public Signature Sign(PrivateKey priv) { var data = this.MagicHash(); var signer = new DgbECDsaSigner(); signer.Init(true, new ECPrivateKeyParameters(priv.BN, Config.ECDomain), true); var signatureData = signer.GenerateSignature(data); return(new Signature(signatureData[0], signatureData[1], data, priv.ToPublicKey())); }
public bool Verify(string addressString, string signatureString) { var data = this.MagicHash(); var signature = Signature.FromCompact(Convert.FromBase64String(signatureString)); signature.Data = data; var address = Address.FromString(addressString); var signatureAddress = Address.FromPublicKey(signature.GetPublicKey()); if (signatureAddress.ToString() != addressString) { return(false); } var signer = new DgbECDsaSigner(); signer.Init(false, new ECPublicKeyParameters(signature.GetPublicKey().Point, Config.ECDomain)); return(signer.VerifySignature(this.MagicHash(), signature.R, signature.S)); }