Fixing a couple of tests
MODIFY
WalletWasabi.Tests/RegressionTests/DosTests.cs
WalletWasabi.Tests/RegressionTests/DosTests.cs
@@ -97,7 +97,7 @@ namespace WalletWasabi.Tests.RegressionTests
Uri baseUri = new Uri(RegTestFixture.BackendEndPoint);
var fundingTxCount = 0;
- var inputRegistrationUsers = new List<(Requester requester, uint256 blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData)>();
+ var inputRegistrationUsers = new List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData)>();
CoordinatorRound round = null;
for (int i = 0; i < roundConfig.AnonymitySet; i++)
{
@@ -106,8 +106,10 @@ namespace WalletWasabi.Tests.RegressionTests
var changeOutputAddress = new Key().PubKey.GetAddress(ScriptPubKeyType.Segwit, network);
round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
Requester requester = new Requester();
- uint256 blinded = requester.BlindScript(round.MixingLevels.GetBaseLevel().Signer.Key.PubKey, round.MixingLevels.GetBaseLevel().Signer.R.PubKey, activeOutputAddress.ScriptPubKey);
- uint256 blindedOutputScriptsHash = new uint256(Hashes.SHA256(blinded.ToBytes()));
+ var nonce = round.GetNextNonce();
+
+ var blinded = new BlindedOutputWithNonceIndex(nonce.N, requester.BlindScript(round.MixingLevels.GetBaseLevel().SignerKey.PubKey, nonce.R, activeOutputAddress.ScriptPubKey));
+ uint256 blindedOutputScriptsHash = new uint256(Hashes.SHA256(blinded.BlindedOutput.ToBytes()));
var inputProofModels = new List<InputProofModel>();
int numberOfInputs = new Random().Next(1, 7);
@@ -151,15 +153,15 @@ namespace WalletWasabi.Tests.RegressionTests
await rpc.GenerateAsync(1);
}
- var aliceClients = new List<Task<AliceClient>>();
+ var aliceClients = new List<Task<AliceClient4>>();
foreach (var user in inputRegistrationUsers)
{
- aliceClients.Add(AliceClientBase.CreateNewAsync(round.RoundId, new[] { user.activeOutputAddress }, new[] { round.MixingLevels.GetBaseLevel().SchnorrKey.SchnorrPubKey }, new[] { user.requester }, network, user.changeOutputAddress, new[] { user.blinded }, user.inputProofModels, () => baseUri, null));
+ aliceClients.Add(AliceClientBase.CreateNewAsync(round.RoundId, new[] { user.activeOutputAddress }, new[] { round.MixingLevels.GetBaseLevel().SignerKey.PubKey }, new[] { user.requester }, network, user.changeOutputAddress, new[] { user.blinded }, user.inputProofModels, () => baseUri, null));
}
long roundId = 0;
- var users = new List<(Requester requester, uint256 blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, AliceClient aliceClient, UnblindedSignature unblindedSignature)>();
+ var users = new List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, AliceClient4 aliceClient, UnblindedSignature unblindedSignature)>();
for (int i = 0; i < inputRegistrationUsers.Count; i++)
{
var user = inputRegistrationUsers[i];
@@ -227,11 +229,11 @@ namespace WalletWasabi.Tests.RegressionTests
round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
foreach (var user in inputRegistrationUsers)
{
- aliceClients.Add(AliceClientBase.CreateNewAsync(round.RoundId, new[] { user.activeOutputAddress }, new[] { round.MixingLevels.GetBaseLevel().SchnorrKey.SchnorrPubKey }, new[] { user.requester }, network, user.changeOutputAddress, new[] { user.blinded }, user.inputProofModels, () => baseUri, null));
+ aliceClients.Add(AliceClientBase.CreateNewAsync(round.RoundId, new[] { user.activeOutputAddress }, new[] { round.MixingLevels.GetBaseLevel().SignerKey.PubKey }, new[] { user.requester }, network, user.changeOutputAddress, new[] { user.blinded }, user.inputProofModels, () => baseUri, null));
}
roundId = 0;
- users = new List<(Requester requester, uint256 blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, AliceClient aliceClient, UnblindedSignature unblindedSignature)>();
+ users = new List<(Requester requester, BlindedOutputWithNonceIndex blinded, BitcoinAddress activeOutputAddress, BitcoinAddress changeOutputAddress, IEnumerable<InputProofModel> inputProofModels, List<(Key key, BitcoinWitPubKeyAddress address, uint256 txHash, Transaction tx, OutPoint input)> userInputData, AliceClient4 aliceClient, UnblindedSignature unblindedSignature)>();
for (int i = 0; i < inputRegistrationUsers.Count; i++)
{
var user = inputRegistrationUsers[i];
@@ -298,8 +300,8 @@ namespace WalletWasabi.Tests.RegressionTests
Uri baseUri = new Uri(RegTestFixture.BackendEndPoint);
- var registerRequests = new List<(BitcoinWitPubKeyAddress changeOutputAddress, uint256 blindedData, InputProofModel[] inputsProofs)>();
- AliceClient aliceClientBackup = null;
+ var registerRequests = new List<(BitcoinWitPubKeyAddress changeOutputAddress, BlindedOutputWithNonceIndex blindedData, InputProofModel[] inputsProofs)>();
+ AliceClient4 aliceClientBackup = null;
CoordinatorRound round = coordinator.GetCurrentInputRegisterableRoundOrDefault();
for (int i = 0; i < roundConfig.AnonymitySet; i++)
{
@@ -309,8 +311,10 @@ namespace WalletWasabi.Tests.RegressionTests
BitcoinWitPubKeyAddress inputAddress = inputKey.PubKey.GetSegwitAddress(network);
var requester = new Requester();
- uint256 blinded = requester.BlindScript(round.MixingLevels.GetBaseLevel().Signer.Key.PubKey, round.MixingLevels.GetBaseLevel().Signer.R.PubKey, activeOutputAddress.ScriptPubKey);
- uint256 blindedOutputScriptsHash = new uint256(Hashes.SHA256(blinded.ToBytes()));
+ var nonce = round.GetNextNonce();
+
+ var blinded = new BlindedOutputWithNonceIndex(nonce.N, requester.BlindScript(round.MixingLevels.GetBaseLevel().SignerKey.PubKey, nonce.R, activeOutputAddress.ScriptPubKey));
+ uint256 blindedOutputScriptsHash = new uint256(Hashes.SHA256(blinded.BlindedOutput.ToBytes()));
uint256 txHash = await rpc.SendToAddressAsync(inputAddress, Money.Coins(2));
await rpc.GenerateAsync(1);
@@ -321,7 +325,7 @@ namespace WalletWasabi.Tests.RegressionTests
InputProofModel inputProof = new InputProofModel { Input = input, Proof = inputKey.SignCompact(blindedOutputScriptsHash) };
InputProofModel[] inputsProofs = new InputProofModel[] { inputProof };
registerRequests.Add((changeOutputAddress, blinded, inputsProofs));
- aliceClientBackup = await AliceClientBase.CreateNewAsync(round.RoundId, new[] { activeOutputAddress }, new[] { round.MixingLevels.GetBaseLevel().SchnorrKey.SchnorrPubKey }, new[] { requester }, network, changeOutputAddress, new[] { blinded }, inputsProofs, () => baseUri, null);
+ aliceClientBackup = await AliceClientBase.CreateNewAsync(round.RoundId, new[] { activeOutputAddress }, new[] { round.MixingLevels.GetBaseLevel().SignerKey.PubKey }, new[] { requester }, network, changeOutputAddress, new[] { blinded }, inputsProofs, () => baseUri, null);
}
await WaitForTimeoutAsync(baseUri);
@@ -335,7 +339,7 @@ namespace WalletWasabi.Tests.RegressionTests
foreach (var registerRequest in registerRequests)
{
- await AliceClientBase.CreateNewAsync(round.RoundId, aliceClientBackup.RegisteredAddresses, round.MixingLevels.GetAllLevels().Select(x => x.SchnorrKey.SchnorrPubKey), aliceClientBackup.Requesters, network, registerRequest.changeOutputAddress, new[] { registerRequest.blindedData }, registerRequest.inputsProofs, () => baseUri, null);
+ await AliceClientBase.CreateNewAsync(round.RoundId, aliceClientBackup.RegisteredAddresses, round.MixingLevels.GetAllLevels().Select(x => x.SignerKey.PubKey), aliceClientBackup.Requesters, network, registerRequest.changeOutputAddress, new[] { registerRequest.blindedData }, registerRequest.inputsProofs, () => baseUri, null);
}
await WaitForTimeoutAsync(baseUri);

MODIFY
WalletWasabi.Tests/UnitTests/Crypto/SchnorrBlindingSignatureTests.cs
WalletWasabi.Tests/UnitTests/Crypto/SchnorrBlindingSignatureTests.cs
@@ -16,11 +16,11 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var requester = new SchnorrBlinding.Requester();
var r = new Key(Encoders.Hex.DecodeData("31E151628AED2A6ABF7155809CF4F3C762E7160F38B4DA56B784D9045190CFA0"));
var key = new Key(Encoders.Hex.DecodeData("B7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF"));
- var signer = new SchnorrBlinding.Signer(key, r);
+ var signer = new SchnorrBlinding.Signer(key);
var message = new uint256(Encoders.Hex.DecodeData("243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89"), false);
var blindedMessage = requester.BlindMessage(message, r.PubKey, key.PubKey);
- var blindSignature = signer.Sign(blindedMessage);
+ var blindSignature = signer.Sign(blindedMessage, r);
var unblindedSignature = requester.UnblindSignature(blindSignature);
var str = unblindedSignature.ToString();
@@ -44,11 +44,11 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var requester = new SchnorrBlinding.Requester();
var r = new Key(Encoders.Hex.DecodeData("31E151628AED2A6ABF7155809CF4F3C762E7160F38B4DA56B784D9045190CFA0"));
var key = new Key(Encoders.Hex.DecodeData("B7E151628AED2A6ABF7158809CF4F3C762E7160F38B4DA56A784D9045190CFEF"));
- var signer = new SchnorrBlinding.Signer(key, r);
+ var signer = new SchnorrBlinding.Signer(key);
var message = new uint256(Encoders.Hex.DecodeData("243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89"), false);
var blindedMessage = requester.BlindMessage(message, r.PubKey, key.PubKey);
- var blindSignature = signer.Sign(blindedMessage);
+ var blindSignature = signer.Sign(blindedMessage, r);
var unblindedSignature = requester.UnblindSignature(blindSignature);
Assert.True(SchnorrBlinding.VerifySignature(message, unblindedSignature, key.PubKey));
@@ -57,12 +57,12 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
// Test with unknown values
requester = new SchnorrBlinding.Requester();
- signer = new SchnorrBlinding.Signer(new Key(), new Key());
+ signer = new SchnorrBlinding.Signer(new Key());
message = NBitcoin.Crypto.Hashes.Hash256(Encoders.ASCII.DecodeData("Hello world!"));
- blindedMessage = requester.BlindMessage(message, signer.R.PubKey, signer.Key.PubKey);
+ blindedMessage = requester.BlindMessage(message, r.PubKey, signer.Key.PubKey);
- blindSignature = signer.Sign(blindedMessage);
+ blindSignature = signer.Sign(blindedMessage, r);
unblindedSignature = requester.UnblindSignature(blindSignature);
Assert.True(SchnorrBlinding.VerifySignature(message, unblindedSignature, signer.Key.PubKey));
Assert.False(SchnorrBlinding.VerifySignature(uint256.One, unblindedSignature, signer.Key.PubKey));
@@ -72,14 +72,14 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
{
requester = new SchnorrBlinding.Requester();
signer = new SchnorrBlinding.Signer(new Key());
- blindedMessage = requester.BlindMessage(newMessage, signer.R.PubKey, signer.Key.PubKey);
- blindSignature = signer.Sign(blindedMessage);
+ blindedMessage = requester.BlindMessage(newMessage, r.PubKey, signer.Key.PubKey);
+ blindSignature = signer.Sign(blindedMessage, r);
unblindedSignature = requester.UnblindSignature(blindSignature);
Assert.True(signer.VerifyUnblindedSignature(unblindedSignature, newMessage));
}
- var ex = Assert.Throws<ArgumentException>(() => signer.Sign(uint256.Zero));
+ var ex = Assert.Throws<ArgumentException>(() => signer.Sign(uint256.Zero, r));
Assert.StartsWith("Invalid blinded message.", ex.Message);
}
}

