cardano-crypto-wallet-0.1.0.0: Authenticated v2 envelope for HD wallet keys
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cardano.Crypto.WalletHD.Encrypted

Description

Keys are stored as CBOR-encoded v2 envelopes: a random 32-byte salt and 24-byte nonce, Argon2id-derived 32-byte wrapping key, and the 64-byte extended secret key encrypted with XChaCha20-Poly1305. The public key and chain code are bound as AEAD additional data so they cannot be silently swapped without detection.

The plaintext secret key is held exclusively in sodium_malloc'd memory (MLockedSizedBytes) which is locked against swapping and is never moved by the GC. All public operations are in IO; callers must mlsbFinalize any MLockedSizedBytes they receive when done with it.

Synopsis

Types

data XPrvFormat Source #

Constructors

LegacyV1 
EnvelopeV2 

Instances

Instances details
Show XPrvFormat Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Eq XPrvFormat Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==)XPrvFormatXPrvFormatBool #

(/=)XPrvFormatXPrvFormatBool #

newtype Signature Source #

Constructors

Signature ByteString 

Instances

Instances details
Show Signature Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrecIntSignatureShowS #

showSignatureString #

showList ∷ [Signature] → ShowS #

NFData Signature Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

rnfSignature → () #

Eq Signature Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==)SignatureSignatureBool #

(/=)SignatureSignatureBool #

data DerivationScheme Source #

Instances

Instances details
Bounded DerivationScheme Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Enum DerivationScheme Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Show DerivationScheme Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Eq DerivationScheme Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Ord DerivationScheme Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Construction & validation

encryptedCreate ∷ (ByteArrayAccess passphrase, ByteArrayAccess secret, ByteArrayAccess cc) ⇒ secret → passphrase → cc → IO (Either XPrvError EncryptedKey) Source #

encryptedCreateDirectWithTweak ∷ (ByteArrayAccess passphrase, ByteArrayAccess secret) ⇒ secret → passphrase → IO (Either XPrvError EncryptedKey) Source #

Passphrase operations

encryptedChangePass ∷ (ByteArrayAccess oldPassPhrase, ByteArrayAccess newPassPhrase) ⇒ oldPassPhrase → newPassPhrase → EncryptedKeyIO (Either XPrvError EncryptedKey) Source #

Signing & derivation

encryptedSign ∷ (ByteArrayAccess passphrase, ByteArrayAccess msg) ⇒ EncryptedKey → passphrase → msg → IO (Either XPrvError Signature) Source #

encryptedDerivePublicDerivationScheme → (PublicKey, ChainCode) → DerivationIndex → (PublicKey, ChainCode) Source #

Accessors

encryptedKeyMaterialByteArrayAccess passphrase ⇒ EncryptedKey → passphrase → IO (Either XPrvError (MLockedSizedBytes 64)) Source #

Decrypt a v2 EncryptedKey and return the 64-byte extended ed25519 scalar in locked memory. The caller must mlsbFinalize the result when done with it.

Test helpers

withFastKdfForTestingIO a → IO a Source #

Reduce Argon2id cost for fast tests while keeping all v2 envelope structure intact.

withDeterministicRandomnessForTestingIO a → IO a Source #

Replace system randomness with a deterministic counter for reproducible test output.