Rename randomPoint and randomness to nonce.
MODIFY
WalletWasabi.Tests/UnitTests/Crypto/ZeroKnowledge/ZkExponentTests.cs
WalletWasabi.Tests/UnitTests/Crypto/ZeroKnowledge/ZkExponentTests.cs
@@ -82,11 +82,11 @@ namespace WalletWasabi.Tests.UnitTests.Crypto.ZeroKnowledge
var publicPoint = secret * generator;
Scalar randomScalar = new Scalar(14);
- var randomPoint = randomScalar * generator;
- var challenge = ZkChallenge.Build(publicPoint, randomPoint);
+ var nonce = randomScalar * generator;
+ var challenge = ZkChallenge.Build(publicPoint, nonce);
var response = randomScalar + (secret + Scalar.One) * challenge;
- var proof = new ZkKnowledgeOfExponent(randomPoint, response);
+ var proof = new ZkKnowledgeOfExponent(nonce, response);
Assert.False(ZkVerifier.Verify(proof, publicPoint, generator));
// Other false verification tests.
@@ -135,18 +135,18 @@ namespace WalletWasabi.Tests.UnitTests.Crypto.ZeroKnowledge
var point2 = new Scalar(7) * Generators.G;
var publicPoint = point1;
- var randomPoint = Generators.G;
- var challenge = ZkChallenge.Build(publicPoint, randomPoint);
+ var nonce = Generators.G;
+ var challenge = ZkChallenge.Build(publicPoint, nonce);
Assert.Equal("secp256k1_scalar = { 0x0F850F8CUL, 0x9D74683AUL, 0xDD03779BUL, 0xFD58F09BUL, 0xE148D87AUL, 0x3477A63FUL, 0xBE5906D3UL, 0x35E5A382UL }", challenge.ToC(""));
publicPoint = Generators.G;
- randomPoint = point2;
- challenge = ZkChallenge.Build(publicPoint, randomPoint);
+ nonce = point2;
+ challenge = ZkChallenge.Build(publicPoint, nonce);
Assert.Equal("secp256k1_scalar = { 0x69823107UL, 0xDA1CE96BUL, 0xBA00C8E7UL, 0x8A031437UL, 0x4D0BC9ADUL, 0x790E6FD8UL, 0x6C2EF5E6UL, 0x8F476E3FUL }", challenge.ToC(""));
publicPoint = point1;
- randomPoint = point2;
- challenge = ZkChallenge.Build(publicPoint, randomPoint);
+ nonce = point2;
+ challenge = ZkChallenge.Build(publicPoint, nonce);
Assert.Equal("secp256k1_scalar = { 0xC5AA9243UL, 0x074DDA7CUL, 0xE8FFD6CAUL, 0xF3613B9EUL, 0x542CBD09UL, 0xF4191712UL, 0x045BD716UL, 0xECCC6626UL }", challenge.ToC(""));
}

