/// <summary> /// Generates proofs that a token attribute value is not equal to any values in the target array. /// </summary> /// <param name="prover">Inequality proof parameters for the token.</param> /// <param name="target">Target values array.</param> /// <returns>An inequality proof.</returns> public static InequalityProof[] GenerateUProveInequalityProofs(EQProofUProveProverData prover, byte[][] target) { // Create PedersenCommitments int commitmentIndex = ClosedPedersenCommitment.GetCommitmentIndex(prover.PPPP.Committed, prover.index); PedersenCommitment ped = new PedersenCommitment(prover.PPPP, prover.PP, prover.CPV, commitmentIndex); // Create EqualityProof CryptoParameters crypto = new CryptoParameters(prover.PPPP.IP); InequalityProof[] proofs = new InequalityProof[target.Length]; for (int i = 0; i < target.Length; i++) { FieldZqElement targetValue = ProtocolHelper.ComputeXi(prover.PPPP.IP, prover.index - 1, target[i]); proofs[i] = new InequalityProof(new ProverInequalityProofParameters(ped, targetValue, crypto)); } return(proofs); }
/// <summary> /// Verifies a proof that a token attribute value is not equal to a target value. /// </summary> /// <param name="verifier">Equality proof parameters for the token.</param> /// <param name="target">Target value.</param> /// <param name="eQProof">The inequality proof to verify.</param> /// <exception cref="InvalidUProveArtifactException">Thrown if the proof is invalid.</exception> public static void VerifyUProveEqualityProof(EQProofUProveVerifierData verifier, byte[] target, InequalityProof iNeqProof) { VerifyUProveEqualityProofs(verifier, new byte[][] { target }, new InequalityProof[] { iNeqProof }); }
/// <summary> /// Verifies a proof that two tokens share an attribute value, without revealing it. /// </summary> /// <param name="verifier1">Equality proof parameters for the first token.</param> /// <param name="verifier2">Equality proof parameters for the second token.</param> /// <param name="eQProof">The equality proof to verify.</param> /// <exception cref="InvalidUProveArtifactException">Thrown if the proof is invalid.</exception> public static void VerifyUProveEqualityProof(EQProofUProveVerifierData verifier1, EQProofUProveVerifierData verifier2, InequalityProof iNeqProof) { int commitmentIndex1 = ClosedPedersenCommitment.GetCommitmentIndex(verifier1.VPPP.Committed, verifier1.index); int commitmentIndex2 = ClosedPedersenCommitment.GetCommitmentIndex(verifier2.VPPP.Committed, verifier2.index); ClosedPedersenCommitment closedPed1 = new ClosedPedersenCommitment(verifier1.VPPP.IP, verifier1.PP, commitmentIndex1); ClosedPedersenCommitment closedPed2 = new ClosedPedersenCommitment(verifier2.VPPP.IP, verifier2.PP, commitmentIndex2); CryptoParameters crypto = new CryptoParameters(verifier1.VPPP.IP); // Can use prover2.IP VerifierInequalityProofParameters inequalityVerifier = new VerifierInequalityProofParameters(closedPed1.Value, closedPed2.Value, crypto); if (!iNeqProof.Verify(inequalityVerifier)) { throw new InvalidUProveArtifactException("invalid equality proof"); } }