/// <summary> /// Validates the proof of fail. /// </summary> internal bool ValidateProofOfFail(ProofOfFail proof, PublicKey pkS, byte[] nS, byte[] c0, byte[] c1) { Validation.NotNull(proof); Validation.NotNull(pkS); Validation.NotNullOrEmptyByteArray(nS); Validation.NotNullOrEmptyByteArray(c0); Validation.NotNullOrEmptyByteArray(c1); var term1 = proof.Term1.ToByteArray(); var term2 = proof.Term2.ToByteArray(); var term3 = proof.Term3.ToByteArray(); var term4 = proof.Term4.ToByteArray(); var challenge = this.HashZ( Domains.ProofErr, pkS.Encode(), this.CurveG.GetEncoded(), c0, c1, term1, term2, term3, term4); var hs0Point = this.HashToPoint(Domains.Dhs0, nS); var term1Point = this.Curve.DecodePoint(term1); var term2Point = this.Curve.DecodePoint(term2); var term3Point = this.Curve.DecodePoint(term3); var term4Point = this.Curve.DecodePoint(term4); var blindAInt = new BigInteger(1, proof.BlindA.ToByteArray()); var blindBInt = new BigInteger(1, proof.BlindB.ToByteArray()); var c0Point = this.Curve.DecodePoint(c0); var c1Point = this.Curve.DecodePoint(c1); var t1Point = term1Point.Add(term2Point).Add(c1Point.Multiply(challenge)); var t2Point = c0Point.Multiply(blindAInt).Add(hs0Point.Multiply(blindBInt)); if (!t1Point.Equals(t2Point)) { return(false); } t1Point = term3Point.Add(term4Point); t2Point = pkS.Point.Multiply(blindAInt).Add(this.curveParams.G.Multiply(blindBInt)); if (!t1Point.Equals(t2Point)) { return(false); } return(true); }
/// <summary> /// Validates the proof of fail. /// </summary> public bool ValidateProofOfFail(ProofOfFail proof, PublicKey pkS, byte[] nS, byte[] c0, byte[] c1) { var curveG = this.curveParams.G.Multiply(BigInteger.ValueOf(1)); var challenge = this.HashZ(this.proofErr, pkS.Encode(), curveG.GetEncoded(), c0, c1, proof.Term1, proof.Term2, proof.Term3, proof.Term4); var hs0Point = this.HashToPoint(dhs0, nS); var term1Point = this.curve.DecodePoint(proof.Term1); var term2Point = this.curve.DecodePoint(proof.Term2); var term3Point = this.curve.DecodePoint(proof.Term3); var term4Point = this.curve.DecodePoint(proof.Term4); var blindAInt = new BigInteger(1, proof.BlindA); var blindBInt = new BigInteger(1, proof.BlindB); var c0Point = this.curve.DecodePoint(c0); var c1Point = this.curve.DecodePoint(c1); var t1Point = term1Point.Add(term2Point).Add(c1Point.Multiply(challenge)); var t2Point = c0Point.Multiply(blindAInt).Add(hs0Point.Multiply(blindBInt)); if (!t1Point.Equals(t2Point)) { return(false); } t1Point = term3Point.Add(term4Point); t2Point = pkS.Point.Multiply(blindAInt).Add(this.curveParams.G.Multiply(blindBInt)); if (!t1Point.Equals(t2Point)) { return(false); } return(true); }