MODIFY
WalletWasabi/Crypto/ZeroKnowledge/ZkChallenge.cs
WalletWasabi/Crypto/ZeroKnowledge/ZkChallenge.cs
@@ -10,17 +10,17 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
{
public static class ZkChallenge
{
- public static Scalar Build(GroupElement publicPoint, GroupElement randomPoint)
+ public static Scalar Build(GroupElement publicPoint, GroupElement nonce)
{
Guard.False($"{nameof(publicPoint)}.{nameof(publicPoint.IsInfinity)}", publicPoint.IsInfinity);
- Guard.False($"{nameof(randomPoint)}.{nameof(randomPoint.IsInfinity)}", randomPoint.IsInfinity);
+ Guard.False($"{nameof(nonce)}.{nameof(nonce.IsInfinity)}", nonce.IsInfinity);
- if (publicPoint == randomPoint)
+ if (publicPoint == nonce)
{
- throw new InvalidOperationException($"{nameof(publicPoint)} and {nameof(randomPoint)} should not be equal.");
+ throw new InvalidOperationException($"{nameof(publicPoint)} and {nameof(nonce)} should not be equal.");
}
- return HashToScalar(publicPoint, randomPoint);
+ return HashToScalar(publicPoint, nonce);
}
public static Scalar HashToScalar(params GroupElement[] transcript)

MODIFY
WalletWasabi/Crypto/ZeroKnowledge/ZkKnowledgeOfExponent.cs
WalletWasabi/Crypto/ZeroKnowledge/ZkKnowledgeOfExponent.cs
@@ -9,16 +9,16 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
{
public class ZkKnowledgeOfExponent
{
- public ZkKnowledgeOfExponent(GroupElement randomPoint, Scalar response)
+ public ZkKnowledgeOfExponent(GroupElement nonce, Scalar response)
{
- Guard.False($"{nameof(randomPoint)}.{nameof(randomPoint.IsInfinity)}", randomPoint.IsInfinity);
+ Guard.False($"{nameof(nonce)}.{nameof(nonce.IsInfinity)}", nonce.IsInfinity);
Guard.False($"{nameof(response)}.{nameof(response.IsZero)}", response.IsZero);
- RandomPoint = randomPoint;
+ Nonce = nonce;
Response = response;
}
- public GroupElement RandomPoint { get; }
+ public GroupElement Nonce { get; }
public Scalar Response { get; }
}
}

MODIFY
WalletWasabi/Crypto/ZeroKnowledge/ZkKnowledgeOfRepresentation.cs
WalletWasabi/Crypto/ZeroKnowledge/ZkKnowledgeOfRepresentation.cs
@@ -8,13 +8,13 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
{
public class ZkKnowledgeOfRepresentation
{
- public ZkKnowledgeOfRepresentation(GroupElement randomness, IEnumerable<Scalar> responses)
+ public ZkKnowledgeOfRepresentation(GroupElement nonce, IEnumerable<Scalar> responses)
{
- Randomness = randomness;
+ Nonce = nonce;
Responses = responses;
}
- public GroupElement Randomness { get; }
+ public GroupElement Nonce { get; }
public IEnumerable<Scalar> Responses { get; }
}
}

MODIFY
WalletWasabi/Crypto/ZeroKnowledge/ZkProver.cs
WalletWasabi/Crypto/ZeroKnowledge/ZkProver.cs
@@ -24,7 +24,7 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
var proof = CreateProof(new[] { exponent }, publicPoint, new[] { generator }, random);
- return new ZkKnowledgeOfExponent(proof.Randomness, proof.Responses.First());
+ return new ZkKnowledgeOfExponent(proof.Nonce, proof.Responses.First());
}
public static ZkKnowledgeOfRepresentation CreateProof(IEnumerable<Scalar> exponents, GroupElement publicPoint, IEnumerable<GroupElement> generators, WasabiRandom? random = null)
@@ -39,7 +39,7 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
throw new ArgumentException($"Same number of exponents and generators must be provided. Exponents: {exponentArray.Length}, Generators: {generatorArray.Length}");
}
- var randomness = GroupElement.Infinity;
+ var nonce = GroupElement.Infinity;
var randomScalars = new List<Scalar>();
for (int i = 0; i < exponentArray.Length; i++)
{
@@ -54,10 +54,10 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
randomScalars.Add(randomScalar);
var randomPoint = randomScalar * generator;
- randomness += randomPoint;
+ nonce += randomPoint;
}
- var challenge = ZkChallenge.HashToScalar(new[] { publicPoint, randomness }.Concat(generators).ToArray());
+ var challenge = ZkChallenge.HashToScalar(new[] { publicPoint, nonce }.Concat(generators).ToArray());
var responses = new List<Scalar>();
for (int i = 0; i < exponentArray.Length; i++)
@@ -68,7 +68,7 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
responses.Add(response);
}
- return new ZkKnowledgeOfRepresentation(randomness, responses);
+ return new ZkKnowledgeOfRepresentation(nonce, responses);
}
private static Scalar GetNonZeroRandomScalar(WasabiRandom? random = null)

MODIFY
WalletWasabi/Crypto/ZeroKnowledge/ZkVerifier.cs
WalletWasabi/Crypto/ZeroKnowledge/ZkVerifier.cs
@@ -14,12 +14,12 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
Guard.False($"{nameof(generator)}.{nameof(generator.IsInfinity)}", generator.IsInfinity);
Guard.False($"{nameof(publicPoint)}.{nameof(publicPoint.IsInfinity)}", publicPoint.IsInfinity);
- if (publicPoint == proof.RandomPoint)
+ if (publicPoint == proof.Nonce)
{
- throw new InvalidOperationException($"{nameof(publicPoint)} and {nameof(proof.RandomPoint)} should not be equal.");
+ throw new InvalidOperationException($"{nameof(publicPoint)} and {nameof(proof.Nonce)} should not be equal.");
}
- var zkor = new ZkKnowledgeOfRepresentation(proof.RandomPoint, new[] { proof.Response });
+ var zkor = new ZkKnowledgeOfRepresentation(proof.Nonce, new[] { proof.Response });
return Verify(zkor, publicPoint, new[] { generator });
}
@@ -30,11 +30,11 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
Guard.False($"{nameof(generator)}.{nameof(generator.IsInfinity)}", generator.IsInfinity);
}
- var randomness = proof.Randomness;
+ var nonce = proof.Nonce;
var responses = proof.Responses.ToArray();
- var challenge = ZkChallenge.HashToScalar(new[] { publicPoint, randomness }.Concat(generators).ToArray());
- var a = challenge * publicPoint + randomness;
+ var challenge = ZkChallenge.HashToScalar(new[] { publicPoint, nonce }.Concat(generators).ToArray());
+ var a = challenge * publicPoint + nonce;
var b = GroupElement.Infinity;
for (int i = 0; i < responses.Length; i++)

Rename randomPoint and randomness to nonce.