Use publicNonce inscead of nonce
MODIFY
WalletWasabi.Tests/UnitTests/Crypto/TranscriptTests.cs
WalletWasabi.Tests/UnitTests/Crypto/TranscriptTests.cs
@@ -70,24 +70,24 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
transcript3.CommitPublicNonces(commitment2);
transcript4.CommitPublicNonces(commitment2);
- var nonceGenerator1 = transcript1.CreateSyntheticNoncesProvider(witness1, rnd);
- var nonceGenerator2 = transcript2.CreateSyntheticNoncesProvider(witness1, rnd);
- var nonceGenerator3 = transcript3.CreateSyntheticNoncesProvider(witness2, rnd);
- var nonceGenerator4 = transcript4.CreateSyntheticNoncesProvider(witness2, rnd);
+ var publicNonceGenerator1 = transcript1.CreateSyntheticPublicNoncesProvider(witness1, rnd);
+ var publicNonceGenerator2 = transcript2.CreateSyntheticPublicNoncesProvider(witness1, rnd);
+ var publicNonceGenerator3 = transcript3.CreateSyntheticPublicNoncesProvider(witness2, rnd);
+ var publicNonceGenerator4 = transcript4.CreateSyntheticPublicNoncesProvider(witness2, rnd);
- var nonce1 = nonceGenerator1().First();
- var nonce2 = nonceGenerator2().First();
- var nonce3 = nonceGenerator3().First();
- var nonce4 = nonceGenerator4().First();
+ var publicNonce1 = publicNonceGenerator1().First();
+ var publicNonce2 = publicNonceGenerator2().First();
+ var publicNonce3 = publicNonceGenerator3().First();
+ var publicNonce4 = publicNonceGenerator4().First();
- Assert.NotEqual(nonce1, nonce2);
- Assert.NotEqual(nonce1, nonce3);
- Assert.NotEqual(nonce1, nonce4);
+ Assert.NotEqual(publicNonce1, publicNonce2);
+ Assert.NotEqual(publicNonce1, publicNonce3);
+ Assert.NotEqual(publicNonce1, publicNonce4);
- Assert.NotEqual(nonce2, nonce3);
- Assert.NotEqual(nonce2, nonce4);
+ Assert.NotEqual(publicNonce2, publicNonce3);
+ Assert.NotEqual(publicNonce2, publicNonce4);
- Assert.NotEqual(nonce3, nonce4);
+ Assert.NotEqual(publicNonce3, publicNonce4);
}
}
}
\ No newline at end of file

