public void TestCases() { var message = "attack at dawn"; var encrypted = "0339e504d6492b082da96e11e8f039796b06cd4855c101e2492a6f10f3e056a9e712c732611c6917ab5c57a1926973bc44a1586e94a783f81d05ce72518d9b0a80e2e13c7ff7d1306583f9cc7a48def5b37fbf2d5f294f128472a6e9c78dede5f5"; // encrypted broken down: // priv.pubkey 0339e504d6492b082da96e11e8f039796b06cd4855c101e2492a6f10f3e056a9e7 // ivbuf 12c732611c6917ab5c57a1926973bc44 // encrypted a1586e94a783f81d05ce72518d9b0a80 // sig e2e13c7ff7d1306583f9cc7a48def5b37fbf2d5f294f128472a6e9c78dede5f5"; var aliceKey = KzPrivKey.FromWIF("L1Ejc5dAigm5XrM3mNptMEsNnHzS7s51YxU7J61ewGshZTKkbmzJ"); var bobKey = KzPrivKey.FromWIF("KxfxrUXSMjJQcb3JgnaaA6MqsrKQ1nBSxvhuigdKRyFiEm6BZDgG"); var alice = new KzEcies() { PrivateKey = aliceKey, PublicKey = bobKey.GetPubKey() }; var bob = new KzEcies() { PrivateKey = bobKey, PublicKey = aliceKey.GetPubKey() }; var encBuf = encrypted.HexToBytes(); var ciphertext = alice.Encrypt(message); Assert.Equal(encrypted, ciphertext.ToHex()); //var decryptedtext = bob.Decrypt(ecrypted }
public void BsvPrivateKeyTests() { var hex = "96c132224121b509b7d0a16245e957d9192609c5637c6228311287b1be21627a"; //var hex2 = "8080808080808080808080808080808080808080808080808080808080808080"; var wifLivenet = "L2Gkw3kKJ6N24QcDuH4XDqt9cTqsKTVNDGz1CRZhk9cq4auDUbJy"; var privKey = new KzPrivKey(hex); var privKey2 = KzPrivKey.FromWIF(wifLivenet); Assert.Equal(privKey, privKey2); }
public void FromPrivKey() { var privhex = "906977a061af29276e40bf377042ffbde414e496ae2260bbf1fa9d085637bfff"; var pubhex = "02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc"; var privkey = KzPrivKey.FromHex(privhex); var pubkey = privkey.GetPubKey(); Assert.Equal(privhex, privkey.ToHex()); Assert.Equal(pubhex, pubkey.ToHex()); Assert.True(privkey.VerifyPubKey(pubkey)); }
public void FromHexAndB58() { var hex = "906977a061af29276e40bf377042ffbde414e496ae2260bbf1fa9d085637bfff"; var b58 = "L24Rq5hPWMexw5mQi7tchYw6mhtr5ApiHZMN8KJXCkskEv7bTV61"; var key1 = new KzPrivKey(hex); var key2 = KzPrivKey.FromB58(b58); Assert.Equal(key1, key2); Assert.Equal(hex, key1.ToHex()); Assert.Equal(b58, key1.ToB58().ToString()); Assert.Equal(b58, key1.ToString()); Assert.Equal(hex, key2.ToHex()); Assert.Equal(b58, key2.ToB58().ToString()); Assert.Equal(b58, key2.ToString()); }
public async Task GetOutputScript() { // Paymail server configuration for [email protected]: // [email protected] // Generate public addresses beneath this derivation path: M/0 // Master public key for derivations (M): xpub661MyMwAqRbcEaJYm4GjL9XnYrwbTR7Rug3oZ66juJHMXYwCYD4Z3RVgyoPhhpU97Ls9fACV3Y7kYqMPxGAA8XWFdPpaXAj3qb8VHnRMU8c // Public key returned by GetPubKey("*****@*****.**"): M/0/{int.MaxValue} // Private key for that public key: m/0/{int.MaxValue} // var key = KzElectrumSv.GetMasterPrivKey("<replace with actual wallet seed>").Derive($"0/{int.MaxValue}").PrivKey; var key = KzPrivKey.FromB58("KxXvocKqZtdHvZP5HHNShrwDQVz2muNPisrzoyeyhXc4tZhBj1nM"); var r = new KzPaymailClient(); var s = await r.GetOutputScript(key, "*****@*****.**", "*****@*****.**"); Assert.True(s.Length > 0); }
public void SignatureTest2() { var paymail = "*****@*****.**"; var amount = "500"; var when = "2019-03-01T05:00:00.000Z"; var purpose = "some reason"; var message = $"{paymail}{amount}{when}{purpose}"; var privkey = KzPrivKey.FromB58("KxWjJiTRSA7oExnvbWRaCizYB42XMKPxyD6ryzANbdXCJw1fo4sR"); var signature = privkey.SignMessageToB64(message); Assert.Equal("H1CV5DE7tya0jM2ZynueSTRgkv4CpNY9/pz5lK5ENdGOWXCt/MTReMcQ54LCRt4ogf/g53HokXDpuSfc1D5gBUE=", signature); var pub = privkey.GetPubKey(); var ok = pub.VerifyMessage(message, signature); Assert.True(ok); }