/// <summary> /// Generates a list of Pedersen Commitments /// </summary> /// <param name="prover">Array of tokens</param> /// <param name="attributeIndices">target attribute for each token</param> /// <param name="commitmentsToAttribute">Pedersen commitment to target attribute in token. Generated via method /// Proof.PedersenCommmitmentsToAttributes</param> public UProveIntegrationProof(ProverPresentationProtocolParameters [] prover, int [] attributeIndices, PedersenCommitment [] commitmentsToAttribute) { if ((prover == null) || (prover.Length == 0)) { throw new ArgumentException("First argument should be an array of at least one element."); } if (!UProveIntegrationProof.AreTokensCompatible(prover)) { throw new ArgumentException("All tokens must use same group."); } if ((attributeIndices == null) || (attributeIndices.Length != prover.Length)) { throw new ArgumentNullException("Second argument must be an array of the same length as first argument."); } if ((commitmentsToAttribute == null) || (commitmentsToAttribute.Length != prover.Length)) { throw new ArgumentNullException("Third argument must be an array of the same length as first argument."); } // copy Pedersen Commitment values this.PedersenCommitmentValues = new GroupElement[prover.Length]; for (int i = 0; i < PedersenCommitmentValues.Length; ++i) { this.PedersenCommitmentValues[i] = commitmentsToAttribute[i].Value; } // Create Equality Proof between Pedersen Commitments and tokens. EqualityMap map = new EqualityMap(); IWitness [] witnesses = new IWitness[prover.Length * 2]; OpenUProveToken[] tokens = new OpenUProveToken[prover.Length]; for (int i = 0; i < tokens.Length; ++i) { // create uprove token and add target attribute to map witnesses[2 * i] = new OpenUProveToken(prover[i]); map.Add(new PrettyName("token", 2 * i), new DoubleIndex(i, attributeIndices[i])); // add pedersen commitment to witness list, and add to map witnesses[2 * i + 1] = commitmentsToAttribute[i]; map.Add(new PrettyName("token", 2 * i + 1), new DoubleIndex(i, 0)); } ProverEqualityParameters eqProver = new ProverEqualityParameters(witnesses, map, new CryptoParameters(prover[0].IP)); this.TokenCommitmentEqualityProof = new EqualityProof(eqProver); this.TokenCommitmentEqualityProof.IsGroupSerializable = false; }
/// <summary> /// Constructor. Creates proof that two UProve tokens have equal attributes. /// </summary> /// <param name="prover1">Description of token 1.</param> /// <param name="attributeIndexForProver1">1-based index for target attribute in token 1.</param> /// <param name="prover2">Description of token 2.</param> /// <param name="attributeIndexForProver2">1-based index for target attribute in token 2.</param> public EqualityProof(ProverPresentationProtocolParameters prover1, int attributeIndexForProver1, ProverPresentationProtocolParameters prover2, int attributeIndexForProver2) { if (!prover1.IP.Gq.Equals(prover2.IP.Gq)) { throw new ArgumentException("both provers must share the same group"); } // Create OpenUProveTokens OpenUProveToken token1 = new OpenUProveToken(prover1); OpenUProveToken token2 = new OpenUProveToken(prover2); // Create proof ProverEqualityParameters eqProver = new ProverEqualityParameters( token1, attributeIndexForProver1, token2, attributeIndexForProver2, new CryptoParameters(prover1.IP)); ConstructorHelper(eqProver); }