cardano-crypto-wallet-0.2.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

(==) ∷ XPrvFormat → XPrvFormat → Bool #

(/=) ∷ XPrvFormat → XPrvFormat → Bool #

newtype Signature Source #

Constructors

Signature ByteString 

Instances

Instances details
Show Signature Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrec ∷ Int → Signature → ShowS #

show ∷ Signature → String #

showList ∷ [Signature] → ShowS #

NFData Signature Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

rnf ∷ Signature → () #

Eq Signature Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==) ∷ Signature → Signature → Bool #

(/=) ∷ Signature → Signature → Bool #

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

PublicKey

data PublicKey Source #

Instances

Instances details
Show PublicKey Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrec ∷ Int → PublicKey → ShowS #

show ∷ PublicKey → String #

showList ∷ [PublicKey] → ShowS #

Eq PublicKey Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==) ∷ PublicKey → PublicKey → Bool #

(/=) ∷ PublicKey → PublicKey → Bool #

Encrypted SecretKey

data EncSecretKey Source #

Encrypted version of SecretKey

Instances

Instances details
Show EncSecretKey Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Eq EncSecretKey Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

ChainCode

data ChainCode Source #

Instances

Instances details
Show ChainCode Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrec ∷ Int → ChainCode → ShowS #

show ∷ ChainCode → String #

showList ∷ [ChainCode] → ShowS #

Eq ChainCode Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==) ∷ ChainCode → ChainCode → Bool #

(/=) ∷ ChainCode → ChainCode → Bool #

Salt

data Salt Source #

Instances

Instances details
Show Salt Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrec ∷ Int → Salt → ShowS #

show ∷ Salt → String #

showList ∷ [Salt] → ShowS #

Eq Salt Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==) ∷ Salt → Salt → Bool #

(/=) ∷ Salt → Salt → Bool #

Nonce

data Nonce Source #

Instances

Instances details
Show Nonce Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrec ∷ Int → Nonce → ShowS #

show ∷ Nonce → String #

showList ∷ [Nonce] → ShowS #

Eq Nonce Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==) ∷ Nonce → Nonce → Bool #

(/=) ∷ Nonce → Nonce → Bool #

Tag

data Tag Source #

Instances

Instances details
Show Tag Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrec ∷ Int → Tag → ShowS #

show ∷ Tag → String #

showList ∷ [Tag] → ShowS #

Eq Tag Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==) ∷ Tag → Tag → Bool #

(/=) ∷ Tag → Tag → Bool #

Envelope

data Envelope Source #

Instances

Instances details
Show Envelope Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrec ∷ Int → Envelope → ShowS #

show ∷ Envelope → String #

showList ∷ [Envelope] → ShowS #

Eq Envelope Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==) ∷ Envelope → Envelope → Bool #

(/=) ∷ Envelope → Envelope → Bool #

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 #

encryptedKey ∷ ByteString → Either XPrvError EncryptedKey Source #

Deprecated: In favor of mkEncryptedKey

In order to promote smoother migration from cardano-crypto. Use mkEncryptedKey instead

Passphrase operations

encryptedChangePassphrase ∷ (ByteArrayAccess oldPassPhrase, ByteArrayAccess newPassPhrase) ⇒ oldPassPhrase → newPassPhrase → EncryptedKey → IO (Either XPrvError EncryptedKey) Source #

Signing & derivation

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

Accessors

Test helpers

withFastKdfForTesting ∷ IO a → IO a Source #

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

withDeterministicRandomnessForTesting ∷ IO a → IO a Source #

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