示例#1
0
        public void ShouldGenerateKeys(string privateKey, string address)
        {
            var kp         = new AvmKeyPair(alias, privateKey);
            var addressStr = kp.GetAddressString();

            Assert.AreEqual(address, addressStr);
        }
示例#2
0
        public void ShouldGenerateKeysWithMnemonicAndPassword()
        {
            var mnemonic   = new Mnemonic("clever glove portion swing nerve bullet boil rose motion nose rocket tube color account enhance");
            var kp         = new AvmKeyPair(alias, mnemonic, "P@aaw0rd");
            var addressStr = kp.GetAddressString();

            Assert.AreEqual("020ea542208ffa2bef2213bb1b3460e95d0134056bb211317c323a1d102cf856b5", kp.Pubk.BytesToHex());
            Assert.AreEqual("X-avax1908hms500kcnht8msg3rr0qn0qt9qmc78m7se0", addressStr);
        }
示例#3
0
        public void ShouldGenerateKeysWithMnemonic()
        {
            var mnemonic   = new Mnemonic("clever glove portion swing nerve bullet boil rose motion nose rocket tube color account enhance");
            var kp         = new AvmKeyPair(alias, mnemonic);
            var addressStr = kp.GetAddressString();

            Assert.AreEqual("0343087424849a4d3ca79a0eb89e14e00ff8a8c042e4f5f891f3d57c88737bac67", kp.Pubk.BytesToHex());
            Assert.AreEqual("X-avax1pzw2dc55hckyn68dwfmtcqdpvltc3s87q4gve8", addressStr);
        }
示例#4
0
        public void ShouldSign(string privateKey, string signature)
        {
            var kp = new AvmKeyPair(alias, privateKey);

            var hashed = NBitcoin.Crypto.Hashes.SHA256("09090909".HexToBytes());
            var signed = kp.Sign(hashed);

            Assert.AreEqual(65, signed.Length);
            Assert.AreEqual(signature.HexToBytes(), signed);
            Assert.IsTrue(kp.Verify(hashed, signed));
        }