-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,13 +59,14 @@ public static byte[] Sign(byte[] message, byte[] prikey, byte[] pubkey) | |
/// <returns><see langword="true"/> if the signature is valid; otherwise, <see langword="false"/>.</returns> | ||
public static bool VerifySignature(ReadOnlySpan<byte> message, ReadOnlySpan<byte> signature, ECC.ECPoint pubkey) | ||
{ | ||
byte[] buffer = pubkey.EncodePoint(false); | ||
#if OSX | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
shargon
Author
Member
|
||
try | ||
{ | ||
var curve = Org.BouncyCastle.Asn1.Sec.SecNamedCurves.GetByName(pubkey.Curve == ECC.ECCurve.Secp256r1 ? "secp256r1" : "secp256k1"); | ||
var domain = new Org.BouncyCastle.Crypto.Parameters.ECDomainParameters(curve.Curve, curve.G, curve.N, curve.H); | ||
var point = curve.Curve.DecodePoint(buffer); | ||
var point = curve.Curve.CreatePoint( | ||
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"); | ||
|
||
|
@@ -75,6 +76,7 @@ public static bool VerifySignature(ReadOnlySpan<byte> message, ReadOnlySpan<byte | |
} | ||
catch { return false; } | ||
#else | ||
byte[] buffer = pubkey.EncodePoint(false); | ||
ECCurve curve = | ||
pubkey.Curve == ECC.ECCurve.Secp256r1 ? ECCurve.NamedCurves.nistP256 : | ||
pubkey.Curve == ECC.ECCurve.Secp256k1 ? ECCurve.CreateFromFriendlyName("secP256k1") : | ||
|
#if OSX
this precompile command does not work on my Macbook Pro 2019. This code works:
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)){} else {}