MODIFY
WalletWasabi.Tests/UnitTests/CryptoTests.cs
WalletWasabi.Tests/UnitTests/CryptoTests.cs
@@ -78,7 +78,7 @@ namespace WalletWasabi.Tests.UnitTests
// Generate ECDSA keypairs.
var r = new Key();
var key = new Key();
- Signer signer = new Signer(key, r);
+ Signer signer = new Signer(key);
// Generate ECDSA requester.
// Get the r's pubkey and the key's pubkey.
@@ -93,7 +93,7 @@ namespace WalletWasabi.Tests.UnitTests
uint256 blindedMessageHash = requester.BlindMessage(hash, rPubKey, keyPubKey);
// Sign the blinded message hash.
- uint256 blindedSignature = signer.Sign(blindedMessageHash);
+ uint256 blindedSignature = signer.Sign(blindedMessageHash, r);
// Unblind the signature.
UnblindedSignature unblindedSignature = requester.UnblindSignature(blindedSignature);

MODIFY
WalletWasabi.Tests/UnitTests/JsonConvertersTest/UnblindedSignatureTests.cs
WalletWasabi.Tests/UnitTests/JsonConvertersTest/UnblindedSignatureTests.cs
@@ -20,7 +20,7 @@ namespace WalletWasabi.Tests.UnitTests.JsonConvertersTest
var converter = new UnblindedSignatureJsonConverter();
var r = new Key();
var key = new Key();
- var signer = new SchnorrBlinding.Signer(key, r);
+ var signer = new SchnorrBlinding.Signer(key);
foreach (var i in Enumerable.Range(0, 100))
{
@@ -29,7 +29,7 @@ namespace WalletWasabi.Tests.UnitTests.JsonConvertersTest
var message = new byte[256];
Random.NextBytes(message);
var blindedMessage = requester.BlindMessage(message, r.PubKey, key.PubKey);
- var blindSignature = signer.Sign(blindedMessage);
+ var blindSignature = signer.Sign(blindedMessage, r);
var unblindedSignature = requester.UnblindSignature(blindSignature);
var sb = new StringBuilder();

Fixing a couple of tests