HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulecardano-addresses-4.0.2Haskell2010

Cardano.Address.Derivation

  • 8 types
  • 3 classes
  • 27 values

Overview

0 declarations

These abstractions allow generating root private key, also called Master Key and then basing on it enable address derivation

Key Derivation

0 declarations

Types

newtypenewtype Index (derivationType :: DerivationType) (depth :: Depth)
#

A derivation index, with phantom-types to disambiguate derivation type.

let accountIx = Index 'Hardened 'AccountK
let addressIx = Index 'Soft 'PaymentK
Instances10Bounded, Eq, Ord, Show, Generic, NFData, …
  • Bounded (Index 'Hardened depth)Defined in cardano-addresses-4.0.2 · Cardano.Address.Derivation
  • Bounded (Index 'Soft depth)Defined in cardano-addresses-4.0.2 · Cardano.Address.Derivation
  • Bounded (Index 'WholeDomain depth)Defined in cardano-addresses-4.0.2 · Cardano.Address.Derivation
  • Eq (Index derivationType depth)Defined in cardano-addresses-4.0.2 · Cardano.Address.Derivation
  • Ord (Index derivationType depth)Defined in cardano-addresses-4.0.2 · Cardano.Address.Derivation
  • Show (Index derivationType depth)Defined in cardano-addresses-4.0.2 · Cardano.Address.Derivation
  • Generic (Index derivationType depth)Defined in cardano-addresses-4.0.2 · Cardano.Address.Derivation
  • NFData (Index derivationType depth)Defined in cardano-addresses-4.0.2 · Cardano.Address.Derivation
  • Buildable (Index derivationType depth)Defined in cardano-addresses-4.0.2 · Cardano.Address.Derivation
  • type Rep (Index derivationType depth) = D1 ('MetaData "Index" "Cardano.Address.Derivation" "cardano-addresses-4.0.2-IfBlVg9kl2D9r65sjHkHQ2" 'True) (C1 ('MetaCons "Index" 'PrefixI 'True) (S1 ('MetaSel ('Just "indexToWord32") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Word32)))Defined in cardano-addresses-4.0.2 · Cardano.Address.Derivation
datadata DerivationType
#

Type of derivation that should be used with the given indexes.

In theory, we should only consider two derivation types: soft and hard.

However, historically, addresses in Cardano used to be generated across both the soft and the hard domain. We therefore introduce a WholeDomain derivation type that is the exact union of Hardened and Soft.

Abstractions

3 declarations
classclass GenMasterKey (key :: Depth -> Type -> Type) where
#

Abstract interface for constructing a Master Key.

Associated types

Methods

Instances4GenMasterKey
  • GenMasterKey ByronDefined in cardano-addresses-4.0.2 · Cardano.Address.Style.Byron

    Key Derivation

    Example:

    Generating a root key from SomeMnemonic
    >>> :set -XOverloadedStrings
    >>> :set -XTypeApplications
    >>> :set -XDataKinds
    >>> :set -XFlexibleContexts
    >>> import Cardano.Mnemonic ( mkSomeMnemonic )
    >>> import Cardano.Address ( base58 )
    >>> import Cardano.Address.Derivation ( toXPub )
    >>> import qualified Cardano.Address.Style.Byron as Byron
    
    >>> let (Right mw) = mkSomeMnemonic @'[12] ["moon","fox","ostrich","quick","cactus","raven","wasp","intact","first","ring","crumble","error"]
    >>> let rootK = Byron.genMasterKeyFromMnemonic mw :: Byron 'RootK XPrv
    
    Deriving child keys

    Both accIx and addIx assume values from 0 to 4294967295 (ie. 0xFFFFFFFF) In case of account one can get this bound via

    let accIxMin = minBound (Index 'WholeDomain 'AccountK)
    let accIxMax = maxBound (Index 'WholeDomain 'AccountK)
    
    >>> let Just accIx = wholeDomainIndex 0x80000000
    >>> let acctK = Byron.deriveAccountPrivateKey rootK accIx
    
    >>> let Just addIx = wholeDomainIndex 0x80000014
    >>> let addrK = Byron.deriveAddressPrivateKey acctK addIx
    
    >>> base58 $ Byron.paymentAddress Byron.byronMainnet (toXPub $ addrK)
    DdzFFzCqrhsq3KjLtT51mESbZ4RepiHPzLqEhamexVFTJpGbCXmh7qSxnHvaL88QmtVTD1E1sjx8Z1ZNDhYmcBV38ZjDST9kYVxSkhcw
    
  • GenMasterKey IcarusDefined in cardano-addresses-4.0.2 · Cardano.Address.Style.Icarus
  • GenMasterKey SharedDefined in cardano-addresses-4.0.2 · Cardano.Address.Style.Shared
  • GenMasterKey ShelleyDefined in cardano-addresses-4.0.2 · Cardano.Address.Style.Shelley
classclass HardDerivation (key :: Depth -> Type -> Type) where
#

An interface for doing hard derivations from the root private key, Master Key

Associated types

Methods

Instances4HardDerivation
classclass HardDerivation key => SoftDerivation (key :: Depth -> Type -> Type) where
#

An interface for doing soft derivations from an account public key

Methods

Instances3SoftDerivation

Low-Level Cryptography Primitives

0 declarations

XPrv

XPub

Pub

newtypenewtype Pub
#

An opaque type representing a non-extended public key.

Properties:

Roundtripping
forall pub. pubFromBytes (pubToBytes pub) == Just pub
Instances2Eq, Show
  • Eq PubDefined in cardano-addresses-4.0.2 · Cardano.Address.Derivation
  • Show PubDefined in cardano-addresses-4.0.2 · Cardano.Address.Derivation

XSignature

datadata DerivationScheme
#
Instances6Bounded, Enum, Eq, Ord, Show, Arbitrary