Rename exponent to secret
MODIFY
WalletWasabi.Tests/UnitTests/Crypto/ZeroKnowledge/KnowledgeOfExponentTests.cs
WalletWasabi.Tests/UnitTests/Crypto/ZeroKnowledge/KnowledgeOfExponentTests.cs
@@ -50,23 +50,23 @@ namespace WalletWasabi.Tests.UnitTests.Crypto.ZeroKnowledge
[InlineData(short.MaxValue)]
[InlineData(int.MaxValue)]
[InlineData(uint.MaxValue)]
- public void End2EndVerifiesSimpleProof(uint scalarSeed)
+ public void End2EndVerificationSimple(uint scalarSeed)
{
- var exponent = new Scalar(scalarSeed);
+ var secret = new Scalar(scalarSeed);
var generator = Generators.G;
- var publicPoint = exponent * generator;
- var proof = Prover.CreateProof(exponent, publicPoint, generator);
+ var publicPoint = secret * generator;
+ var proof = Prover.CreateProof(secret, publicPoint, generator);
Assert.True(Verifier.Verify(proof, publicPoint, generator));
}
[Fact]
- public void End2EndVerifiesExponents()
+ public void End2EndVerification()
{
- foreach (var exponent in GetScalars(x => !x.IsOverflow && !x.IsZero))
+ foreach (var secret in GetScalars(x => !x.IsOverflow && !x.IsZero))
{
var generator = Generators.G;
- var publicPoint = exponent * generator;
- var proof = Prover.CreateProof(exponent, publicPoint, generator);
+ var publicPoint = secret * generator;
+ var proof = Prover.CreateProof(secret, publicPoint, generator);
Assert.True(Verifier.Verify(proof, publicPoint, generator));
}
}
@@ -104,27 +104,27 @@ namespace WalletWasabi.Tests.UnitTests.Crypto.ZeroKnowledge
{
uint val = int.MaxValue;
var gen = new Scalar(4) * Generators.G;
- var exponent = new Scalar(val, val, val, val, val, val, val, val);
- var p = exponent * gen;
- var proof = Prover.CreateProof(exponent, p, gen);
+ var secret = new Scalar(val, val, val, val, val, val, val, val);
+ var p = secret * gen;
+ var proof = Prover.CreateProof(secret, p, gen);
Assert.True(Verifier.Verify(proof, p, gen));
- exponent = EC.N + (new Scalar(1)).Negate();
- p = exponent * gen;
- proof = Prover.CreateProof(exponent, p, gen);
+ secret = EC.N + (new Scalar(1)).Negate();
+ p = secret * gen;
+ proof = Prover.CreateProof(secret, p, gen);
Assert.True(Verifier.Verify(proof, p, gen));
- exponent = EC.NC;
- p = exponent * gen;
- proof = Prover.CreateProof(exponent, p, gen);
+ secret = EC.NC;
+ p = secret * gen;
+ proof = Prover.CreateProof(secret, p, gen);
Assert.True(Verifier.Verify(proof, p, gen));
- exponent = EC.NC + new Scalar(1);
- p = exponent * gen;
- proof = Prover.CreateProof(exponent, p, gen);
+ secret = EC.NC + new Scalar(1);
+ p = secret * gen;
+ proof = Prover.CreateProof(secret, p, gen);
Assert.True(Verifier.Verify(proof, p, gen));
- exponent = EC.NC + (new Scalar(1)).Negate();
- p = exponent * gen;
- proof = Prover.CreateProof(exponent, p, gen);
+ secret = EC.NC + (new Scalar(1)).Negate();
+ p = secret * gen;
+ proof = Prover.CreateProof(secret, p, gen);
Assert.True(Verifier.Verify(proof, p, gen));
}
@@ -166,7 +166,7 @@ namespace WalletWasabi.Tests.UnitTests.Crypto.ZeroKnowledge
}
[Fact]
- public void ExponentProofThrows()
+ public void KnowledgeOfExponentThrows()
{
// Demonstrate when it shouldn't throw.
new KnowledgeOfExponent(Generators.G, Scalar.One);
@@ -194,12 +194,12 @@ namespace WalletWasabi.Tests.UnitTests.Crypto.ZeroKnowledge
Assert.ThrowsAny<ArgumentException>(() => Prover.CreateProof(two, GroupElement.Infinity, GroupElement.Infinity));
Assert.ThrowsAny<ArgumentException>(() => Prover.CreateProof(Scalar.Zero, GroupElement.Infinity, GroupElement.Infinity));
- // Public point must be generator * exponent.
+ // Public point must be generator * secret.
Assert.ThrowsAny<InvalidOperationException>(() => Prover.CreateProof(two, Generators.G, Generators.G));
Assert.ThrowsAny<InvalidOperationException>(() => Prover.CreateProof(two, new Scalar(3) * Generators.G, Generators.G));
Assert.ThrowsAny<InvalidOperationException>(() => Prover.CreateProof(two, Scalar.One * Generators.G, Generators.G));
- // Exponent cannot overflow.
+ // Secret cannot overflow.
Assert.ThrowsAny<ArgumentException>(() => Prover.CreateProof(EC.N, EC.N * Generators.G, Generators.G));
Assert.ThrowsAny<ArgumentException>(() => Prover.CreateProof(ScalarLargestOverflow, ScalarLargestOverflow * Generators.G, Generators.G));
}

