Delete ProverTests, StatementTests, VerifierTests
DELETE
WalletWasabi.Tests/UnitTests/Crypto/ZeroKnowledge/ProverTests.cs
-using NBitcoin.Secp256k1;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using WalletWasabi.Crypto.Groups;
-using WalletWasabi.Crypto.Randomness;
-using WalletWasabi.Crypto.ZeroKnowledge;
-using WalletWasabi.Tests.Helpers;
-using Xunit;
-
-namespace WalletWasabi.Tests.UnitTests.Crypto.ZeroKnowledge
-{
- public class ProverTests
- {
- [Fact]
- public void RandomOverflow()
- {
- var mockRandom = new MockRandom();
- foreach (var scalar in CryptoHelpers.GetScalars(x => x.IsOverflow))
- {
- mockRandom.GetScalarResults.Add(scalar);
-
- Assert.ThrowsAny<InvalidOperationException>(() => Prover.CreateProof(new KnowledgeOfDlogParams(Scalar.One, new Statement(Scalar.One * Generators.G, Generators.G)), mockRandom));
- }
- }
-
- [Fact]
- public void RandomZero()
- {
- var mockRandom = new MockRandom();
- mockRandom.GetScalarResults.Add(Scalar.Zero);
-
- // Don't tolerate if the second zero scalar random is received.
- mockRandom.GetScalarResults.Add(Scalar.Zero);
-
- Assert.ThrowsAny<InvalidOperationException>(() => Prover.CreateProof(new KnowledgeOfDlogParams(Scalar.One, new Statement(Scalar.One * Generators.G, Generators.G)), mockRandom));
- }
- }
-}

DELETE
WalletWasabi.Tests/UnitTests/Crypto/ZeroKnowledge/StatementTests.cs
-using System;
-using System.Collections.Generic;
-using System.Text;
-using WalletWasabi.Crypto.Groups;
-using WalletWasabi.Crypto.ZeroKnowledge;
-using Xunit;
-
-namespace WalletWasabi.Tests.UnitTests.Crypto.ZeroKnowledge
-{
- public class StatementTests
- {
- [Fact]
- public void Throws()
- {
- // Demonstrate when it shouldn't throw.
- new Statement(Generators.G, Generators.Ga);
- new Statement(Generators.G, Generators.Ga, Generators.Gg);
-
- // Cannot miss generators.
- Assert.ThrowsAny<ArgumentException>(() => new Statement(Generators.G));
-
- // Infinity cannot pass through.
- Assert.ThrowsAny<ArgumentException>(() => new Statement(GroupElement.Infinity, Generators.Ga));
- Assert.ThrowsAny<ArgumentException>(() => new Statement(Generators.G, GroupElement.Infinity));
- Assert.ThrowsAny<ArgumentException>(() => new Statement(GroupElement.Infinity, Generators.Ga, Generators.Gg));
- Assert.ThrowsAny<ArgumentException>(() => new Statement(Generators.G, GroupElement.Infinity, Generators.Gg));
- Assert.ThrowsAny<ArgumentException>(() => new Statement(Generators.G, Generators.Ga, GroupElement.Infinity));
- }
- }
-}

DELETE
WalletWasabi.Tests/UnitTests/Crypto/ZeroKnowledge/VerifierTests.cs
-using NBitcoin.Secp256k1;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using WalletWasabi.Crypto.Groups;
-using WalletWasabi.Crypto.ZeroKnowledge;
-using WalletWasabi.Tests.Helpers;
-using Xunit;
-
-namespace WalletWasabi.Tests.UnitTests.Crypto.ZeroKnowledge
-{
- public class VerifierTests
- {
- [Fact]
- public void KnowledgeOfDiscreteLogVerifiesToFalse()
- {
- // Even if the challenge is correct, because the public input in the hash is right,
- // if the final response is not valid wrt the verification equation,
- // the verifier should still reject.
- var secret = new Scalar(7);
- var generator = Generators.G;
- var publicPoint = secret * generator;
-
- Scalar randomScalar = new Scalar(14);
- var nonce = randomScalar * generator;
- var statement = new Statement(publicPoint, generator);
- var challenge = Challenge.Build(nonce, statement);
-
- var response = randomScalar + (secret + Scalar.One) * challenge;
- var proof = new KnowledgeOfDlog(nonce, response);
- Assert.False(Verifier.Verify(proof, statement));
-
- // Other false verification tests.
- var point1 = new Scalar(3) * Generators.G;
- var point2 = new Scalar(7) * Generators.G;
- var scalar = new Scalar(11);
- var gen = Generators.G;
-
- proof = new KnowledgeOfDlog(point1, scalar);
- var statement2 = new Statement(point2, gen);
- Assert.False(Verifier.Verify(proof, statement2));
- }
-
- [Fact]
- public void Throws()
- {
- var dlProof = new KnowledgeOfDlog(Generators.G, Scalar.One);
- var repProof = new KnowledgeOfRep(Generators.G, Scalar.One, CryptoHelpers.ScalarThree);
-
- // Demonstrate when it shouldn't throw.
- var validStatement1 = new Statement(Generators.Ga, Generators.Gg);
- var validStatement2 = new Statement(Generators.Ga, Generators.Gg, Generators.Ga);
- Verifier.Verify(dlProof, validStatement1);
- Verifier.Verify(repProof, validStatement2);
-
- // Public point should not be equal to the random point of the proof.
- Assert.ThrowsAny<InvalidOperationException>(() => Verifier.Verify(dlProof, new Statement(Generators.G, Generators.Ga)));
- Assert.ThrowsAny<InvalidOperationException>(() => Verifier.Verify(repProof, new Statement(Generators.G, Generators.Gg, Generators.Ga)));
-
- // Same number of generators must be provided as the responses.
- Assert.ThrowsAny<InvalidOperationException>(() => Verifier.Verify(dlProof, new Statement(Generators.Ga, Generators.Gg, Generators.GV)));
- Assert.ThrowsAny<InvalidOperationException>(() => Verifier.Verify(repProof, new Statement(Generators.Ga, Generators.Gg)));
- Assert.ThrowsAny<InvalidOperationException>(() => Verifier.Verify(repProof, new Statement(Generators.Ga, Generators.Gg, Generators.Ga, Generators.GV)));
- }
- }
-}

Delete ProverTests, StatementTests, VerifierTests