/// <summary> /// Generate a mnemonic /// </summary> /// <param name="wordList"></param> /// <param name="entropy"></param> public Mnemonic(Wordlist wordList, byte[] entropy = null) { wordList = wordList ?? Wordlist.English; _WordList = wordList; if (entropy == null) { entropy = RandomUtils.GetBytes(32); } var i = Array.IndexOf(entArray, entropy.Length * 8); if (i == -1) { throw new ArgumentException("The length for entropy should be : " + String.Join(",", entArray), "entropy"); } int cs = csArray[i]; byte[] checksum = Hashes.SHA256(entropy); BitWriter entcsResult = new BitWriter(); entcsResult.Write(entropy); entcsResult.Write(checksum, cs); _Indices = entcsResult.ToIntegers(); _Words = _WordList.GetWords(_Indices); _Mnemonic = _WordList.GetSentence(_Indices); }
/// <summary> /// Generate a mnemonic /// </summary> /// <param name="wordList"></param> /// <param name="entropy"></param> public Mnemonic(Wordlist wordList, byte[] entropy = null) { wordList = wordList ?? Wordlist.English; _WordList = wordList; if(entropy == null) entropy = RandomUtils.GetBytes(32); var i = Array.IndexOf(entArray, entropy.Length * 8); if(i == -1) throw new ArgumentException("The length for entropy should be : " + String.Join(",", entArray), "entropy"); int cs = csArray[i]; byte[] checksum = Hashes.SHA256(entropy); BitWriter entcsResult = new BitWriter(); entcsResult.Write(entropy); entcsResult.Write(checksum, cs); _Indices = entcsResult.ToIntegers(); _Words = _WordList.GetWords(_Indices); _Mnemonic = _WordList.GetSentence(_Indices); }
public string ToString(Wordlist wordlist) { return wordlist.GetSentence(WordIndices); }
public string ToString(Wordlist wordlist) { return(wordlist.GetSentence(WordIndices)); }