MODIFY
WalletWasabi.Tests/UnitTests/Crypto/ZeroKnowledge/KnowledgeOfRepresentationTests.cs
WalletWasabi.Tests/UnitTests/Crypto/ZeroKnowledge/KnowledgeOfRepresentationTests.cs
@@ -19,16 +19,16 @@ namespace WalletWasabi.Tests.UnitTests.Crypto.ZeroKnowledge
[InlineData(short.MaxValue, uint.MaxValue)]
[InlineData(int.MaxValue, uint.MaxValue)]
[InlineData(uint.MaxValue, uint.MaxValue)]
- public void End2EndVerifiesSimpleProof(uint scalarSeed1, uint scalarSeed2)
+ public void End2EndVerificationSimple(uint scalarSeed1, uint scalarSeed2)
{
- var exponents = new[] { new Scalar(scalarSeed1), new Scalar(scalarSeed2) };
+ var secrets = new[] { new Scalar(scalarSeed1), new Scalar(scalarSeed2) };
var generators = new[] { Generators.G, Generators.Ga };
var publicPoint = GroupElement.Infinity;
- for (int i = 0; i < exponents.Length; i++)
+ for (int i = 0; i < secrets.Length; i++)
{
- publicPoint += exponents[i] * generators[i];
+ publicPoint += secrets[i] * generators[i];
}
- var proof = Prover.CreateProof(exponents, publicPoint, generators);
+ var proof = Prover.CreateProof(secrets, publicPoint, generators);
Assert.True(Verifier.Verify(proof, publicPoint, generators));
}
}

MODIFY
WalletWasabi/Crypto/ZeroKnowledge/Prover.cs
WalletWasabi/Crypto/ZeroKnowledge/Prover.cs
@@ -11,43 +11,43 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
{
public static class Prover
{
- public static KnowledgeOfExponent CreateProof(Scalar exponent, GroupElement publicPoint, GroupElement generator, WasabiRandom? random = null)
+ public static KnowledgeOfExponent CreateProof(Scalar secret, GroupElement publicPoint, GroupElement generator, WasabiRandom? random = null)
{
- Guard.False($"{nameof(exponent)}.{nameof(exponent.IsOverflow)}", exponent.IsOverflow);
- Guard.False($"{nameof(exponent)}.{nameof(exponent.IsZero)}", exponent.IsZero);
+ Guard.False($"{nameof(secret)}.{nameof(secret.IsOverflow)}", secret.IsOverflow);
+ Guard.False($"{nameof(secret)}.{nameof(secret.IsZero)}", secret.IsZero);
Guard.False($"{nameof(generator)}.{nameof(generator.IsInfinity)}", generator.IsInfinity);
Guard.False($"{nameof(publicPoint)}.{nameof(publicPoint.IsInfinity)}", publicPoint.IsInfinity);
- if (publicPoint != exponent * generator)
+ if (publicPoint != secret * generator)
{
- throw new InvalidOperationException($"{nameof(publicPoint)} != {nameof(exponent)} * {nameof(generator)}");
+ throw new InvalidOperationException($"{nameof(publicPoint)} != {nameof(secret)} * {nameof(generator)}");
}
- var proof = CreateProof(new[] { exponent }, publicPoint, new[] { generator }, random);
+ var proof = CreateProof(new[] { secret }, publicPoint, new[] { generator }, random);
return new KnowledgeOfExponent(proof.Nonce, proof.Responses.First());
}
- public static KnowledgeOfRepresentation CreateProof(IEnumerable<Scalar> exponents, GroupElement publicPoint, IEnumerable<GroupElement> generators, WasabiRandom? random = null)
+ public static KnowledgeOfRepresentation CreateProof(IEnumerable<Scalar> secrets, GroupElement publicPoint, IEnumerable<GroupElement> generators, WasabiRandom? random = null)
{
Guard.False($"{nameof(publicPoint)}.{nameof(publicPoint.IsInfinity)}", publicPoint.IsInfinity);
- var exponentArray = exponents.ToArray();
+ var secretArray = secrets.ToArray();
var generatorArray = generators.ToArray();
- if (exponentArray.Length != generatorArray.Length)
+ if (secretArray.Length != generatorArray.Length)
{
- throw new ArgumentException($"Same number of exponents and generators must be provided. Exponents: {exponentArray.Length}, Generators: {generatorArray.Length}");
+ throw new ArgumentException($"Same number of secrets and generators must be provided. Secrets: {secretArray.Length}, Generators: {generatorArray.Length}");
}
var nonce = GroupElement.Infinity;
var randomScalars = new List<Scalar>();
- for (int i = 0; i < exponentArray.Length; i++)
+ for (int i = 0; i < secretArray.Length; i++)
{
- var exponent = exponentArray[i];
+ var secret = secretArray[i];
var generator = generatorArray[i];
- Guard.False($"{nameof(exponent)}.{nameof(exponent.IsOverflow)}", exponent.IsOverflow);
- Guard.False($"{nameof(exponent)}.{nameof(exponent.IsZero)}", exponent.IsZero);
+ Guard.False($"{nameof(secret)}.{nameof(secret.IsOverflow)}", secret.IsOverflow);
+ Guard.False($"{nameof(secret)}.{nameof(secret.IsZero)}", secret.IsZero);
Guard.False($"{nameof(generator)}.{nameof(generator.IsInfinity)}", generator.IsInfinity);
var randomScalar = GetNonZeroRandomScalar(random);
@@ -60,11 +60,11 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
var challenge = Challenge.HashToScalar(new[] { publicPoint, nonce }.Concat(generators).ToArray());
var responses = new List<Scalar>();
- for (int i = 0; i < exponentArray.Length; i++)
+ for (int i = 0; i < secretArray.Length; i++)
{
- var exponent = exponentArray[i];
+ var secret = secretArray[i];
var randomScalar = randomScalars.ToArray()[i];
- var response = randomScalar + exponent * challenge;
+ var response = randomScalar + secret * challenge;
responses.Add(response);
}

Rename exponent to secret