Copyright | © 2018-2020 IOHK |
---|---|
License | Apache-2.0 |
Safe Haskell | None |
Language | Haskell2010 |
Implementation of address derivation for the random scheme, as implemented by the legacy Cardano wallets.
For full documentation of the key derivation schemes, see the Cardano.Crypto.Wallet module, and the implementation in cardano-crypto .
Synopsis
-
data
ByronKey
(depth ::
Depth
) key =
ByronKey
{
- getKey :: key
- derivationPath :: DerivationPathFrom depth
- payloadPassphrase :: Passphrase "addr-derivation-payload"
- type family DerivationPathFrom (depth :: Depth ) :: Type where ...
- unsafeGenerateKeyFromSeed :: DerivationPathFrom depth -> SomeMnemonic -> Passphrase "encryption" -> ByronKey depth XPrv
- generateKeyFromSeed :: SomeMnemonic -> Passphrase "encryption" -> ByronKey ' RootK XPrv
- minSeedLengthBytes :: Int
- unsafeMkByronKeyFromMasterKey :: DerivationPathFrom depth -> XPrv -> ByronKey depth XPrv
- mkByronKeyFromMasterKey :: XPrv -> ByronKey ' RootK XPrv
- deriveAccountPrivateKey :: Passphrase "encryption" -> ByronKey ' RootK XPrv -> Index ' WholeDomain ' AccountK -> ByronKey ' AccountK XPrv
- deriveAddressPrivateKey :: Passphrase "encryption" -> ByronKey ' AccountK XPrv -> Index ' WholeDomain ' AddressK -> ByronKey ' AddressK XPrv
Types
data ByronKey (depth :: Depth ) key Source #
Material for deriving HD random scheme keys, which can be used for making addresses.
ByronKey | |
|
Instances
type family DerivationPathFrom (depth :: Depth ) :: Type where ... Source #
The hierarchical derivation indices for a given level/depth.
DerivationPathFrom ' RootK = () | |
DerivationPathFrom ' AccountK = Index ' WholeDomain ' AccountK | |
DerivationPathFrom ' AddressK = ( Index ' WholeDomain ' AccountK , Index ' WholeDomain ' AddressK ) |
Generation
unsafeGenerateKeyFromSeed :: DerivationPathFrom depth -> SomeMnemonic -> Passphrase "encryption" -> ByronKey depth XPrv Source #
Generate a new key from seed. Note that the
depth
is left open so that
the caller gets to decide what type of key this is. This is mostly for
testing, in practice, seeds are used to represent root keys, and one should
use
generateKeyFromSeed
.
generateKeyFromSeed :: SomeMnemonic -> Passphrase "encryption" -> ByronKey ' RootK XPrv Source #
Generate a root key from a corresponding seed. The seed should be at least 16 bytes.
minSeedLengthBytes :: Int Source #
The amount of entropy carried by a BIP-39 12-word mnemonic is 16 bytes.
unsafeMkByronKeyFromMasterKey :: DerivationPathFrom depth -> XPrv -> ByronKey depth XPrv Source #
Derivation
deriveAccountPrivateKey :: Passphrase "encryption" -> ByronKey ' RootK XPrv -> Index ' WholeDomain ' AccountK -> ByronKey ' AccountK XPrv Source #
Derives account private key from the given root private key, using derivation scheme 1.
NOTE: The caller is expected to provide the corresponding passphrase (and to have checked that the passphrase is valid). Providing a wrong passphrase will not make the function fail but will instead, yield an incorrect new key that doesn't belong to the wallet.
deriveAddressPrivateKey :: Passphrase "encryption" -> ByronKey ' AccountK XPrv -> Index ' WholeDomain ' AddressK -> ByronKey ' AddressK XPrv Source #
Derives address private key from the given account private key, using derivation scheme 1.
NOTE: The caller is expected to provide the corresponding passphrase (and to have checked that the passphrase is valid). Providing a wrong passphrase will not make the function fail but will instead, yield an incorrect new key that doesn't belong to the wallet.