distribute/crypto/noop_adapter
No-op crypto adapter for development and testing.
WARNING: This adapter provides NO ACTUAL ENCRYPTION. It is intended only for development, testing, and debugging. Never use this adapter in production environments.
Features
- Identity encryption: Returns plaintext unchanged
- Instant handshake: Completes immediately without key exchange
- Fake secure contexts: Creates placeholder contexts
- Full metrics: Tracks operations for testing
Usage
import distribute/crypto/adapter
import distribute/crypto/noop_adapter
let opts = adapter.development_options("test_crypto")
let provider = noop_adapter.new()
let assert Ok(handle) = provider.init(opts)
// "Encrypt" (actually just returns the input)
let assert Ok(ciphertext) = provider.encrypt(handle, ctx, plaintext)
Types
Values
pub fn child_spec(
options: types.ProviderOptions,
) -> supervision.ChildSpecification(types.ProviderHandle)
Create a child specification for OTP supervision.
Returns a supervision child spec that starts the noop adapter as a supervised worker. Use this when integrating with OTP supervision trees.
Arguments
options- Provider options (name, timeouts, etc.)
Example
let opts = adapter.development_options("crypto")
let spec = noop_adapter.child_spec(opts)
// Add to supervisor
let children = [spec, ...other_children]
Lifecycle
The supervised process will:
- Start the actor with initial state
- Register with the global registry
- Handle all crypto commands
- Clean up on shutdown
pub fn get_handle(
name: String,
) -> Result(types.ProviderHandle, Nil)
Get a handle to a running provider by name.
Looks up a previously started noop adapter in the registry and returns a handle that can be used for crypto operations.
Arguments
name- The name the provider was registered with
Returns
Ok(handle)- Handle to the running providerError(Nil)- No provider registered with that name
Example
case noop_adapter.get_handle("my_crypto") {
Ok(handle) -> { adapter.encrypt }(handle, ctx, data)
Error(Nil) -> Error(NotInitialized)
}
pub fn new() -> adapter.CryptoAdapter
Create a new no-op crypto adapter.
Returns a CryptoAdapter that implements the crypto behaviour contract
with identity transformations (no actual encryption).
⚠️ WARNING: This adapter provides NO REAL ENCRYPTION.
Use this adapter ONLY for:
- Development and local testing
- Debugging message flow without crypto overhead
- Benchmarking non-crypto performance
Features
- Instant handshake (completes immediately)
- Identity encryption (plaintext = ciphertext)
- Full metrics tracking for testing
- Safe for supervision trees
Example
let adapter = noop_adapter.new()
let opts = adapter.development_options("test")
let assert Ok(handle) = adapter.init(opts)
Security
Never use in production. The health status will report Degraded
when is_development = True to remind you this is not secure.