public void ShouldGenerateFromMnemonic() { CardanoHDWallet hdWallet = new CardanoHDWallet(mnemonic, string.Empty); Assert.AreEqual(ReferenceSeed, hdWallet.BIP39Seed); CardanoWallet wallet = hdWallet.GetCoinTypeWallet(); Assert.AreEqual(ReferencePrivateKey, wallet.PrivateKey.ToHexString()); Assert.AreEqual(ReferencePubKey, $"00{wallet.PublicKey.ToHexString()}"); }
public void ShouldGenerateInternalFromMnemonic(int accountIndex, int walletIndex, string expectedPrivateKey, string expectedPublicKey) { IHDWallet <CardanoWallet> hdWallet = new CardanoHDWallet(mnemonic, string.Empty); CardanoWallet wallet = hdWallet.GetAccount((uint)accountIndex).GetInternalWallet((uint)walletIndex); string pubKey = $"00{wallet.PublicKey.ToHexString()}"; string privKey = wallet.PrivateKey.ToHexString(); Assert.AreEqual(expectedPrivateKey, privKey); Assert.AreEqual(expectedPublicKey, pubKey); }
public void ShouldCreateAccount() { IHDWallet <CardanoWallet> hdWallet = new CardanoHDWallet("conduct stadium ask orange vast impose depend assume income sail chunk tomorrow life grape dutch", ""); var account0 = hdWallet.GetAccount(0); var depositWallet0 = account0.GetExternalWallet(0); Assert.AreEqual("547ad18a1e3e3e3d4ff10b23e47e6795e180a18b213a1c894909cb5bf6d47f6c", depositWallet0.PublicKey.ToHexString()); var depositWallet1 = account0.GetExternalWallet(1); Assert.AreEqual("d081709b367a8cb21d6ebb3b7ee40a4069f15d38e3a6db595ae0df8c7e86c9ed", depositWallet1.PublicKey.ToHexString()); var account1 = hdWallet.GetAccount(1); var depositWallet10 = account1.GetExternalWallet(0); Assert.AreEqual("575f47e7ebbab331c83b5ce69ee8baa469d0eb18404627dc7659ab44400a1810", depositWallet10.PublicKey.ToHexString()); }
public void ShouldGenerateMasterPrivateKeys() { string words = "push wrong tribe amazing again cousin hill belt silent found sketch monitor"; IHDWallet <CardanoWallet> wallet = new CardanoHDWallet(words); var account = wallet.GetMasterWallet(); var privateKeyBytes = account.PrivateKey; var privateKeyHex = account.PrivateKey.ToHexString(); var message = Encoding.UTF8.GetBytes("159817a085f113d099d3d93c051410e9bfe043cc5c20e43aa9a083bf73660145"); var messageHash = new Sha3Keccack().CalculateHash(message); var signature = account.Sign(messageHash); var signatureBytes = Helper.Concat(signature.R, signature.S); var validationResult = Signer.Validate(signatureBytes, messageHash, account.PublicKey); Assert.That(validationResult, Is.True); }