| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Cardano.Address.Crypto.BIP39
Description
Vendored from cardano-crypto (Apache-2.0).
Original: Crypto.Encoding.BIP39
Basement types replaced with standard Haskell equivalents.
Synopsis
- data Entropy (n :: Nat)
- type ValidEntropySize (n :: Nat) = (KnownNat n, Elem n '[96, 128, 160, 192, 224, 256])
- data Checksum (bits :: Nat)
- type ValidChecksumSize (ent :: Nat) (csz :: Nat) = (KnownNat csz, Elem csz '[3, 4, 5, 6, 7, 8], CheckSumBits ent ~ csz)
- type family MnemonicWords (n :: Nat) :: Nat where ...
- type family EntropySize (n :: Nat) :: Nat where ...
- toEntropy :: forall (n :: Nat) (csz :: Nat) ba. (ValidEntropySize n, ValidChecksumSize n csz, ByteArrayAccess ba) => ba -> Either (EntropyError csz) (Entropy n)
- entropyRaw :: Entropy n -> ByteString
- entropyChecksum :: Entropy n -> Checksum (CheckSumBits n)
- entropyToWords :: forall (n :: Nat) (csz :: Nat) (mw :: Nat). ConsistentEntropy n mw csz => Entropy n -> MnemonicSentence mw
- wordsToEntropy :: forall (ent :: Nat) (csz :: Nat) (mw :: Nat). ConsistentEntropy ent mw csz => MnemonicSentence mw -> Either (EntropyError csz) (Entropy ent)
- data Seed
- type Passphrase = Text
- sentenceToSeed :: forall (mw :: Nat). ValidMnemonicSentence mw => MnemonicSentence mw -> Dictionary -> Passphrase -> Seed
- phraseToSeed :: forall (mw :: Nat). ValidMnemonicSentence mw => MnemonicPhrase mw -> Dictionary -> Passphrase -> Seed
- newtype MnemonicSentence (mw :: Nat) = MnemonicSentence {}
- data MnemonicPhrase (mw :: Nat)
- type ValidMnemonicSentence (mw :: Nat) = (KnownNat mw, Elem mw '[9, 12, 15, 18, 21, 24])
- mnemonicPhrase :: forall (mw :: Nat). ValidMnemonicSentence mw => [Text] -> Either MnemonicWordsError (MnemonicPhrase mw)
- checkMnemonicPhrase :: forall (mw :: Nat). ValidMnemonicSentence mw => Dictionary -> MnemonicPhrase mw -> Bool
- mnemonicPhraseToMnemonicSentence :: forall (mw :: Nat). ValidMnemonicSentence mw => Dictionary -> MnemonicPhrase mw -> Either DictionaryError (MnemonicSentence mw)
- mnemonicSentenceToMnemonicPhrase :: forall (mw :: Nat). ValidMnemonicSentence mw => Dictionary -> MnemonicSentence mw -> MnemonicPhrase mw
- mnemonicSentenceToString :: forall (mw :: Nat). ValidMnemonicSentence mw => Dictionary -> MnemonicSentence mw -> Text
- mnemonicPhraseToString :: forall (mw :: Nat). ValidMnemonicSentence mw => Dictionary -> MnemonicPhrase mw -> Text
- mnemonicPhraseToListN :: MnemonicPhrase mw -> ListN mw Text
- translateTo :: forall (mw :: Nat). ValidMnemonicSentence mw => Dictionary -> Dictionary -> MnemonicPhrase mw -> Either DictionaryError (MnemonicPhrase mw)
- data Dictionary = Dictionary {}
- data WordIndex
- wordIndex :: Word16 -> WordIndex
- unWordIndex :: WordIndex -> Word16
- type ConsistentEntropy (ent :: Nat) (mw :: Nat) (csz :: Nat) = (ValidEntropySize ent, ValidChecksumSize ent csz, ValidMnemonicSentence mw, MnemonicWords ent ~ mw)
- type family CheckSumBits (n :: Nat) :: Nat where ...
- type family Elem (e :: Nat) (l :: [Nat]) where ...
- newtype DictionaryError = ErrInvalidDictionaryWord Text
- data EntropyError (csz :: Nat)
- = ErrInvalidEntropyLength Int Int
- | ErrInvalidEntropyChecksum (Checksum csz) (Checksum csz)
- data MnemonicWordsError = ErrWrongNumberOfWords Int Int
Entropy
type ValidEntropySize (n :: Nat) = (KnownNat n, Elem n '[96, 128, 160, 192, 224, 256]) #
type ValidChecksumSize (ent :: Nat) (csz :: Nat) = (KnownNat csz, Elem csz '[3, 4, 5, 6, 7, 8], CheckSumBits ent ~ csz) #
type family MnemonicWords (n :: Nat) :: Nat where ... #
Equations
| MnemonicWords 96 = 9 | |
| MnemonicWords 128 = 12 | |
| MnemonicWords 160 = 15 | |
| MnemonicWords 192 = 18 | |
| MnemonicWords 224 = 21 | |
| MnemonicWords 256 = 24 |
type family EntropySize (n :: Nat) :: Nat where ... #
Equations
| EntropySize 9 = 96 | |
| EntropySize 12 = 128 | |
| EntropySize 15 = 160 | |
| EntropySize 18 = 192 | |
| EntropySize 21 = 224 | |
| EntropySize 24 = 256 |
toEntropy :: forall (n :: Nat) (csz :: Nat) ba. (ValidEntropySize n, ValidChecksumSize n csz, ByteArrayAccess ba) => ba -> Either (EntropyError csz) (Entropy n) #
entropyRaw :: Entropy n -> ByteString #
entropyChecksum :: Entropy n -> Checksum (CheckSumBits n) #
entropyToWords :: forall (n :: Nat) (csz :: Nat) (mw :: Nat). ConsistentEntropy n mw csz => Entropy n -> MnemonicSentence mw #
wordsToEntropy :: forall (ent :: Nat) (csz :: Nat) (mw :: Nat). ConsistentEntropy ent mw csz => MnemonicSentence mw -> Either (EntropyError csz) (Entropy ent) #
Seed
type Passphrase = Text #
sentenceToSeed :: forall (mw :: Nat). ValidMnemonicSentence mw => MnemonicSentence mw -> Dictionary -> Passphrase -> Seed #
phraseToSeed :: forall (mw :: Nat). ValidMnemonicSentence mw => MnemonicPhrase mw -> Dictionary -> Passphrase -> Seed #
Mnemonic Sentence
newtype MnemonicSentence (mw :: Nat) #
Constructors
| MnemonicSentence | |
Fields | |
Instances
| NFData (MnemonicSentence mw) # | |
Defined in Cardano.Address.Crypto.BIP39 Methods rnf :: MnemonicSentence mw -> () # | |
| Show (MnemonicSentence mw) # | |
Defined in Cardano.Address.Crypto.BIP39 Methods showsPrec :: Int -> MnemonicSentence mw -> ShowS # show :: MnemonicSentence mw -> String # showList :: [MnemonicSentence mw] -> ShowS # | |
| Eq (MnemonicSentence mw) # | |
Defined in Cardano.Address.Crypto.BIP39 Methods (==) :: MnemonicSentence mw -> MnemonicSentence mw -> Bool # (/=) :: MnemonicSentence mw -> MnemonicSentence mw -> Bool # | |
data MnemonicPhrase (mw :: Nat) #
Instances
| NFData (MnemonicPhrase mw) # | |
Defined in Cardano.Address.Crypto.BIP39 Methods rnf :: MnemonicPhrase mw -> () # | |
| Show (MnemonicPhrase mw) # | |
Defined in Cardano.Address.Crypto.BIP39 Methods showsPrec :: Int -> MnemonicPhrase mw -> ShowS # show :: MnemonicPhrase mw -> String # showList :: [MnemonicPhrase mw] -> ShowS # | |
| Eq (MnemonicPhrase mw) # | |
Defined in Cardano.Address.Crypto.BIP39 Methods (==) :: MnemonicPhrase mw -> MnemonicPhrase mw -> Bool # (/=) :: MnemonicPhrase mw -> MnemonicPhrase mw -> Bool # | |
type ValidMnemonicSentence (mw :: Nat) = (KnownNat mw, Elem mw '[9, 12, 15, 18, 21, 24]) #
mnemonicPhrase :: forall (mw :: Nat). ValidMnemonicSentence mw => [Text] -> Either MnemonicWordsError (MnemonicPhrase mw) #
checkMnemonicPhrase :: forall (mw :: Nat). ValidMnemonicSentence mw => Dictionary -> MnemonicPhrase mw -> Bool #
mnemonicPhraseToMnemonicSentence :: forall (mw :: Nat). ValidMnemonicSentence mw => Dictionary -> MnemonicPhrase mw -> Either DictionaryError (MnemonicSentence mw) #
mnemonicSentenceToMnemonicPhrase :: forall (mw :: Nat). ValidMnemonicSentence mw => Dictionary -> MnemonicSentence mw -> MnemonicPhrase mw #
mnemonicSentenceToString :: forall (mw :: Nat). ValidMnemonicSentence mw => Dictionary -> MnemonicSentence mw -> Text #
mnemonicPhraseToString :: forall (mw :: Nat). ValidMnemonicSentence mw => Dictionary -> MnemonicPhrase mw -> Text #
mnemonicPhraseToListN :: MnemonicPhrase mw -> ListN mw Text #
translateTo :: forall (mw :: Nat). ValidMnemonicSentence mw => Dictionary -> Dictionary -> MnemonicPhrase mw -> Either DictionaryError (MnemonicPhrase mw) #
Dictionary
Index of a mnemonic word in the Dictionary.
WordIndex values are in the range [0..2047].
Instances
| NFData WordIndex # | |
Defined in Cardano.Address.Crypto.BIP39.Dictionary | |
| Bounded WordIndex # | |
| Enum WordIndex # | |
Defined in Cardano.Address.Crypto.BIP39.Dictionary Methods succ :: WordIndex -> WordIndex # pred :: WordIndex -> WordIndex # fromEnum :: WordIndex -> Int # enumFrom :: WordIndex -> [WordIndex] # enumFromThen :: WordIndex -> WordIndex -> [WordIndex] # enumFromTo :: WordIndex -> WordIndex -> [WordIndex] # enumFromThenTo :: WordIndex -> WordIndex -> WordIndex -> [WordIndex] # | |
| Show WordIndex # | |
| Eq WordIndex # | |
| Ord WordIndex # | |
Defined in Cardano.Address.Crypto.BIP39.Dictionary | |
unWordIndex :: WordIndex -> Word16 #
Extract the raw index.
helpers
type ConsistentEntropy (ent :: Nat) (mw :: Nat) (csz :: Nat) = (ValidEntropySize ent, ValidChecksumSize ent csz, ValidMnemonicSentence mw, MnemonicWords ent ~ mw) #
type family CheckSumBits (n :: Nat) :: Nat where ... #
Equations
| CheckSumBits 96 = 3 | |
| CheckSumBits 128 = 4 | |
| CheckSumBits 160 = 5 | |
| CheckSumBits 192 = 6 | |
| CheckSumBits 224 = 7 | |
| CheckSumBits 256 = 8 |
Errors
newtype DictionaryError #
Errors from dictionary lookup.
Constructors
| ErrInvalidDictionaryWord Text |
Instances
| NFData DictionaryError # | |
Defined in Cardano.Address.Crypto.BIP39.Dictionary Methods rnf :: DictionaryError -> () # | |
| Show DictionaryError # | |
Defined in Cardano.Address.Crypto.BIP39.Dictionary Methods showsPrec :: Int -> DictionaryError -> ShowS # show :: DictionaryError -> String # showList :: [DictionaryError] -> ShowS # | |
| Eq DictionaryError # | |
Defined in Cardano.Mnemonic Methods (==) :: DictionaryError -> DictionaryError -> Bool # (/=) :: DictionaryError -> DictionaryError -> Bool # | |
data EntropyError (csz :: Nat) #
Constructors
| ErrInvalidEntropyLength Int Int | |
| ErrInvalidEntropyChecksum (Checksum csz) (Checksum csz) |
Instances
| NFData (EntropyError csz) # | |
Defined in Cardano.Mnemonic Methods rnf :: EntropyError csz -> () # | |
| Show (EntropyError csz) # | |
Defined in Cardano.Address.Crypto.BIP39 Methods showsPrec :: Int -> EntropyError csz -> ShowS # show :: EntropyError csz -> String # showList :: [EntropyError csz] -> ShowS # | |
| Eq (EntropyError czs) # | |
Defined in Cardano.Mnemonic Methods (==) :: EntropyError czs -> EntropyError czs -> Bool # (/=) :: EntropyError czs -> EntropyError czs -> Bool # | |
data MnemonicWordsError #
Constructors
| ErrWrongNumberOfWords Int Int |
Instances
| NFData MnemonicWordsError # | |
Defined in Cardano.Mnemonic Methods rnf :: MnemonicWordsError -> () # | |
| Show MnemonicWordsError # | |
Defined in Cardano.Address.Crypto.BIP39 Methods showsPrec :: Int -> MnemonicWordsError -> ShowS # show :: MnemonicWordsError -> String # showList :: [MnemonicWordsError] -> ShowS # | |
| Eq MnemonicWordsError # | |
Defined in Cardano.Mnemonic Methods (==) :: MnemonicWordsError -> MnemonicWordsError -> Bool # (/=) :: MnemonicWordsError -> MnemonicWordsError -> Bool # | |