Add sanity check for public point.
MODIFY
WalletWasabi/Crypto/ZeroKnowledge/Prover.cs
WalletWasabi/Crypto/ZeroKnowledge/Prover.cs
@@ -33,19 +33,25 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
var nonce = GroupElement.Infinity;
var randomScalars = new List<Scalar>();
+ var publicPointSanity = publicPoint;
foreach (var (secret, generator) in secretGeneratorPairs)
{
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);
+ publicPointSanity -= secret * generator;
var randomScalar = GetNonZeroRandomScalar(random);
randomScalars.Add(randomScalar);
var randomPoint = randomScalar * generator;
-
nonce += randomPoint;
}
+ if (publicPointSanity != GroupElement.Infinity)
+ {
+ throw new InvalidOperationException($"{nameof(publicPoint)} was incorrectly constructed.");
+ }
+
var challenge = Challenge.Build(publicPoint, nonce, secretGeneratorPairs.Select(x => x.generator));
var responses = new List<Scalar>();

Add sanity check for public point.