Why Redacted Types Matter
Private keys, mnemonics, and API keys can leak through:- Console logging during debugging
- Error stack traces
- JSON serialization in API responses
- Unintentional exposure in logs
Redacted<T> type prevents accidental exposure by showing <redacted> instead of the actual value.
Primitives That Should Use Redacted
| Primitive | Redacted Schema | Risk if Exposed |
|---|---|---|
| Private Keys | PrivateKey.RedactedHex | Full account control |
| Mnemonics | Manual Redacted.make() | All derived wallets compromised |
| API Keys | Manual Redacted.make() | Rate limits, billing, access |
| Encryption Keys | Manual Redacted.make() | Data decryption |
Safe Logging Example
Unwrapping When Needed
UseRedacted.value() to explicitly access the underlying value for cryptographic operations:
Creating Redacted Values Manually
For data without built-in Redacted schemas:Round-Trip Encoding
Redacted values encode back to their original form:Error Handling
Parse errors don’t expose attempted values:Environment Variable Pattern
Testing with Redacted Values
See Also
- PrivateKey - Redacted schemas for private keys
- Effect Redacted - Effect’s documentation
- HD Wallet Guide - Deriving keys from mnemonics

