Finish up registration request pre-checks
MODIFY
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
@@ -101,9 +101,24 @@ namespace WalletWasabi.Tests.Helpers
var inputRoundSignaturePairs = pairs ?? CreateInputRoundSignaturePairs(1, round?.Hash);
var rnd = new InsecureRandom();
- var client = new WabiSabiClient(new CredentialIssuerSecretKey(rnd).ComputeCredentialIssuerParameters(), 2, rnd, 4300000000000); // Input Reg
- var (zeroAmountCredentialRequest, _) = client.CreateRequestForZeroAmount();
- var (zeroWeightCredentialRequest, _) = client.CreateRequestForZeroAmount();
+ var amClient =
+ round is null
+ ? new WabiSabiClient(new CredentialIssuerSecretKey(rnd).ComputeCredentialIssuerParameters(), 2, rnd, 4300000000000)
+ : new WabiSabiClient(
+ round.AmountCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters(),
+ round.AmountCredentialIssuer.NumberOfCredentials,
+ rnd,
+ round.MaxRegistrableAmount);
+ var weClient =
+ round is null
+ ? new WabiSabiClient(new CredentialIssuerSecretKey(rnd).ComputeCredentialIssuerParameters(), 2, rnd, 4300000000000)
+ : new WabiSabiClient(
+ round.WeightCredentialIssuer.CredentialIssuerSecretKey.ComputeCredentialIssuerParameters(),
+ round.WeightCredentialIssuer.NumberOfCredentials,
+ rnd,
+ round.MaxRegistrableWeight);
+ var (zeroAmountCredentialRequest, _) = amClient.CreateRequestForZeroAmount();
+ var (zeroWeightCredentialRequest, _) = weClient.CreateRequestForZeroAmount();
return new(
roundId,

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RegisterInputTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/RegisterInputTests.cs
@@ -18,6 +18,32 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
{
public class RegisterInputTests
{
+ [Fact]
+ public async Task SuccessAsync()
+ {
+ MockArena arena = new();
+ WabiSabiConfig cfg = new();
+ var round = WabiSabiFactory.CreateRound(cfg);
+ arena.OnTryGetRound = _ => round;
+ MockRpcClient rpc = new();
+ using Key key = new();
+
+ rpc.OnGetTxOutAsync = (_, _, _) => new()
+ {
+ Confirmations = 1,
+ ScriptPubKeyType = "witness_v0_keyhash",
+ TxOut = new TxOut(Money.Coins(1), key.PubKey.GetSegwitAddress(Network.Main))
+ };
+
+ var req = WabiSabiFactory.CreateInputsRegistrationRequest(key, round);
+ await using PostRequestHandler handler = new(cfg, new Prison(), arena, rpc);
+ var resp = await handler.RegisterInputAsync(req);
+ Assert.NotEmpty(round.Alices);
+ Assert.NotNull(resp);
+ Assert.NotNull(resp.AmountCredentials);
+ Assert.NotNull(resp.WeightCredentials);
+ }
+
[Fact]
public async Task RoundNotFoundAsync()
{

MODIFY
WalletWasabi/WabiSabi/Backend/PostRequests/PostRequestHandler.cs
WalletWasabi/WabiSabi/Backend/PostRequests/PostRequestHandler.cs
@@ -81,7 +81,10 @@ namespace WalletWasabi.WabiSabi.Backend.PostRequests
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.RoundNotFound);
}
- return round.RegisterAlice(new Alice(coinRoundSignaturePairs));
+ return round.RegisterAlice(
+ new Alice(coinRoundSignaturePairs),
+ request.ZeroAmountCredentialRequests,
+ request.ZeroWeightCredentialRequests);
}
}

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
WalletWasabi/WabiSabi/Backend/Rounds/Round.cs
@@ -10,6 +10,7 @@ using WalletWasabi.Crypto.Randomness;
using WalletWasabi.Helpers;
using WalletWasabi.WabiSabi.Backend.Models;
using WalletWasabi.WabiSabi.Crypto;
+using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
using WalletWasabi.WabiSabi.Models;
namespace WalletWasabi.WabiSabi.Backend.Rounds
@@ -85,7 +86,10 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
return alice is not null;
}
- public InputsRegistrationResponse RegisterAlice(Alice alice)
+ public InputsRegistrationResponse RegisterAlice(
+ Alice alice,
+ ZeroCredentialsRequest zeroAmountCredentialRequests,
+ ZeroCredentialsRequest zeroWeightCredentialRequests)
{
var coins = alice.Coins;
if (MaxInputCountByAlice < coins.Count())
@@ -139,15 +143,19 @@ namespace WalletWasabi.WabiSabi.Backend.Rounds
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.TooMuchWeight);
}
+ var amountCredentialResponse = AmountCredentialIssuer.HandleRequest(zeroAmountCredentialRequests);
+ var weightCredentialResponse = WeightCredentialIssuer.HandleRequest(zeroWeightCredentialRequests);
+
lock (Lock)
{
if (Phase != Phase.InputRegistration)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.WrongPhase);
}
-
- throw new NotImplementedException();
+ Alices.Add(alice);
}
+
+ return new(alice.Id, amountCredentialResponse, weightCredentialResponse);
}
}
}

Finish up registration request pre-checks