/// <summary> /// Creates a range proof that compares a UProve attribute to a target date. /// Target attribute MUST NOT be hashed. /// Value MUST be generated via RangeProofParameterFactory.EncodeYearAndDayAsUProveAttribute. /// </summary> /// <param name="prover">Token information.</param> /// <param name="attributeIndexForProver">1-based index of target attribute.</param> /// <param name="proofType">Range proof type</param> /// <param name="targetDate">Compare token attribute to this date. (Time component is ignored).</param> /// <param name="minYear">Minimum year for attribute and target date.</param> /// <param name="maxYear">Maximum year for attribute and target date.</param> public RangeProof( ProverPresentationProtocolParameters prover1, int attributeIndexForProver1, VerifierRangeProofParameters.ProofType proofType, ProverPresentationProtocolParameters prover2, int attributeIndexForProver2, int minValue, int maxValue) { // make sure target attribute is not hashed if ((prover1.IP.E[attributeIndexForProver1 - 1] == 0x01) || ((prover2.IP.E[attributeIndexForProver2 - 1]) == 0x01)) { throw new ArgumentException("UProve attributes used in Range Proof must not be hashed."); } // generate Pedersen Commitments to token attributes ProverPresentationProtocolParameters[] provers = new ProverPresentationProtocolParameters[] { prover1, prover2 }; int[] attributeIndices = new int[] { attributeIndexForProver1, attributeIndexForProver2 }; PedersenCommitment[] attributeCommitments = PedersenCommitment.PedersenCommmitmentsToAttributes(provers, attributeIndices); // create range proof ProverRangeProofParameters rangeProver = new ProverRangeProofParameters( new CryptoParameters(prover1.IP), attributeCommitments[0], proofType, attributeCommitments[1], minValue, maxValue); ConstructorHelper(rangeProver); // Add UProve Integration proof this.UPIProof = new UProveIntegrationProof(provers, attributeIndices, attributeCommitments); this.UPIProof.IsGroupSerializable = false; }
/// <summary> /// Constructor. Creates a proof that a token attribute is in a given set. /// </summary> /// <param name="prover">Token description.</param> /// <param name="attributeIndexForProver">1-based attribute index in token.</param> /// <param name="setValues">Set of attributes to compare to token attribute.</param> /// <param name="smRandom">Random data for set membership proof.</param> /// <returns>Inequality proof.</returns> public SetMembershipProof(ProverPresentationProtocolParameters prover, int attributeIndexForProver, byte[][] setValues, SetMembershipProofGenerationRandomData smRandom = null) { // generate Pedersen Commitments to token attribute ProverPresentationProtocolParameters[] provers = new ProverPresentationProtocolParameters[] { prover }; int[] attributeIndices = new int[] { attributeIndexForProver }; PedersenCommitment[] attributeCommitments = PedersenCommitment.PedersenCommmitmentsToAttributes(provers, attributeIndices); // create set membership proof using Pedersen Commitment FieldZqElement[] memberSet = VerifierSetMembershipParameters.GenerateMemberSet(prover.IP, attributeIndexForProver, setValues); ProverSetMembershipParameters setProver = new ProverSetMembershipParameters(attributeCommitments[0], memberSet, new CryptoParameters(prover.IP)); ConstructorHelper(setProver, smRandom); // add UProve Integration proof this.UPIProof = new UProveIntegrationProof(provers, attributeIndices, attributeCommitments); this.UPIProof.IsGroupSerializable = false; }
/// <summary> /// Constructor. Creates an inequality proof that a token attribute is not equal to some value. /// </summary> /// <param name="prover">Token description.</param> /// <param name="attributeIndexForProver">1-based attribute index in token.</param> /// <param name="attributeValue">Attribute value to compare actual token attribute.</param> /// <returns>Inequality proof.</returns> public InequalityProof(ProverPresentationProtocolParameters prover, int attributeIndexForProver, byte[] attributeValue) { // generate Pedersen Commitments to attributes ProverPresentationProtocolParameters[] provers = new ProverPresentationProtocolParameters[] { prover }; int[] attributeIndices = new int[] { attributeIndexForProver }; PedersenCommitment[] attributeCommitments = PedersenCommitment.PedersenCommmitmentsToAttributes(provers, attributeIndices); // create inequality proof using Pedersen Commitmetns FieldZqElement committedAttribute = ProtocolHelper.ComputeXi(prover.IP, attributeIndexForProver - 1, attributeValue); ProverInequalityProofParameters ieqProver = new ProverInequalityProofParameters(attributeCommitments[0], committedAttribute, new CryptoParameters(prover.IP)); ConstructorHelper(ieqProver); // add UProve Integration proof this.UPIProof = new UProveIntegrationProof(provers, attributeIndices, attributeCommitments); this.UPIProof.IsGroupSerializable = false; }
/// <summary> /// Constructor. Creates an inequality proof that an attribute in one token is not equal to an attribute in another token. /// </summary> /// <param name="prover1">Token.</param> /// <param name="attributeIndexForProver1">Target attribute in first token, uses 1-based index.</param> /// <param name="prover2">Token</param> /// <param name="attributeIndexForProver2">Target attribute in second token, uses 1-based index</param> /// <returns>Proof of inequality.</returns> public InequalityProof( ProverPresentationProtocolParameters prover1, int attributeIndexForProver1, ProverPresentationProtocolParameters prover2, int attributeIndexForProver2) { // generate Pedersen Commitments to attributes ProverPresentationProtocolParameters[] provers = new ProverPresentationProtocolParameters[] { prover1, prover2 }; int [] attributeIndices = new int[] { attributeIndexForProver1, attributeIndexForProver2 }; PedersenCommitment[] attributeCommitments = PedersenCommitment.PedersenCommmitmentsToAttributes(provers, attributeIndices); // create inequality proof using Pedersen Commitmetns ProverInequalityProofParameters ieqProver = new ProverInequalityProofParameters(attributeCommitments[0], attributeCommitments[1], new CryptoParameters(prover1.IP)); ConstructorHelper(ieqProver); // add UProve Integration proof this.UPIProof = new UProveIntegrationProof(provers, attributeIndices, attributeCommitments); this.UPIProof.IsGroupSerializable = false; }