/// <summary> /// Validates the proof of success. /// </summary> internal bool ValidateProofOfSuccess(ProofOfSuccess 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 trm1Point = this.Curve.DecodePoint(term1); var trm2Point = this.Curve.DecodePoint(term2); var trm3Point = this.Curve.DecodePoint(term3); var blindXInt = new BigInteger(1, proof.BlindX.ToByteArray()); var c0Point = this.Curve.DecodePoint(c0); var c1Point = this.Curve.DecodePoint(c1); var hs0Point = this.HashToPoint(Domains.Dhs0, nS); var hs1Point = this.HashToPoint(Domains.Dhs1, nS); var challenge = this.HashZ( Domains.ProofOK, pkS.Encode(), this.CurveG.GetEncoded(), c0, c1, term1, term2, term3); var t1Point = trm1Point.Add(c0Point.Multiply(challenge)); var t2Point = hs0Point.Multiply(blindXInt); if (!t1Point.Equals(t2Point)) { return(false); } t1Point = trm2Point.Add(c1Point.Multiply(challenge)); t2Point = hs1Point.Multiply(blindXInt); if (!t1Point.Equals(t2Point)) { return(false); } t1Point = trm3Point.Add(pkS.Point.Multiply(challenge)); t2Point = this.curveParams.G.Multiply(blindXInt); if (!t1Point.Equals(t2Point)) { return(false); } return(true); }
/// <summary> /// Validates the proof of success. /// </summary> public bool ValidateProofOfSuccess(ProofOfSuccess proof, PublicKey pkS, byte[] nS, byte[] c0, byte[] c1) { var trm1Point = this.curve.DecodePoint(proof.Term1); var trm2Point = this.curve.DecodePoint(proof.Term2); var trm3Point = this.curve.DecodePoint(proof.Term3); var blindXInt = new BigInteger(1, proof.BlindX); var c0Point = this.curve.DecodePoint(c0); var c1Point = this.curve.DecodePoint(c1); var hs0Point = this.HashToPoint(dhs0, nS); var hs1Point = this.HashToPoint(dhs1, nS); var curveG = this.curveParams.G.Multiply(BigInteger.ValueOf(1)); var challenge = this.HashZ(proofOK, pkS.Encode(), curveG.GetEncoded(), c0, c1, proof.Term1, proof.Term2, proof.Term3); var t1Point = trm1Point.Add(c0Point.Multiply(challenge)); var t2Point = hs0Point.Multiply(blindXInt); if (!t1Point.Equals(t2Point)) { return(false); } t1Point = trm2Point.Add(c1Point.Multiply(challenge)); t2Point = hs1Point.Multiply(blindXInt); if (!t1Point.Equals(t2Point)) { return(false); } t1Point = trm3Point.Add(pkS.Point.Multiply(challenge)); t2Point = this.curveParams.G.Multiply(blindXInt); if (!t1Point.Equals(t2Point)) { return(false); } return(true); }