예제 #1
0
        /// <summary>
        /// Rebuild the account from private key
        /// </summary>
        /// <param name="privateKey">Private Key</param>
        /// <returns>the rebuilded account</returns>
        public static Account AccountFromPrivateKey(byte[] privateKey)
        {
            if (privateKey.Length != SK_SIZE)
            {
                throw new ArgumentException("Incorrect private key length");
            }

            var privateKeyRebuild = new Ed25519PrivateKeyParameters(privateKey, 0);
            var publicKeyRebuild  = privateKeyRebuild.GeneratePublicKey();
            var act = new Account
            {
                privateKeyPair = new AsymmetricCipherKeyPair(publicKeyRebuild, privateKeyRebuild),
            };

            act.Address = new Address(act.GetClearTextPublicKey());
            return(act);
        }