Beispiel #1
0
        public void SyntheticNoncesTest()
        {
            var protocol = Encoding.UTF8.GetBytes("test TranscriptRng collisions");
            var rnd      = new SecureRandom();

            var commitment1 = new[] { Generators.Gx0 };
            var commitment2 = new[] { Generators.Gx1 };
            var witness1    = new[] { rnd.GetScalar() };
            var witness2    = new[] { rnd.GetScalar() };

            var transcript1 = new Transcript(protocol);
            var transcript2 = new Transcript(protocol);
            var transcript3 = new Transcript(protocol);
            var transcript4 = new Transcript(protocol);

            transcript1.CommitPublicNonces(commitment1);
            transcript2.CommitPublicNonces(commitment2);
            transcript3.CommitPublicNonces(commitment2);
            transcript4.CommitPublicNonces(commitment2);

            var publicNonceGenerator1 = transcript1.CreateSyntheticPublicNoncesProvider(witness1, rnd);
            var publicNonceGenerator2 = transcript2.CreateSyntheticPublicNoncesProvider(witness1, rnd);
            var publicNonceGenerator3 = transcript3.CreateSyntheticPublicNoncesProvider(witness2, rnd);
            var publicNonceGenerator4 = transcript4.CreateSyntheticPublicNoncesProvider(witness2, rnd);

            var publicNonce1 = publicNonceGenerator1().First();
            var publicNonce2 = publicNonceGenerator2().First();
            var publicNonce3 = publicNonceGenerator3().First();
            var publicNonce4 = publicNonceGenerator4().First();

            Assert.NotEqual(publicNonce1, publicNonce2);
            Assert.NotEqual(publicNonce1, publicNonce3);
            Assert.NotEqual(publicNonce1, publicNonce4);

            Assert.NotEqual(publicNonce2, publicNonce3);
            Assert.NotEqual(publicNonce2, publicNonce4);

            Assert.NotEqual(publicNonce3, publicNonce4);
        }