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

(==)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

PublicKey

data PublicKey Source #

Instances

Instances details
Show PublicKey Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrecIntPublicKeyShowS #

showPublicKeyString #

showList ∷ [PublicKey] → ShowS #

Eq PublicKey Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==)PublicKeyPublicKeyBool #

(/=)PublicKeyPublicKeyBool #

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

showsPrecIntChainCodeShowS #

showChainCodeString #

showList ∷ [ChainCode] → ShowS #

Eq ChainCode Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==)ChainCodeChainCodeBool #

(/=)ChainCodeChainCodeBool #

Salt

data Salt Source #

Instances

Instances details
Show Salt Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrecIntSaltShowS #

showSaltString #

showList ∷ [Salt] → ShowS #

Eq Salt Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==)SaltSaltBool #

(/=)SaltSaltBool #

Nonce

data Nonce Source #

Instances

Instances details
Show Nonce Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrecIntNonceShowS #

showNonceString #

showList ∷ [Nonce] → ShowS #

Eq Nonce Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==)NonceNonceBool #

(/=)NonceNonceBool #

Tag

data Tag Source #

Instances

Instances details
Show Tag Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrecIntTagShowS #

showTagString #

showList ∷ [Tag] → ShowS #

Eq Tag Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==)TagTagBool #

(/=)TagTagBool #

Envelope

data Envelope Source #

Instances

Instances details
Show Envelope Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

showsPrecIntEnvelopeShowS #

showEnvelopeString #

showList ∷ [Envelope] → ShowS #

Eq Envelope Source # 
Instance details

Defined in Cardano.Crypto.WalletHD.Encrypted

Methods

(==)EnvelopeEnvelopeBool #

(/=)EnvelopeEnvelopeBool #

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 #

encryptedKeyByteStringEither 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 → EncryptedKeyIO (Either XPrvError EncryptedKey) Source #

Signing & derivation

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

Accessors

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.