Scalar generators do not overflow
MODIFY
WalletWasabi/Crypto/ZeroKnowledge/SyntheticSecretNonceProvider.cs
WalletWasabi/Crypto/ZeroKnowledge/SyntheticSecretNonceProvider.cs
@@ -31,7 +31,14 @@ public class SyntheticSecretNonceProvider
{
while (true)
{
- yield return new Scalar(_strobe.Prf(32, false));
+ Scalar scalar;
+ int overflow;
+ do
+ {
+ scalar = new Scalar(_strobe.Prf(32, false), out overflow);
+ }
+ while (overflow != 0);
+ yield return scalar;
}
}

MODIFY
WalletWasabi/Crypto/ZeroKnowledge/Transcript.cs
WalletWasabi/Crypto/ZeroKnowledge/Transcript.cs
@@ -64,9 +64,16 @@ public sealed class Transcript
// Generate Fiat Shamir challenges
public Scalar GenerateChallenge()
+ {
+ Scalar scalar;
+ int overflow;
+ do
{
_strobe.AddAssociatedMetaData(ChallengeTag, false);
- return new Scalar(_strobe.Prf(KeySizeInBytes, false));
+ scalar = new Scalar(_strobe.Prf(KeySizeInBytes, false), out overflow);
+ }
+ while(overflow != 0);
+ return scalar;
}
private void AddMessage(byte[] label, byte[] message)

Scalar generators do not overflow