Introduce derived classes to remove error checking code duplication
MODIFY
WalletWasabi.Tests/UnitTests/Wabisabi/CredentialTests.cs
WalletWasabi.Tests/UnitTests/Wabisabi/CredentialTests.cs
@@ -7,6 +7,7 @@ using WalletWasabi.Crypto.Groups;
using WalletWasabi.Crypto.Randomness;
using WalletWasabi.Crypto.ZeroKnowledge;
using WalletWasabi.WabiSabi.Crypto;
+using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
using Xunit;
namespace WalletWasabi.Tests.UnitTests.WabiSabi
@@ -192,7 +193,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi
// Test incorrect number of presentations (one instead of 3.)
var presented = validCredentialRequest.Presented.ToArray();
- var invalidCredentialRequest = new RegistrationRequestMessage(
+ var invalidCredentialRequest = new RealCredentialsRequest(
validCredentialRequest.DeltaAmount,
new[] { presented[0] }, // Should present 3 credentials.
validCredentialRequest.Requested,
@@ -204,7 +205,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi
// Test incorrect number of presentations (0 instead of 3.)
presented = credentialRequest.Presented.ToArray();
- invalidCredentialRequest = new RegistrationRequestMessage(
+ invalidCredentialRequest = new RealCredentialsRequest(
Money.Coins(2),
Array.Empty<CredentialPresentation>(), // Should present 3 credentials.
validCredentialRequest.Requested,
@@ -217,7 +218,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi
(validCredentialRequest, _) = client.CreateRequest(Array.Empty<Money>(), client.Credentials.All);
// Test incorrect number of credential requests.
- invalidCredentialRequest = new RegistrationRequestMessage(
+ invalidCredentialRequest = new RealCredentialsRequest(
validCredentialRequest.DeltaAmount,
validCredentialRequest.Presented,
validCredentialRequest.Requested.Take(1),
@@ -228,7 +229,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi
Assert.Equal("3 credential requests were expected but 1 were received.", ex.Message);
// Test incorrect number of credential requests.
- invalidCredentialRequest = new RegistrationRequestMessage(
+ invalidCredentialRequest = new RealCredentialsRequest(
Money.Coins(2),
Array.Empty<CredentialPresentation>(),
validCredentialRequest.Requested.Take(1),
@@ -241,7 +242,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi
// Test invalid range proof.
var requested = validCredentialRequest.Requested.ToArray();
- invalidCredentialRequest = new RegistrationRequestMessage(
+ invalidCredentialRequest = new RealCredentialsRequest(
validCredentialRequest.DeltaAmount,
validCredentialRequest.Presented,
new[] { requested[0], requested[1], new IssuanceRequest(requested[2].Ma, new[] { GroupElement.Infinity }) },
@@ -258,7 +259,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi
// Test invalid proofs.
var proofs = validCredentialRequest.Proofs.ToArray();
proofs[0] = proofs[1];
- var invalidCredentialRequest = new RegistrationRequestMessage(
+ var invalidCredentialRequest = new RealCredentialsRequest(
validCredentialRequest.DeltaAmount,
validCredentialRequest.Presented,
validCredentialRequest.Requested,

MODIFY
WalletWasabi.Tests/UnitTests/Wabisabi/SerializationTests.cs
WalletWasabi.Tests/UnitTests/Wabisabi/SerializationTests.cs
@@ -9,6 +9,7 @@ using WalletWasabi.Crypto.Randomness;
using WalletWasabi.JsonConverters;
using WalletWasabi.WabiSabi;
using WalletWasabi.WabiSabi.Crypto;
+using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
using WalletWasabi.WabiSabi.Crypto.Serialization;
using Xunit;
@@ -166,13 +167,13 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi
// Registration request message.
var serializedRequestMessage = JsonConvert.SerializeObject(credentialRequest, converters);
- var deserializedRequestMessage = JsonConvert.DeserializeObject<RegistrationRequestMessage>(serializedRequestMessage, converters);
+ var deserializedRequestMessage = JsonConvert.DeserializeObject<CredentialsRequest>(serializedRequestMessage, converters);
var reserializedRequestMessage = JsonConvert.SerializeObject(deserializedRequestMessage, converters);
Assert.Equal(serializedRequestMessage, reserializedRequestMessage);
// Registration response message.
var serializedResponseMessage = JsonConvert.SerializeObject(credentialResponse, converters);
- var deserializedResponseMessage = JsonConvert.DeserializeObject<RegistrationResponseMessage>(serializedResponseMessage, converters);
+ var deserializedResponseMessage = JsonConvert.DeserializeObject<CredentialsResponse>(serializedResponseMessage, converters);
var reserializedResponseMessage = JsonConvert.SerializeObject(deserializedResponseMessage, converters);
Assert.Equal(serializedResponseMessage, reserializedResponseMessage);
}

MODIFY
WalletWasabi/WabiSabi/Crypto/CredentialIssuer.cs
WalletWasabi/WabiSabi/Crypto/CredentialIssuer.cs
@@ -10,6 +10,7 @@ using WalletWasabi.Crypto.Randomness;
using WalletWasabi.Crypto.ZeroKnowledge;
using WalletWasabi.Crypto.ZeroKnowledge.LinearRelation;
using WalletWasabi.Helpers;
+using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Crypto
{
@@ -19,7 +20,7 @@ namespace WalletWasabi.WabiSabi.Crypto
/// <remarks>
/// CredentialIssuer is the coordinator's component used to issue anonymous credentials
/// requested by a WabiSabi client. This means this component abstracts receives
- /// <see cref="RegistrationRequestMessage">RegistrationRequests</see>, validates the requested
+ /// <see cref="CredentialsRequest">RegistrationRequests</see>, validates the requested
/// amounts are in the valid range, serial numbers are not duplicated nor reused,
/// and finally issues the credentials using the coordinator's secret key (and also
/// proving to the WabiSabi client that the credentials were issued with the right
@@ -32,7 +33,7 @@ namespace WalletWasabi.WabiSabi.Crypto
/// that the same instance has to be used for a given round (the coordinator needs to
/// maintain only one instance of this class per round)
///
- /// About replay requests: a replay request is a <see cref="RegistrationRequestMessage">request</see>
+ /// About replay requests: a replay request is a <see cref="CredentialsRequest">request</see>
/// that has already been seen before. These kind of requests can be the result of misbehaving
/// clients or simply clients using a retry communication mechanism.
/// Reply requests are not handled by this component and they have to be handled by a different
@@ -76,13 +77,13 @@ namespace WalletWasabi.WabiSabi.Crypto
public int NumberOfCredentials { get; }
/// <summary>
- /// Process the <see cref="RegistrationRequestMessage">credentials registration requests</see> and
+ /// Process the <see cref="CredentialsRequest">credentials registration requests</see> and
/// issues the credentials.
/// </summary>
/// <param name="registrationRequest">The request containing the credentials presentations, credential requests and the proofs.</param>
- /// <returns>The <see cref="RegistrationResponseMessage">registration response</see> containing the requested credentials and the proofs.</returns>
+ /// <returns>The <see cref="CredentialsResponse">registration response</see> containing the requested credentials and the proofs.</returns>
/// <exception cref="WabiSabiException">Error code: <see cref="WabiSabiErrorCode">WabiSabiErrorCode</see></exception>
- public RegistrationResponseMessage HandleRequest(RegistrationRequestMessage registrationRequest)
+ public CredentialsResponse HandleRequest(CredentialsRequest registrationRequest)
{
Guard.NotNull(nameof(registrationRequest), registrationRequest);
@@ -187,7 +188,7 @@ namespace WalletWasabi.WabiSabi.Crypto
// Construct response.
var proofs = ProofSystem.Prove(transcript, credentials.Select(x => x.Knowledge), RandomNumberGenerator);
var macs = credentials.Select(x => x.Mac);
- var response = new RegistrationResponseMessage(macs, proofs);
+ var response = new CredentialsResponse(macs, proofs);
// Register the serial numbers to prevent credential reuse.
foreach (var presentation in presented)

RENAME
WalletWasabi/WabiSabi/Crypto/RegistrationRequestMessage.cs
WalletWasabi/WabiSabi/Crypto/CredentialRequesting/CredentialsRequest.cs
@@ -5,7 +5,7 @@ using WalletWasabi.Crypto.Groups;
using WalletWasabi.Crypto.ZeroKnowledge;
using Newtonsoft.Json;
-namespace WalletWasabi.WabiSabi.Crypto
+namespace WalletWasabi.WabiSabi.Crypto.CredentialRequesting
{
/// <summary>
/// Represents a request message for the WabiSabi unified registration protocol.
@@ -15,10 +15,10 @@ namespace WalletWasabi.WabiSabi.Crypto
/// inputs registration and outputs registration and it is designed to support
/// credentials reissuance.
/// </remarks>
- public class RegistrationRequestMessage
+ public abstract class CredentialsRequest
{
[JsonConstructor]
- internal RegistrationRequestMessage(
+ internal CredentialsRequest(
Money deltaAmount,
IEnumerable<CredentialPresentation> presented,
IEnumerable<IssuanceRequest> requested,

RENAME
WalletWasabi/WabiSabi/Crypto/RegistrationResponseMessage.cs
WalletWasabi/WabiSabi/Crypto/CredentialRequesting/CredentialsResponse.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using WalletWasabi.Crypto;
using WalletWasabi.Crypto.ZeroKnowledge;
-namespace WalletWasabi.WabiSabi.Crypto
+namespace WalletWasabi.WabiSabi.Crypto.CredentialRequesting
{
/// <summary>
/// Represents a response message for the WabiSabi unified registration protocol.
@@ -13,9 +13,9 @@ namespace WalletWasabi.WabiSabi.Crypto
/// inputs registration and outputs registration. It contains the collection of `k` issued
/// credentials and the corresponding proofs.
/// </remarks>
- public class RegistrationResponseMessage
+ public class CredentialsResponse
{
- public RegistrationResponseMessage(IEnumerable<MAC> issuedCredentials, IEnumerable<Proof> proofs)
+ public CredentialsResponse(IEnumerable<MAC> issuedCredentials, IEnumerable<Proof> proofs)
{
IssuedCredentials = issuedCredentials;
Proofs = proofs;

RENAME
WalletWasabi/WabiSabi/Crypto/RegistrationValidationData.cs
WalletWasabi/WabiSabi/Crypto/CredentialRequesting/CredentialsResponseValidation.cs
using System.Collections.Generic;
using WalletWasabi.Crypto.ZeroKnowledge;
-namespace WalletWasabi.WabiSabi.Crypto
+namespace WalletWasabi.WabiSabi.Crypto.CredentialRequesting
{
/// <summary>
/// Maintains the state needed to validate the credentials once the coordinator
/// issues them.
/// </summary>
- public class RegistrationValidationData
+ public class CredentialsResponseValidation
{
- internal RegistrationValidationData(
+ internal CredentialsResponseValidation(
Transcript transcript,
IEnumerable<Credential> presented,
IEnumerable<IssuanceValidationData> requested)

ADD
WalletWasabi/WabiSabi/Crypto/CredentialRequesting/RealCredentialsRequest.cs
+using NBitcoin;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WalletWasabi.Crypto.ZeroKnowledge;
+
+namespace WalletWasabi.WabiSabi.Crypto.CredentialRequesting
+{
+ public class RealCredentialsRequest : CredentialsRequest
+ {
+ public RealCredentialsRequest(Money deltaAmount, IEnumerable<CredentialPresentation> presented, IEnumerable<IssuanceRequest> requested, IEnumerable<Proof> proofs) : base(deltaAmount, presented, requested, proofs)
+ {
+ if (IsNullRequest)
+ {
+ throw new InvalidOperationException($"{nameof(RealCredentialsRequest)} must not be null request.");
+ }
+ }
+ }
+}

ADD
WalletWasabi/WabiSabi/Crypto/CredentialRequesting/ZeroCredentialsRequest.cs
+using NBitcoin;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WalletWasabi.Crypto.ZeroKnowledge;
+
+namespace WalletWasabi.WabiSabi.Crypto.CredentialRequesting
+{
+ public class ZeroCredentialsRequest : CredentialsRequest
+ {
+ public ZeroCredentialsRequest(Money deltaAmount, IEnumerable<CredentialPresentation> presented, IEnumerable<IssuanceRequest> requested, IEnumerable<Proof> proofs)
+ : base(deltaAmount, presented, requested, proofs)
+ {
+ if (!IsNullRequest)
+ {
+ throw new InvalidOperationException($"{nameof(ZeroCredentialsRequest)} must be null request.");
+ }
+ }
+ }
+}

MODIFY
WalletWasabi/WabiSabi/Crypto/WabiSabiClient.cs
WalletWasabi/WabiSabi/Crypto/WabiSabiClient.cs
@@ -9,12 +9,13 @@ using WalletWasabi.Crypto.Randomness;
using WalletWasabi.Crypto.ZeroKnowledge;
using WalletWasabi.Crypto.ZeroKnowledge.LinearRelation;
using WalletWasabi.Helpers;
+using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Crypto
{
/// <summary>
- /// Provides the methods for creating <see cref="RegistrationRequestMessage">unified WabiSabi credential registration request messages</see>
- /// and for handling the <see cref="RegistrationResponseMessage">credential registration responses</see> received from the coordinator.
+ /// Provides the methods for creating <see cref="CredentialsRequest">unified WabiSabi credential registration request messages</see>
+ /// and for handling the <see cref="CredentialsResponse">credential registration responses</see> received from the coordinator.
/// </summary>
public class WabiSabiClient
{
@@ -41,7 +42,7 @@ namespace WalletWasabi.WabiSabi.Crypto
public CredentialPool Credentials { get; }
/// <summary>
- /// Creates a <see cref="RegistrationRequestMessage">credential registration request messages</see>
+ /// Creates a <see cref="CredentialsRequest">credential registration request messages</see>
/// for requesting `k` zero-value credentials.
/// </summary>
/// <remarks>
@@ -49,7 +50,7 @@ namespace WalletWasabi.WabiSabi.Crypto
/// registration request message that has to be sent to the coordinator is a null request, in this
/// way the coordinator issues `k` zero-value credentials that can be used in following requests.
/// </remarks>
- public (RegistrationRequestMessage, RegistrationValidationData) CreateRequestForZeroAmount()
+ public (CredentialsRequest, CredentialsResponseValidation) CreateRequestForZeroAmount()
{
var credentialsToRequest = new IssuanceRequest[NumberOfCredentials];
var knowledge = new Knowledge[NumberOfCredentials];
@@ -68,19 +69,19 @@ namespace WalletWasabi.WabiSabi.Crypto
var transcript = BuildTransnscript(isNullRequest: true);
return (
- new RegistrationRequestMessage(
+ new ZeroCredentialsRequest(
Money.Zero,
Enumerable.Empty<CredentialPresentation>(),
credentialsToRequest,
ProofSystem.Prove(transcript, knowledge, RandomNumberGenerator)),
- new RegistrationValidationData(
+ new CredentialsResponseValidation(
transcript,
Enumerable.Empty<Credential>(),
validationData));
}
/// <summary>
- /// Creates a <see cref="RegistrationRequestMessage">credential registration request messages</see>
+ /// Creates a <see cref="CredentialsRequest">credential registration request messages</see>
/// for requesting `k` non-zero-value credentials.
/// </summary>
/// <param name="amountsToRequest">List of amounts requested in credentials.</param>
@@ -89,7 +90,7 @@ namespace WalletWasabi.WabiSabi.Crypto
/// A tuple containing the registration request message instance and the registration validation data
/// to be used to validate the coordinator response message (the issued credentials).
/// </returns>
- public (RegistrationRequestMessage, RegistrationValidationData) CreateRequest(
+ public (CredentialsRequest, CredentialsResponseValidation) CreateRequest(
IEnumerable<Money> amountsToRequest,
IEnumerable<Credential> credentialsToPresent)
{
@@ -165,12 +166,12 @@ namespace WalletWasabi.WabiSabi.Crypto
var transcript = BuildTransnscript(isNullRequest: false);
return (
- new RegistrationRequestMessage(
+ new RealCredentialsRequest(
amountsToRequest.Sum() - credentialsToPresent.Sum(x => x.Amount.ToMoney()),
presentations,
credentialsToRequest,
ProofSystem.Prove(transcript, knowledgeToProve, RandomNumberGenerator)),
- new RegistrationValidationData(
+ new CredentialsResponseValidation(
transcript,
credentialsToPresent,
validationData));
@@ -186,7 +187,7 @@ namespace WalletWasabi.WabiSabi.Crypto
/// </remarks>
/// <param name="registrationResponse">The registration response message received from the coordinator.</param>
/// <param name="registrationValidationData">The state data required to validate the issued credentials and the proofs.</param>
- public void HandleResponse(RegistrationResponseMessage registrationResponse, RegistrationValidationData registrationValidationData)
+ public void HandleResponse(CredentialsResponse registrationResponse, CredentialsResponseValidation registrationValidationData)
{
Guard.NotNull(nameof(registrationResponse), registrationResponse);
Guard.NotNull(nameof(registrationValidationData), registrationValidationData);

MODIFY
WalletWasabi/WabiSabi/Models/ConnectionConfirmationRequest.cs
WalletWasabi/WabiSabi/Models/ConnectionConfirmationRequest.cs
@@ -4,45 +4,27 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WalletWasabi.Crypto.ZeroKnowledge;
-using WalletWasabi.WabiSabi.Crypto;
+using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Models
{
public class ConnectionConfirmationRequest
{
- public ConnectionConfirmationRequest(Guid roundId, Guid aliceId, RegistrationRequestMessage zeroAmountCredentialRequests, RegistrationRequestMessage realAmountCredentialRequests, RegistrationRequestMessage realWeightCredentialRequests, RegistrationRequestMessage zeroWeightCredentialRequests)
+ public ConnectionConfirmationRequest(Guid roundId, Guid aliceId, ZeroCredentialsRequest zeroAmountCredentialRequests, RealCredentialsRequest realAmountCredentialRequests, ZeroCredentialsRequest zeroWeightCredentialRequests, RealCredentialsRequest realWeightCredentialRequests)
{
RoundId = roundId;
AliceId = aliceId;
- RealAmountCredentialRequests = realAmountCredentialRequests;
ZeroAmountCredentialRequests = zeroAmountCredentialRequests;
- RealWeightCredentialRequests = realWeightCredentialRequests;
+ RealAmountCredentialRequests = realAmountCredentialRequests;
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.");
- }
-
- 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.");
- }
+ RealWeightCredentialRequests = realWeightCredentialRequests;
}
public Guid RoundId { get; }
public Guid AliceId { get; }
- public RegistrationRequestMessage RealAmountCredentialRequests { get; }
- public RegistrationRequestMessage ZeroAmountCredentialRequests { get; }
- public RegistrationRequestMessage RealWeightCredentialRequests { get; }
- public RegistrationRequestMessage ZeroWeightCredentialRequests { get; }
+ public ZeroCredentialsRequest ZeroAmountCredentialRequests { get; }
+ public RealCredentialsRequest RealAmountCredentialRequests { get; }
+ public ZeroCredentialsRequest ZeroWeightCredentialRequests { get; }
+ public RealCredentialsRequest RealWeightCredentialRequests { get; }
}
}

MODIFY
WalletWasabi/WabiSabi/Models/ConnectionConfirmationResponse.cs
WalletWasabi/WabiSabi/Models/ConnectionConfirmationResponse.cs
@@ -3,13 +3,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using WalletWasabi.WabiSabi.Crypto;
+using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Models
{
public class ConnectionConfirmationResponse
{
- public ConnectionConfirmationResponse(RegistrationResponseMessage zeroAmountCredentials, RegistrationResponseMessage zeroWeightCredentials, RegistrationResponseMessage? realAmountCredentials = null, RegistrationResponseMessage? realWeightCredentials = null)
+ public ConnectionConfirmationResponse(CredentialsResponse zeroAmountCredentials, CredentialsResponse zeroWeightCredentials, CredentialsResponse? realAmountCredentials = null, CredentialsResponse? realWeightCredentials = null)
{
ZeroAmountCredentials = zeroAmountCredentials;
ZeroWeightCredentials = zeroWeightCredentials;
@@ -17,9 +17,9 @@ namespace WalletWasabi.WabiSabi.Models
RealWeightCredentials = realWeightCredentials;
}
- public RegistrationResponseMessage ZeroAmountCredentials { get; }
- public RegistrationResponseMessage ZeroWeightCredentials { get; }
- public RegistrationResponseMessage? RealAmountCredentials { get; }
- public RegistrationResponseMessage? RealWeightCredentials { get; }
+ public CredentialsResponse ZeroAmountCredentials { get; }
+ public CredentialsResponse ZeroWeightCredentials { get; }
+ public CredentialsResponse? RealAmountCredentials { get; }
+ public CredentialsResponse? RealWeightCredentials { get; }
}
}

MODIFY
WalletWasabi/WabiSabi/Models/InputsRegistrationRequest.cs
WalletWasabi/WabiSabi/Models/InputsRegistrationRequest.cs
@@ -4,32 +4,23 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using WalletWasabi.WabiSabi.Crypto;
+using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Models
{
public class InputsRegistrationRequest
{
- public InputsRegistrationRequest(Guid roundId, IEnumerable<InputRoundSignaturePair> inputRoundSignaturePairs, RegistrationRequestMessage zeroAmountCredentialRequests, RegistrationRequestMessage zeroWeightCredentialRequests)
+ public InputsRegistrationRequest(Guid roundId, IEnumerable<InputRoundSignaturePair> inputRoundSignaturePairs, ZeroCredentialsRequest zeroAmountCredentialRequests, ZeroCredentialsRequest zeroWeightCredentialRequests)
{
RoundId = roundId;
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; }
public IEnumerable<InputRoundSignaturePair> InputRoundSignaturePairs { get; }
- public RegistrationRequestMessage ZeroAmountCredentialRequests { get; }
- public RegistrationRequestMessage ZeroWeightCredentialRequests { get; }
+ public ZeroCredentialsRequest ZeroAmountCredentialRequests { get; }
+ public ZeroCredentialsRequest ZeroWeightCredentialRequests { get; }
}
}

MODIFY
WalletWasabi/WabiSabi/Models/InputsRegistrationResponse.cs
WalletWasabi/WabiSabi/Models/InputsRegistrationResponse.cs
@@ -3,13 +3,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
-using WalletWasabi.WabiSabi.Crypto;
+using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Models
{
public class InputsRegistrationResponse
{
- public InputsRegistrationResponse(Guid aliceId, RegistrationResponseMessage amountCredentials, RegistrationResponseMessage weightCredentials)
+ public InputsRegistrationResponse(Guid aliceId, CredentialsResponse amountCredentials, CredentialsResponse weightCredentials)
{
AliceId = aliceId;
AmountCredentials = amountCredentials;
@@ -17,7 +17,7 @@ namespace WalletWasabi.WabiSabi.Models
}
public Guid AliceId { get; }
- public RegistrationResponseMessage AmountCredentials { get; }
- public RegistrationResponseMessage WeightCredentials { get; }
+ public CredentialsResponse AmountCredentials { get; }
+ public CredentialsResponse WeightCredentials { get; }
}
}

MODIFY
WalletWasabi/WabiSabi/Models/OutputRegistrationRequest.cs
WalletWasabi/WabiSabi/Models/OutputRegistrationRequest.cs
@@ -5,32 +5,23 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WalletWasabi.Crypto.ZeroKnowledge;
-using WalletWasabi.WabiSabi.Crypto;
+using WalletWasabi.WabiSabi.Crypto.CredentialRequesting;
namespace WalletWasabi.WabiSabi.Models
{
public class OutputRegistrationRequest
{
- public OutputRegistrationRequest(Guid roundId, TxOut output, RegistrationRequestMessage presentedAmountCredentials, RegistrationRequestMessage presentedWeighCredentials)
+ public OutputRegistrationRequest(Guid roundId, TxOut output, RealCredentialsRequest amountCredentialRequests, RealCredentialsRequest weighCredentialRequests)
{
RoundId = roundId;
Output = output;
- PresentedAmountCredentials = presentedAmountCredentials;
- PresentedWeighCredentials = presentedWeighCredentials;
-
- if (PresentedAmountCredentials.IsNullRequest)
- {
- throw new InvalidOperationException("Only non-zero credentials can be requested.");
- }
- if (PresentedWeighCredentials.IsNullRequest)
- {
- throw new InvalidOperationException("Only non-zero credentials can be requested.");
- }
+ AmountCredentialRequests = amountCredentialRequests;
+ WeighCredentialRequests = weighCredentialRequests;
}
public Guid RoundId { get; }
public TxOut Output { get; }
- public RegistrationRequestMessage PresentedAmountCredentials { get; }
- public RegistrationRequestMessage PresentedWeighCredentials { get; }
+ public RealCredentialsRequest AmountCredentialRequests { get; }
+ public RealCredentialsRequest WeighCredentialRequests { get; }
}
}

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

Introduce derived classes to remove error checking code duplication