@ -67,9 +67,9 @@ const (
// the seed.
// the seed.
EntropySize = 16
EntropySize = 16
// Numm nemonicWords is the number of words that an encoded cipher seed
// NumM nemonicWords is the number of words that an encoded cipher seed
// will result in.
// will result in.
Numm nemonicWords = 24
NumM nemonicWords = 24
// saltSize is the size of the salt we'll generate to use with scrypt
// saltSize is the size of the salt we'll generate to use with scrypt
// to generate a key for use within aez from the user's passphrase. The
// to generate a key for use within aez from the user's passphrase. The
@ -90,9 +90,9 @@ const (
// aez.
// aez.
keyLen = 32
keyLen = 32
// b itsPerWord is the number of bits each word in the wordlist encodes.
// B itsPerWord is the number of bits each word in the wordlist encodes.
// We encode our mnemonic using 24 words, so 264 bits (33 bytes).
// We encode our mnemonic using 24 words, so 264 bits (33 bytes).
b itsPerWord = 11
B itsPerWord = 11
// saltOffset is the index within an enciphered cipherseed that marks
// saltOffset is the index within an enciphered cipherseed that marks
// the start of the salt.
// the start of the salt.
@ -337,7 +337,7 @@ func (c *CipherSeed) encipher(pass []byte) ([EncipheredCipherSeedSize]byte, erro
// cipherTextToMnemonic converts the aez ciphertext appended with the salt to a
// cipherTextToMnemonic converts the aez ciphertext appended with the salt to a
// 24-word mnemonic pass phrase.
// 24-word mnemonic pass phrase.
func cipherTextToMnemonic ( cipherText [ EncipheredCipherSeedSize ] byte ) ( Mnemonic , error ) {
func cipherTextToMnemonic ( cipherText [ EncipheredCipherSeedSize ] byte ) ( Mnemonic , error ) {
var words [ Numm nemonicWords ] string
var words [ NumM nemonicWords ] string
// First, we'll convert the ciphertext itself into a bitstream for easy
// First, we'll convert the ciphertext itself into a bitstream for easy
// manipulation.
// manipulation.
@ -345,13 +345,13 @@ func cipherTextToMnemonic(cipherText [EncipheredCipherSeedSize]byte) (Mnemonic,
// With our bitstream obtained, we'll read 11 bits at a time, then use
// With our bitstream obtained, we'll read 11 bits at a time, then use
// that to index into our word list to obtain the next word.
// that to index into our word list to obtain the next word.
for i := 0 ; i < Numm nemonicWords ; i ++ {
for i := 0 ; i < NumM nemonicWords ; i ++ {
index , err := cipherBits . ReadBits ( b itsPerWord)
index , err := cipherBits . ReadBits ( B itsPerWord)
if err != nil {
if err != nil {
return Mnemonic { } , err
return Mnemonic { } , err
}
}
words [ i ] = d efaultWordList[ index ]
words [ i ] = D efaultWordList[ index ]
}
}
return words , nil
return words , nil
@ -391,7 +391,7 @@ func (c *CipherSeed) BirthdayTime() time.Time {
// Additionally, we also encode the salt used with scrypt to derive the key
// Additionally, we also encode the salt used with scrypt to derive the key
// that the cipher text is encrypted with, and the version which tells us how
// that the cipher text is encrypted with, and the version which tells us how
// to decipher the seed.
// to decipher the seed.
type Mnemonic [ Numm nemonicWords ] string
type Mnemonic [ NumM nemonicWords ] string
// mnemonicToCipherText converts a 24-word mnemonic phrase into a 33 byte
// mnemonicToCipherText converts a 24-word mnemonic phrase into a 33 byte
// cipher text.
// cipher text.
@ -408,11 +408,11 @@ func mnemonicToCipherText(mnemonic *Mnemonic) [EncipheredCipherSeedSize]byte {
for _ , word := range mnemonic {
for _ , word := range mnemonic {
// Using the reverse word map, we'll locate the index of this
// Using the reverse word map, we'll locate the index of this
// word within the word list.
// word within the word list.
index := uint64 ( r everseWordMap[ word ] )
index := uint64 ( R everseWordMap[ word ] )
// With the index located, we'll now write this out to the
// With the index located, we'll now write this out to the
// bitstream, appending to what's already there.
// bitstream, appending to what's already there.
cipherBits . WriteBits ( index , b itsPerWord)
cipherBits . WriteBits ( index , B itsPerWord)
}
}
copy ( cipherText [ : ] , cipherBits . Bytes ( ) )
copy ( cipherText [ : ] , cipherBits . Bytes ( ) )
@ -505,8 +505,8 @@ func (m *Mnemonic) Decipher(pass []byte) ([DecipheredCipherSeedSize]byte, error)
// Before we attempt to map the mnemonic back to the original
// Before we attempt to map the mnemonic back to the original
// ciphertext, we'll ensure that all the word are actually a part of
// ciphertext, we'll ensure that all the word are actually a part of
// the current default word list.
// the current default word list.
wordDict := make ( map [ string ] struct { } , len ( d efaultWordList) )
wordDict := make ( map [ string ] struct { } , len ( D efaultWordList) )
for _ , word := range d efaultWordList {
for _ , word := range D efaultWordList {
wordDict [ word ] = struct { } { }
wordDict [ word ] = struct { } { }
}
}