示例#1
0
        public void InequalityParamUnknownValueTest()
        {
            CryptoParameters crypto = StaticHelperClass.ParameterArray[1];
            FieldZqElement   x      = crypto.FieldZq.GetRandomElement(false);
            FieldZqElement   y      = x + crypto.FieldZq.One;

            // inequality does not hold
            PedersenCommitment X    = new PedersenCommitment(x, crypto);
            PedersenCommitment Y    = new PedersenCommitment(y, crypto);
            PedersenCommitment badY = new PedersenCommitment(x, crypto);
            ProverInequalityProofParameters badProver = new ProverInequalityProofParameters(X, badY, crypto);

            Assert.IsFalse(badProver.Verify(), "x=y");

            // X uses wrong bases
            PedersenCommitment badX = new PedersenCommitment(crypto.H, crypto.G, x, x, crypto.Group);

            badProver = new ProverInequalityProofParameters(badX, Y, crypto);
            Assert.IsFalse(badProver.Verify(), "bad bases in X");

            // Y uses wrong bases
            badProver = new ProverInequalityProofParameters(Y, badX, crypto);
            Assert.IsFalse(badProver.Verify(), "bad bases in Y");

            //good parameters ok
            ProverInequalityProofParameters prover = new ProverInequalityProofParameters(X, Y, crypto);

            Assert.IsTrue(prover.Verify(), "prover verify");
            VerifierInequalityProofParameters verifier = new VerifierInequalityProofParameters(X.Value, Y.Value, crypto);

            Assert.IsTrue(verifier.Verify(), "verifier ok.");
        }
示例#2
0
        public void InequalityE2ETest1()
        {
            CryptoParameters   crypto = StaticHelperClass.ParameterArray[0];
            PedersenCommitment X      = new PedersenCommitment(crypto.FieldZq.GetElement(20), crypto);

            ProverInequalityProofParameters prover = new ProverInequalityProofParameters(X, crypto.FieldZq.GetElement(45), crypto);

            Assert.IsTrue(prover.Verify(), "prover verify");

            InequalityProof proof = new InequalityProof(prover);

            Assert.IsTrue(proof.Verify(prover), "proof verify(prover)");

            VerifierInequalityProofParameters verifier = new VerifierInequalityProofParameters(X.Value, crypto.FieldZq.GetElement(45), crypto);

            Assert.IsTrue(verifier.Verify(), "verifyer.verify()");
            Assert.IsTrue(proof.Verify(verifier), "proof.verify(verifier)");
        }