Expand description
Cryptographic primitives for Freebird
This module provides high-level APIs for VOPRF operations using the internal P-256 implementation in voprf/.
§Memory Zeroization Security
Freebird implements comprehensive memory zeroization to protect cryptographic key material from memory dumps, cold boot attacks, and other extraction methods.
§Automatic Zeroization
-
Scalar values (blinding factors, secret keys): The
Scalartype from RustCrypto’selliptic-curvecrate implementsDefaultIsZeroes, ensuring automatic memory zeroization when dropped. This applies to:- VOPRF blinding factors (
rinBlindState) - DLEQ proof ephemeral scalars (
rinprove()) - Secret keys in VOPRF operations
- VOPRF blinding factors (
-
Software provider secret keys: The
SoftwareCryptoProviderexplicitly zeroizes its secret key in theDropimplementation. -
PKCS11 provider MAC keys: The
Pkcs11CryptoProviderzeroizes themac_base_keyderived from the HSM in itsDropimplementation.
§Explicit Zeroization (via Zeroizing wrapper)
- MAC keys: All MAC keys derived for token authentication are wrapped in
Zeroizing<[u8; 32]>to ensure they are erased immediately after use:- Issuer token MAC computation
- Verifier token MAC verification
- Batch issuance MAC operations
§Non-Secret Values (No Zeroization)
- Elliptic curve points (
ProjectivePoint,AffinePoint): These are public values that do not require zeroization. - Token data: Tokens are meant to be shared and do not contain secrets.
- Public keys: Public keys are intentionally shareable.
§Verification
To verify zeroization is working correctly, use memory analysis tools or run the zeroization tests in the test suite.
Modules§
- provider
- Cryptographic provider abstraction for software and HSM backends
- voprf
- Vendored VOPRF(P-256, SHA-256)-verifiable implementation built on RustCrypto.
Structs§
Enums§
Constants§
- TOKEN_
FORMAT_ V1_ MAC - Token format versions
- TOKEN_
FORMAT_ V2_ SIGNATURE - TOKEN_
LEN_ V1 - Total token lengths including authentication
- TOKEN_
LEN_ V2 - TOKEN_
MAC_ LEN - Token MAC constants
- TOKEN_
SIGNATURE_ LEN - Token signature constants (for public-key metadata authentication)
Functions§
- compute_
token_ mac - Compute HMAC-SHA256 over token and metadata to prevent tampering
- compute_
token_ signature - Compute ECDSA signature over token metadata to prevent tampering
- derive_
mac_ key - Derive MAC key from server secret key using HKDF (legacy, simple version)
- derive_
mac_ key_ v2 - Derive MAC key from server secret key using HKDF with domain separation
- nullifier_
key - Deterministic nullifier seed for anti-double-spend.
- sign_
message - Sign an arbitrary message with an issuer’s secret key
- verify_
message_ signature - Verify an arbitrary message signature with an issuer’s public key
- verify_
token_ mac - Verify HMAC-SHA256 over token and metadata (constant-time)
- verify_
token_ signature - Verify ECDSA signature over token metadata (constant-time)