| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
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
- data Index
- mkIndex :: Integer -> Either Error Index
- indexValue :: Index -> Word32
- data AccountPath
- accountPath :: Index -> Index -> Index -> AccountPath
- purpose :: AccountPath -> Index
- coinType :: AccountPath -> Index
- account :: AccountPath -> Index
- accountIndices :: AccountPath -> [Word32]
- data DerivationPath
- derivationPath :: AccountPath -> Index -> Index -> DerivationPath
- accountPrefix :: DerivationPath -> AccountPath
- role :: DerivationPath -> Index
- index :: DerivationPath -> Index
- toIndices :: DerivationPath -> [Word32]
- relativeIndices :: DerivationPath -> [Word32]
- cardanoCoinType :: Index
- standardPurpose :: Index
- multisigPurpose :: Index
- externalRole :: Index
- internalRole :: Index
- stakingRole :: Index
- drepRole :: Index
- committeeColdRole :: Index
- committeeHotRole :: Index
- standardAccountPath :: Index -> AccountPath
Components
An unencoded component in 0..2147483647. Equality and ordering compare
the component number; Show is diagnostic. minBound is zero and maxBound
is 2147483647.
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.
Instances
| Show AccountPath Source # | |
Defined in Cometa.Crypto.DerivationPath Methods showsPrec :: Int -> AccountPath -> ShowS # show :: AccountPath -> String # showList :: [AccountPath] -> ShowS # | |
| Eq AccountPath Source # | |
Defined in Cometa.Crypto.DerivationPath | |
| Ord AccountPath Source # | |
Defined in Cometa.Crypto.DerivationPath Methods compare :: AccountPath -> AccountPath -> Ordering # (<) :: AccountPath -> AccountPath -> Bool # (<=) :: AccountPath -> AccountPath -> Bool # (>) :: AccountPath -> AccountPath -> Bool # (>=) :: AccountPath -> AccountPath -> Bool # max :: AccountPath -> AccountPath -> AccountPath # min :: AccountPath -> AccountPath -> AccountPath # | |
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.
Instances
| Show DerivationPath Source # | |
Defined in Cometa.Crypto.DerivationPath Methods showsPrec :: Int -> DerivationPath -> ShowS # show :: DerivationPath -> String # showList :: [DerivationPath] -> ShowS # | |
| Eq DerivationPath Source # | |
Defined in Cometa.Crypto.DerivationPath Methods (==) :: DerivationPath -> DerivationPath -> Bool # (/=) :: DerivationPath -> DerivationPath -> Bool # | |
| Ord DerivationPath Source # | |
Defined in Cometa.Crypto.DerivationPath Methods compare :: DerivationPath -> DerivationPath -> Ordering # (<) :: DerivationPath -> DerivationPath -> Bool # (<=) :: DerivationPath -> DerivationPath -> Bool # (>) :: DerivationPath -> DerivationPath -> Bool # (>=) :: DerivationPath -> DerivationPath -> Bool # max :: DerivationPath -> DerivationPath -> DerivationPath # min :: DerivationPath -> DerivationPath -> DerivationPath # | |
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).
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.