Consolidate progress on call
MODIFY
WalletWasabi.Tests/UnitTests/Wabisabi/CredentialTests.cs
WalletWasabi.Tests/UnitTests/Wabisabi/CredentialTests.cs
@@ -13,6 +13,57 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi
{
public class CredentialTests
{
+ [Fact]
+ public void Foo()
+ {
+ // Split 1 BTC into 0.1, 0.1, 0.8
+ var numberOfCredentials = 2;
+ using var rnd = new SecureRandom();
+ var sk = new CredentialIssuerSecretKey(rnd);
+ var client = new WabiSabiClient(sk.ComputeCredentialIssuerParameters(), numberOfCredentials, rnd);
+ var issuer = new CredentialIssuer(sk, numberOfCredentials, rnd);
+
+ // Input Reg
+ var (zeroCredentialRequest, zeroValidationData) = client.CreateRequestForZeroAmount();
+ var zeroCredentialResponse = issuer.HandleRequest(zeroCredentialRequest);
+ client.HandleResponse(zeroCredentialResponse, zeroValidationData);
+
+ // Connection Conf
+ var (credentialRequest, validationData) = client.CreateRequest(new[] { Money.Satoshis(1), Money.Satoshis(9) }, Array.Empty<Credential>());
+ var credentialResponse = issuer.HandleRequest(credentialRequest);
+ client.HandleResponse(credentialResponse, validationData);
+
+ (zeroCredentialRequest, zeroValidationData) = client.CreateRequestForZeroAmount();
+ zeroCredentialResponse = issuer.HandleRequest(zeroCredentialRequest);
+ client.HandleResponse(zeroCredentialResponse, zeroValidationData);
+
+ // Output Reg
+ (credentialRequest, validationData) = client.CreateRequest(new[] { Money.Satoshis(1), Money.Satoshis(8) }, client.Credentials.Valuable);
+ credentialResponse = issuer.HandleRequest(credentialRequest);
+ client.HandleResponse(credentialResponse, validationData);
+ var d1 = credentialRequest.DeltaAmount;
+
+ (credentialRequest, validationData) = client.CreateRequest(new[] { Money.Satoshis(1), Money.Satoshis(7) }, client.Credentials.Valuable);
+ credentialResponse = issuer.HandleRequest(credentialRequest);
+ client.HandleResponse(credentialResponse, validationData);
+ var d2 = credentialRequest.DeltaAmount;
+
+ (credentialRequest, validationData) = client.CreateRequest(new[] { Money.Satoshis(1), Money.Satoshis(6) }, client.Credentials.Valuable);
+ credentialResponse = issuer.HandleRequest(credentialRequest);
+ client.HandleResponse(credentialResponse, validationData);
+ var d3 = credentialRequest.DeltaAmount;
+
+ (credentialRequest, validationData) = client.CreateRequest(Array.Empty<Money>(), client.Credentials.Valuable.Take(1));
+ credentialResponse = issuer.HandleRequest(credentialRequest);
+ client.HandleResponse(credentialResponse, validationData);
+ var d4 = credentialRequest.DeltaAmount;
+
+ (credentialRequest, validationData) = client.CreateRequest(Array.Empty<Money>(), client.Credentials.Valuable.Take(1));
+ credentialResponse = issuer.HandleRequest(credentialRequest);
+ client.HandleResponse(credentialResponse, validationData);
+ var d5 = credentialRequest.DeltaAmount;
+ }
+
[Fact]
[Trait("UnitTest", "UnitTest")]
public void CredentialIssuance()

MODIFY
WalletWasabi/WabiSabi/Backend/PostRequests/PostRequestHandler.cs
WalletWasabi/WabiSabi/Backend/PostRequests/PostRequestHandler.cs
@@ -25,11 +25,6 @@ namespace WalletWasabi.WabiSabi.Backend.PostRequests
throw new NotImplementedException();
}
- public CredentialReissuanceResponse ReissueCredentials(CredentialReissuanceRequest request)
- {
- throw new NotImplementedException();
- }
-
public OutputRegistrationResponse RegisterOutput(OutputRegistrationRequest request)
{
throw new NotImplementedException();

MODIFY
WalletWasabi/WabiSabi/Models/ConnectionConfirmationRequest.cs
WalletWasabi/WabiSabi/Models/ConnectionConfirmationRequest.cs
@@ -18,10 +18,27 @@ namespace WalletWasabi.WabiSabi.Models
ZeroAmountCredentialRequests = zeroAmountCredentialRequests;
RealWeightCredentialRequests = realWeightCredentialRequests;
ZeroWeightCredentialRequests = zeroWeightCredentialRequests;
+
+ if (!ZeroAmountCredentialRequests.IsNullRequest)
+ {
+ throw new InvalidOperationException("Only zero credentials can be requested.");
+ }
+ if (!ZeroWeightCredentialRequests.IsNullRequest)
+ {
+ throw new InvalidOperationException("Only zero credentials can be requested.");
}
- public Guid RoundId { get; }
+ if (RealAmountCredentialRequests.IsNullRequest)
+ {
+ throw new InvalidOperationException("Only non-zero credentials can be requested.");
+ }
+ if (RealWeightCredentialRequests.IsNullRequest)
+ {
+ throw new InvalidOperationException("Only non-zero credentials can be requested.");
+ }
+ }
+ public Guid RoundId { get; }
public Guid AliceId { get; }
public RegistrationRequestMessage RealAmountCredentialRequests { get; }
public RegistrationRequestMessage ZeroAmountCredentialRequests { get; }

MODIFY
WalletWasabi/WabiSabi/Models/ConnectionConfirmationResponse.cs
WalletWasabi/WabiSabi/Models/ConnectionConfirmationResponse.cs
@@ -9,13 +9,17 @@ namespace WalletWasabi.WabiSabi.Models
{
public class ConnectionConfirmationResponse
{
- public ConnectionConfirmationResponse(RegistrationResponseMessage amountCredentials, RegistrationResponseMessage weightCredentials)
+ public ConnectionConfirmationResponse(RegistrationResponseMessage zeroAmountCredentials, RegistrationResponseMessage zeroWeightCredentials, RegistrationResponseMessage? realAmountCredentials = null, RegistrationResponseMessage? realWeightCredentials = null)
{
- AmountCredentials = amountCredentials;
- WeightCredentials = weightCredentials;
+ ZeroAmountCredentials = zeroAmountCredentials;
+ ZeroWeightCredentials = zeroWeightCredentials;
+ RealAmountCredentials = realAmountCredentials;
+ RealWeightCredentials = realWeightCredentials;
}
- public RegistrationResponseMessage AmountCredentials { get; }
- public RegistrationResponseMessage WeightCredentials { get; }
+ public RegistrationResponseMessage ZeroAmountCredentials { get; }
+ public RegistrationResponseMessage ZeroWeightCredentials { get; }
+ public RegistrationResponseMessage? RealAmountCredentials { get; }
+ public RegistrationResponseMessage? RealWeightCredentials { get; }
}
}

DELETE
WalletWasabi/WabiSabi/Models/CredentialReissuanceRequest.cs
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using WalletWasabi.WabiSabi.Crypto;
-
-namespace WalletWasabi.WabiSabi.Models
-{
- public class CredentialReissuanceRequest
- {
- public CredentialReissuanceRequest(Guid roundId, RegistrationRequestMessage amountCredentialRequests, RegistrationRequestMessage weighCredentialRequests)
- {
- RoundId = roundId;
- AmountCredentialRequests = amountCredentialRequests;
- WeighCredentialRequests = weighCredentialRequests;
- }
-
- public Guid RoundId { get; }
- public RegistrationRequestMessage AmountCredentialRequests { get; }
- public RegistrationRequestMessage WeighCredentialRequests { get; }
- }
-}

DELETE
WalletWasabi/WabiSabi/Models/CredentialReissuanceResponse.cs
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using WalletWasabi.WabiSabi.Crypto;
-
-namespace WalletWasabi.WabiSabi.Models
-{
- public class CredentialReissuanceResponse
- {
- public CredentialReissuanceResponse(RegistrationResponseMessage amountCredentials, RegistrationResponseMessage weightCredentials)
- {
- AmountCredentials = amountCredentials;
- WeightCredentials = weightCredentials;
- }
-
- public RegistrationResponseMessage AmountCredentials { get; }
- public RegistrationResponseMessage WeightCredentials { get; }
- }
-}

MODIFY
WalletWasabi/WabiSabi/Models/InputsRegistrationRequest.cs
WalletWasabi/WabiSabi/Models/InputsRegistrationRequest.cs
@@ -16,6 +16,15 @@ namespace WalletWasabi.WabiSabi.Models
InputRoundSignaturePairs = inputRoundSignaturePairs;
ZeroAmountCredentialRequests = zeroAmountCredentialRequests;
ZeroWeightCredentialRequests = zeroWeightCredentialRequests;
+
+ if (!ZeroAmountCredentialRequests.IsNullRequest)
+ {
+ throw new InvalidOperationException("Only zero credentials can be requested.");
+ }
+ if (!ZeroWeightCredentialRequests.IsNullRequest)
+ {
+ throw new InvalidOperationException("Only zero credentials can be requested.");
+ }
}
public Guid RoundId { get; }