DELETE
WalletWasabi/Crypto/Transcript.cs
-using NBitcoin.Secp256k1;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using WalletWasabi.Crypto.Groups;
-using WalletWasabi.Crypto.Randomness;
-using WalletWasabi.Crypto.StrobeProtocol;
-
-namespace WalletWasabi.Crypto.ZeroKnowledge
-{
- public delegate IEnumerable<Scalar> NoncesSequence();
-
- // High level API for transcripts of compound Sigma protocol style proofs
- // implements synthetic nonces and Fiat-Shamir challenges.
- public sealed class Transcript
- {
- private const int KeySizeInBytes = 32;
-
- private Strobe128 _strobe;
-
- private static readonly byte[] StatementTag = Encoding.UTF8.GetBytes("statement");
- private static readonly byte[] ChallengeTag = Encoding.UTF8.GetBytes("challenge");
- private static readonly byte[] NonceTag = Encoding.UTF8.GetBytes("nonce-commitment");
- private static readonly byte[] DomainSeparatorTag = Encoding.UTF8.GetBytes("domain-separator");
-
-
- /// <summary>
- /// Initialize a new transcript with the supplied <param>label</param>, which
- /// is used as a domain separator.
- /// </summary>
- /// <remarks>
- /// This function should be called by a proof library's API consumer
- /// (i.e., the application using the proof library), and
- /// **not by the proof implementation**. See the [Passing
- /// Transcripts](https://merlin.cool/use/passing.html) section of
- /// the Merlin website for more details on why.
- /// </remarks>
- public Transcript(byte[] label)
- : this(new Strobe128("WabiSabi_v1.0"))
- {
- AddMessage(DomainSeparatorTag, label);
- }
-
- // Private constructor used for cloning.
- private Transcript(Strobe128 strobe)
- {
- _strobe = strobe;
- }
-
- public Transcript MakeCopy() =>
- new Transcript(_strobe.MakeCopy());
-
- // Generate synthetic nonce using current state combined with additional randomness.
- public NoncesSequence CreateSyntheticNoncesProvider(IEnumerable<Scalar> secrets, WasabiRandom random)
- {
- // To integrate prior inputs for deterministic component of nonce
- // generation, first clone the state at the current point in the
- // transcript, which should already have the statement tag and public
- // inputs committed.
- var forked = _strobe.MakeCopy();
-
- // add secret inputs as key material
- foreach (var secret in secrets)
- {
- forked.Key(secret.ToBytes(), false);
- }
-
- // Add additional randomness
- forked.Key(random.GetBytes(KeySizeInBytes), false);
-
- IEnumerable<Scalar> NoncesGenerator()
- {
- while (true)
- {
- yield return new Scalar(forked.Prf(KeySizeInBytes, false));
- }
- }
-
- // Generate a new scalar for each secret using this updated state as a seed.
- return NoncesGenerator;
- }
-
- public void CommitPublicNonces(IEnumerable<GroupElement> nonces)
- {
- CryptoGuard.NotInfinity(nameof(nonces), nonces);
- AddMessages(NonceTag, nonces.Select(x => x.ToBytes()));
- }
-
- // Generate Fiat Shamir challenges
- public Scalar GenerateChallenge()
- {
- _strobe.AddAssociatedMetaData(ChallengeTag, false);
- return new Scalar(_strobe.Prf(KeySizeInBytes, false));
- }
-
- private void AddMessage(byte[] label, byte[] message)
- {
- _strobe.AddAssociatedMetaData(label, false);
- _strobe.AddAssociatedMetaData(BitConverter.GetBytes(message.Length), true);
- _strobe.AddAssociatedData(message, false);
- }
-
- private void AddMessages(byte[] label, IEnumerable<byte[]> messages)
- {
- _strobe.AddAssociatedMetaData(label, false);
- _strobe.AddAssociatedMetaData(BitConverter.GetBytes(messages.Count()), true);
- foreach (var message in messages.Select((m, i) => (Index: i, Payload: m) ))
- {
- AddMessage(BitConverter.GetBytes(message.Index), message.Payload);
- }
- }
- }
-}

MODIFY
WalletWasabi/Crypto/ZeroKnowledge/Transcript.cs
WalletWasabi/Crypto/ZeroKnowledge/Transcript.cs
@@ -9,7 +9,7 @@ using WalletWasabi.Crypto.StrobeProtocol;
namespace WalletWasabi.Crypto.ZeroKnowledge
{
- public delegate IEnumerable<Scalar> NoncesSequence();
+ public delegate IEnumerable<Scalar> PublicNoncesSequence();
// High level API for transcripts of compound Sigma protocol style proofs
// implements synthetic nonces and Fiat-Shamir challenges.
@@ -52,7 +52,7 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
new Transcript(_strobe.MakeCopy());
// Generate synthetic nonce using current state combined with additional randomness.
- public NoncesSequence CreateSyntheticNoncesProvider(IEnumerable<Scalar> secrets, WasabiRandom random)
+ public PublicNoncesSequence CreateSyntheticPublicNoncesProvider(IEnumerable<Scalar> secrets, WasabiRandom random)
{
// To integrate prior inputs for deterministic component of nonce
// generation, first clone the state at the current point in the

Use publicNonce inscead of nonce