cometa-0.1.0.0: Idiomatic Haskell bindings to cardano-c
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cometa.Crypto.DerivationPath

Description

Validated five-level wallet paths: m purpose' coin_type' account' role / index. Components are unencoded numbers; the first three become hardened when converted to BIP32 indices. Custom purposes, coins and roles are supported within the same bounds as standard paths.

import qualified Cometa.Crypto.DerivationPath as Path

firstAccount :: Path.AccountPath
firstAccount = Path.standardAccountPath minBound
Synopsis

Components

data Index Source #

An unencoded component in 0..2147483647. Equality and ordering compare the component number; Show is diagnostic. minBound is zero and maxBound is 2147483647.

Instances

Instances details
Bounded Index Source # 
Instance details

Defined in Cometa.Crypto.DerivationPath

Show Index Source # 
Instance details

Defined in Cometa.Crypto.DerivationPath

Methods

showsPrec :: Int -> Index -> ShowS #

show :: Index -> String #

showList :: [Index] -> ShowS #

Eq Index Source # 
Instance details

Defined in Cometa.Crypto.DerivationPath

Methods

(==) :: Index -> Index -> Bool #

(/=) :: Index -> Index -> Bool #

Ord Index Source # 
Instance details

Defined in Cometa.Crypto.DerivationPath

Methods

compare :: Index -> Index -> Ordering #

(<) :: Index -> Index -> Bool #

(<=) :: Index -> Index -> Bool #

(>) :: Index -> Index -> Bool #

(>=) :: Index -> Index -> Bool #

max :: Index -> Index -> Index #

min :: Index -> Index -> Index #

mkIndex :: Integer -> Either Error Index Source #

Validate an unencoded component. Negative values and values above 2147483647 return InvalidDerivationIndex, retaining the exact input.

indexValue :: Index -> Word32 Source #

The unencoded component number, without the hardening bit.

Account paths

data AccountPath Source #

Three unencoded components in purpose, coin type, account order. Equality and ordering compare components in that order; Show is diagnostic.

accountPath :: Index -> Index -> Index -> AccountPath Source #

Construct an account prefix from purpose, coin type and account number. All three components will be hardened by accountIndices.

purpose :: AccountPath -> Index Source #

Unencoded purpose number, for example 1852 or 1854.

coinType :: AccountPath -> Index Source #

Unencoded coin type, for example 1815 for Cardano.

account :: AccountPath -> Index Source #

Unencoded account number, numbered from zero.

accountIndices :: AccountPath -> [Word32] Source #

Three encoded hardened indices in derivation order, suitable for private BIP32 derivation from a root key. Each has its high bit set.

Key paths

data DerivationPath Source #

An account prefix followed by an unhardened role and key index. Equality and ordering compare all five components in derivation order; Show is diagnostic.

derivationPath :: AccountPath -> Index -> Index -> DerivationPath Source #

Extend an account prefix with an unhardened role and key index, in that order.

accountPrefix :: DerivationPath -> AccountPath Source #

The three-component account prefix.

role :: DerivationPath -> Index Source #

Unhardened role number. Standard roles are named in this module.

index :: DerivationPath -> Index Source #

Unhardened key index, numbered from zero.

toIndices :: DerivationPath -> [Word32] Source #

Five encoded indices in derivation order, suitable for private BIP32 derivation from the root. Only the first three indices are hardened.

relativeIndices :: DerivationPath -> [Word32] Source #

The two unhardened indices, role then key index, relative to an already derived account key. Suitable for private or public BIP32 derivation.

Cardano wallet components

cardanoCoinType :: Index Source #

Cardano coin type.

standardPurpose :: Index Source #

Standard wallet purpose.

multisigPurpose :: Index Source #

CIP-1854 multisignature wallet purpose.

externalRole :: Index Source #

External payment chain role.

internalRole :: Index Source #

Internal change chain role.

stakingRole :: Index Source #

Staking key role (CIP-0011).

drepRole :: Index Source #

Delegated representative key role (CIP-0105).

committeeColdRole :: Index Source #

Constitutional committee cold key role (CIP-0105).

committeeHotRole :: Index Source #

Constitutional committee hot key role (CIP-0105).

standardAccountPath :: Index -> AccountPath Source #

Standard Cardano account prefix for the supplied unencoded account number. Uses purpose 1852 and coin type 1815. For multisignature or custom purposes, use accountPath with the desired components.