MODIFY
WalletWasabi/WabiSabi/Models/OutputRegistrationRequest.cs
WalletWasabi/WabiSabi/Models/OutputRegistrationRequest.cs
@@ -5,12 +5,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WalletWasabi.Crypto.ZeroKnowledge;
+using WalletWasabi.WabiSabi.Crypto;
namespace WalletWasabi.WabiSabi.Models
{
public class OutputRegistrationRequest
{
- public OutputRegistrationRequest(Guid roundId, TxOut output, IEnumerable<Credential> presentedAmountCredentials, IEnumerable<Credential> presentedWeighCredentials)
+ public OutputRegistrationRequest(Guid roundId, TxOut output, RegistrationRequestMessage presentedAmountCredentials, RegistrationRequestMessage presentedWeighCredentials)
{
RoundId = roundId;
Output = output;
@@ -20,7 +21,7 @@ namespace WalletWasabi.WabiSabi.Models
public Guid RoundId { get; }
public TxOut Output { get; }
- public IEnumerable<Credential> PresentedAmountCredentials { get; }
- public IEnumerable<Credential> PresentedWeighCredentials { get; }
+ public RegistrationRequestMessage PresentedAmountCredentials { get; }
+ public RegistrationRequestMessage PresentedWeighCredentials { get; }
}
}

MODIFY
WalletWasabi/WabiSabi/Models/OutputRegistrationResponse.cs
WalletWasabi/WabiSabi/Models/OutputRegistrationResponse.cs
@@ -3,16 +3,21 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using WalletWasabi.WabiSabi.Crypto;
namespace WalletWasabi.WabiSabi.Models
{
public class OutputRegistrationResponse
{
- public OutputRegistrationResponse(byte[] unsignedTransactionSecret)
+ public OutputRegistrationResponse(byte[] unsignedTransactionSecret, RegistrationResponseMessage amountCredentials, RegistrationResponseMessage weightCredentials)
{
UnsignedTransactionSecret = unsignedTransactionSecret;
+ AmountCredentials = amountCredentials;
+ WeightCredentials = weightCredentials;
}
public byte[] UnsignedTransactionSecret { get; }
+ public RegistrationResponseMessage AmountCredentials { get; }
+ public RegistrationResponseMessage WeightCredentials { get; }
}
}

Consolidate progress on call