public void TestBitcoinAddressVerify() { var p = new cipher_PubKey(); var s = new cipher_SecKey(); var a = new cipher__BitcoinAddress(); SKY_cipher_GenerateKeyPair(p, s); SKY_cipher_BitcoinAddressFromPubKey(p, a); // Valid pubkey+address var err = SKY_cipher_BitcoinAddress_Verify(a, p); Assert.AreEqual(err, SKY_OK); // Invalid pubkey err = SKY_cipher_BitcoinAddress_Verify(a, new cipher_PubKey()); Assert.AreEqual(err, SKY_ErrAddressInvalidPubKey); var p2 = new cipher_PubKey(); var s2 = new cipher_SecKey(); SKY_cipher_GenerateKeyPair(p2, s2); err = SKY_cipher_BitcoinAddress_Verify(a, p2); Assert.AreEqual(err, SKY_ErrAddressInvalidPubKey); // Bad Version a.Version = 0x01; err = SKY_cipher_BitcoinAddress_Verify(a, p2); Assert.AreEqual(err, SKY_ErrAddressInvalidVersion); }
public void TestBitcoinAddressNull() { var a = new cipher__BitcoinAddress(); Assert.IsTrue(Convert.ToBoolean(SKY_cipher_BitcoinAddress_Null(a))); var p = new cipher_PubKey(); var s = new cipher_SecKey(); var err = SKY_cipher_GenerateKeyPair(p, s); SKY_cipher_BitcoinAddressFromPubKey(p, a); Assert.IsFalse(Convert.ToBoolean(SKY_cipher_BitcoinAddress_Null(a))); }
public void TestBitcoinAddressFromSecKey() { var p = new cipher_PubKey(); var s = new cipher_SecKey(); var a = new cipher__BitcoinAddress(); var a2 = new cipher__BitcoinAddress(); SKY_cipher_GenerateKeyPair(p, s); var err = SKY_cipher_BitcoinAddressFromSecKey(s, a); Assert.AreEqual(err, SKY_OK); // Valid pubkey+address err = SKY_cipher_BitcoinAddress_Verify(a, p); Assert.AreEqual(err, SKY_OK); err = SKY_cipher_BitcoinAddressFromSecKey(new cipher_SecKey(), a2); Assert.AreEqual(err, SKY_ErrPubKeyFromNullSecKey); }