Exemplo n.º 1
0
        //ideographic space used by japanese language

        #endregion Public Constants and Enums

        #region Constructors

        /// <summary>
        /// Constructor to build a BIP39 object from scratch given an entropy size and an optional passphrase. Language is optional and will default to English
        /// </summary>
        /// <param name="entropySize">The size in bits of the entropy to be created</param>
        /// <param name="passphrase">The optional passphrase. Please ensure NFKD Normalized, Empty string will be used if not provided as per spec</param>
        /// <param name="language">The optional language. If no language is provided English will be used</param>
        public BIP39(int entropySize = cMinimumEntropyBits, string passphrase = cEmptyString, Language language = Language.English)
        {
            //check that ENT size is a multiple of 32 and at least minimun entropy size to stop silly people using tiny entropy, oh also making sure entropy size doesn't exceed our checksum bits available
            if (entropySize % cEntropyMultiple != 0 || entropySize < cMinimumEntropyBits || entropySize > cMaximumEntropyBits)
            {
                throw (new Exception("entropy size must be a multiple of " + cEntropyMultiple + " (divisible by " + cEntropyMultiple + " with no remainder) and must be greater than " + (cMinimumEntropyBits - 1) + " and less than " + (cMaximumEntropyBits + 1)));
            }

            _entropyBytes = CryptoServices.CreateRandomBytes(entropySize / cBitsInByte);             //crypto random entropy of the specified size
            Init(passphrase, language);
        }