Skip to content

Commit

Permalink
optimise secp256k1 on osx (#2546)
Browse files Browse the repository at this point in the history
* optimise `secp256k1` on osx

* Optimize

Co-authored-by: Erik Zhang <[email protected]>
  • Loading branch information
Jim8y and erikzhang authored Jul 18, 2021
1 parent c602a21 commit e7fbba3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/neo/Cryptography/Crypto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,14 @@ public static bool VerifySignature(ReadOnlySpan<byte> message, ReadOnlySpan<byte
new Org.BouncyCastle.Math.BigInteger(pubkey.X.Value.ToString()),
new Org.BouncyCastle.Math.BigInteger(pubkey.Y.Value.ToString()));
var pubKey = new Org.BouncyCastle.Crypto.Parameters.ECPublicKeyParameters("ECDSA", point, domain);
var signer = Org.BouncyCastle.Security.SignerUtilities.GetSigner("SHA-256withECDSA");

var signer = new Org.BouncyCastle.Crypto.Signers.ECDsaSigner();
signer.Init(false, pubKey);
signer.BlockUpdate(message.ToArray(), 0, message.Length);

var sig = signature.ToArray();
var r = new Org.BouncyCastle.Math.BigInteger(1, sig, 0, 32);
var s = new Org.BouncyCastle.Math.BigInteger(1, sig, 32, 32);
sig = new Org.BouncyCastle.Asn1.DerSequence(new Org.BouncyCastle.Asn1.DerInteger(r), new Org.BouncyCastle.Asn1.DerInteger(s)).GetDerEncoded();

return signer.VerifySignature(sig);
return signer.VerifySignature(message.Sha256(), r, s);
}
else
{
Expand Down

0 comments on commit e7fbba3

Please sign in to comment.