@@ -95,14 +95,31 @@ public void ECDsaSecP256k1()
95
95
96
96
var msgBytes = Encoding . ASCII . GetBytes ( "Phantasma" ) ;
97
97
98
+ // CryptoExtensions.SignECDsa()/.VerifySignatureECDsa() tests.
98
99
var signature = CryptoExtensions . SignECDsa ( msgBytes , privateKey , publicKey , ECDsaCurve . Secp256k1 ) ;
99
100
Assert . IsNotNull ( signature ) ;
100
101
102
+ Console . WriteLine ( "CryptoExtensions.SignECDsa() signature: " + Base16 . Encode ( signature ) ) ;
103
+
101
104
var signatureUncompressed = CryptoExtensions . SignECDsa ( msgBytes , privateKey , uncompressedPublicKey , ECDsaCurve . Secp256k1 ) ;
102
105
Assert . IsNotNull ( signatureUncompressed ) ;
103
106
104
107
Assert . IsTrue ( CryptoExtensions . VerifySignatureECDsa ( msgBytes , signature , publicKey , ECDsaCurve . Secp256k1 ) ) ;
105
108
Assert . IsTrue ( CryptoExtensions . VerifySignatureECDsa ( msgBytes , signature , uncompressedPublicKey , ECDsaCurve . Secp256k1 ) ) ;
109
+
110
+ // ECDsaSignature.Generate()/ECDsaSignature.Verify() tests.
111
+
112
+ var ethKeys = Ethereum . EthereumKey . FromPrivateKey ( key ) ;
113
+
114
+ // Verifying previous signature, received from CryptoExtensions.SignECDsa().
115
+ var ecdsaSignature = new ECDsaSignature ( signature , ECDsaCurve . Secp256k1 ) ;
116
+ Console . WriteLine ( "ECDsaSignature() signature: " + Base16 . Encode ( ecdsaSignature . ToByteArray ( ) ) ) ;
117
+ Assert . IsTrue ( ecdsaSignature . Verify ( msgBytes , Phantasma . Cryptography . Address . FromKey ( ethKeys ) ) ) ;
118
+
119
+ // Generating new signature with ECDsaSignature.Generate() and verifying it.
120
+ var ecdsaSignature2 = ECDsaSignature . Generate ( ethKeys , msgBytes , ECDsaCurve . Secp256k1 ) ;
121
+ Console . WriteLine ( "ECDsaSignature() signature2: " + Base16 . Encode ( ecdsaSignature2 . ToByteArray ( ) ) ) ;
122
+ Assert . IsTrue ( ecdsaSignature . Verify ( msgBytes , Phantasma . Cryptography . Address . FromKey ( ethKeys ) ) ) ;
106
123
}
107
124
108
125
[ TestMethod ]
0 commit comments