Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Generates a proof that two attribute values are different, without revealing them.
        /// </summary>
        /// <param name="prover1">Equality proof parameters for the first token.</param>
        /// <param name="prover2">Equality proof parameters for the second token.</param>
        /// <returns>An inequality proof.</returns>
        public static InequalityProof GenerateUProveInequalityProof(EQProofUProveProverData prover1, EQProofUProveProverData prover2)
        {
            if (!prover1.PPPP.IP.Gq.Equals(prover2.PPPP.IP.Gq))
            {
                throw new ArgumentException("both provers must share the same group");
            }
            // Create PedersenCommitments
            int commitmentIndex1    = ClosedPedersenCommitment.GetCommitmentIndex(prover1.PPPP.Committed, prover1.index);
            PedersenCommitment ped1 = new PedersenCommitment(prover1.PPPP, prover1.PP, prover1.CPV, commitmentIndex1);
            int commitmentIndex2    = ClosedPedersenCommitment.GetCommitmentIndex(prover2.PPPP.Committed, prover2.index);
            PedersenCommitment ped2 = new PedersenCommitment(prover2.PPPP, prover2.PP, prover2.CPV, commitmentIndex2);

            // Create EqualityProof
            CryptoParameters crypto = new CryptoParameters(prover1.PPPP.IP);                                            // Can use prover2.IP
            ProverInequalityProofParameters inequalityProver = new ProverInequalityProofParameters(ped1, ped2, crypto); // compares committed values in ped1 and ped2

            return(new InequalityProof(inequalityProver));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Generates a proof that a token attribute value is not equal to a target value.
 /// </summary>
 /// <param name="prover">Inequality proof parameters for the token.</param>
 /// <param name="target">Target value.</param>
 /// <returns>An inequality proof.</returns>
 public static InequalityProof GenerateUProveInequalityProof(EQProofUProveProverData prover, byte[] target)
 {
     return(GenerateUProveInequalityProofs(prover, new byte[][] { target })[0]);
 }