Exemple #1
0
        public void SMBadParametersTest()
        {
            // committed value not in memberset
            ProverSetMembershipParameters prover = new ProverSetMembershipParameters(_cryptoParameters);

            prover.setProverParameters(_cryptoParameters.FieldZq.One, ValidDaysOfTheWeek);
            Assert.IsFalse(prover.Verify(), "Verify should fail since committed value not in memberset.");

            // open commitment uses wrong base
            PedersenCommitment ped = new PedersenCommitment(_cryptoParameters.H, _cryptoParameters.G, ValidDaysOfTheWeek[0], ValidDaysOfTheWeek[2], _cryptoParameters.Group);

            prover.setProverParameters(ped, ValidDaysOfTheWeek);
            Assert.IsFalse(prover.Verify(), "Verify should fail since commitment uses wrong bases.");

            // null memberset
            prover.setProverParameters(ValidDaysOfTheWeek[0], null);
            Assert.IsFalse(prover.Verify(), "Verify should fail since memberset is null.");
        }
Exemple #2
0
        public void SMGetVerifierParametersTest()
        {
            ProverSetMembershipParameters prover = new ProverSetMembershipParameters(_cryptoParameters);

            prover.setProverParameters(ValidDaysOfTheWeek[1], ValidDaysOfTheWeek);
            Assert.IsTrue(prover.Verify(), "prover parameters should be valid.");

            VerifierSetMembershipParameters verifier = prover.GetVerifierParameters();

            AssertCorrectVerifierParameters(verifier, _cryptoParameters, prover.ClosedCommitment, ValidDaysOfTheWeek);
            Assert.IsNull(verifier.Witnesses, "witnesses should be null.");
        }
Exemple #3
0
        public void SMEndToEndTest()
        {
            // generate prover and verifier parameters
            ProverSetMembershipParameters proverParams = GeneratePSMParameters(0, 10);

            Assert.IsTrue(proverParams.Verify());
            VerifierSetMembershipParameters verifierParams = new VerifierSetMembershipParameters(proverParams.ClosedCommitment, proverParams.MemberSet, proverParams);

            Assert.IsTrue(verifierParams.Verify());

            //  create the proof and verify it.
            SetMembershipProof proof = new SetMembershipProof(proverParams);

            Assert.IsTrue(proof.Verify(verifierParams));
            Assert.IsTrue(proof.Verify(proverParams));
        }