public async Task <ArenaResponse <Guid> > RegisterInputAsync( uint256 roundId, OutPoint outPoint, Key key, CancellationToken cancellationToken) { var ownershipProof = OwnershipProof.GenerateCoinJoinInputProof( key, new CoinJoinInputCommitmentData("CoinJoinCoordinatorIdentifier", roundId)); var zeroAmountCredentialRequestData = AmountCredentialClient.CreateRequestForZeroAmount(); var zeroVsizeCredentialRequestData = VsizeCredentialClient.CreateRequestForZeroAmount(); var inputRegistrationResponse = await RequestHandler.RegisterInputAsync( new InputRegistrationRequest( roundId, outPoint, ownershipProof, zeroAmountCredentialRequestData.CredentialsRequest, zeroVsizeCredentialRequestData.CredentialsRequest), cancellationToken).ConfigureAwait(false); var realAmountCredentials = AmountCredentialClient.HandleResponse(inputRegistrationResponse.AmountCredentials, zeroAmountCredentialRequestData.CredentialsResponseValidation); var realVsizeCredentials = VsizeCredentialClient.HandleResponse(inputRegistrationResponse.VsizeCredentials, zeroVsizeCredentialRequestData.CredentialsResponseValidation); return(new(inputRegistrationResponse.AliceId, realAmountCredentials, realVsizeCredentials)); }
public async Task <ArenaResponse> ReissueCredentialAsync( uint256 roundId, IEnumerable <long> amountsToRequest, IEnumerable <long> vsizesToRequest, IEnumerable <Credential> amountCredentialsToPresent, IEnumerable <Credential> vsizeCredentialsToPresent, CancellationToken cancellationToken) { Guard.InRange(nameof(amountCredentialsToPresent), amountCredentialsToPresent, 0, AmountCredentialClient.NumberOfCredentials); var presentedAmount = amountCredentialsToPresent.Sum(x => x.Value); if (amountsToRequest.Sum() != presentedAmount) { throw new InvalidOperationException($"Reissuance amounts sum must equal the sum of the presented ones."); } var presentedVsize = vsizeCredentialsToPresent.Sum(x => x.Value); if (vsizesToRequest.Sum() > presentedVsize) { throw new InvalidOperationException($"Reissuance vsizes sum can not be greater than the sum of the presented ones."); } var(realVsizeCredentialRequest, realVsizeCredentialResponseValidation) = VsizeCredentialClient.CreateRequest( vsizesToRequest, vsizeCredentialsToPresent, cancellationToken); var(realAmountCredentialRequest, realAmountCredentialResponseValidation) = AmountCredentialClient.CreateRequest( amountsToRequest, amountCredentialsToPresent, cancellationToken); var zeroAmountCredentialRequestData = AmountCredentialClient.CreateRequestForZeroAmount(); var zeroVsizeCredentialRequestData = VsizeCredentialClient.CreateRequestForZeroAmount(); var reissuanceResponse = await RequestHandler.ReissuanceAsync( new ReissueCredentialRequest( roundId, realAmountCredentialRequest, realVsizeCredentialRequest, zeroAmountCredentialRequestData.CredentialsRequest, zeroVsizeCredentialRequestData.CredentialsRequest), cancellationToken).ConfigureAwait(false); var realAmountCredentials = AmountCredentialClient.HandleResponse(reissuanceResponse.RealAmountCredentials, realAmountCredentialResponseValidation); var realVsizeCredentials = VsizeCredentialClient.HandleResponse(reissuanceResponse.RealVsizeCredentials, realVsizeCredentialResponseValidation); var zeroAmountCredentials = AmountCredentialClient.HandleResponse(reissuanceResponse.ZeroAmountCredentials, zeroAmountCredentialRequestData.CredentialsResponseValidation); var zeroVsizeCredentials = VsizeCredentialClient.HandleResponse(reissuanceResponse.ZeroVsizeCredentials, zeroVsizeCredentialRequestData.CredentialsResponseValidation); return(new(realAmountCredentials.Concat(zeroAmountCredentials), realVsizeCredentials.Concat(zeroVsizeCredentials))); }
public async Task <ArenaResponse <bool> > ConfirmConnectionAsync( uint256 roundId, Guid aliceId, IEnumerable <long> amountsToRequest, IEnumerable <long> vsizesToRequest, IEnumerable <Credential> amountCredentialsToPresent, IEnumerable <Credential> vsizeCredentialsToPresent, CancellationToken cancellationToken) { Guard.InRange(nameof(amountsToRequest), amountsToRequest, 1, ProtocolConstants.CredentialNumber); Guard.InRange(nameof(amountCredentialsToPresent), amountCredentialsToPresent, 0, ProtocolConstants.CredentialNumber); Guard.InRange(nameof(vsizeCredentialsToPresent), vsizeCredentialsToPresent, 0, ProtocolConstants.CredentialNumber); Guard.InRange(nameof(vsizesToRequest), vsizesToRequest, 1, VsizeCredentialClient.NumberOfCredentials); var realAmountCredentialRequestData = AmountCredentialClient.CreateRequest( amountsToRequest, amountCredentialsToPresent, cancellationToken); var realVsizeCredentialRequestData = VsizeCredentialClient.CreateRequest( vsizesToRequest, vsizeCredentialsToPresent, cancellationToken); var zeroAmountCredentialRequestData = AmountCredentialClient.CreateRequestForZeroAmount(); var zeroVsizeCredentialRequestData = VsizeCredentialClient.CreateRequestForZeroAmount(); var confirmConnectionResponse = await RequestHandler.ConfirmConnectionAsync( new ConnectionConfirmationRequest( roundId, aliceId, zeroAmountCredentialRequestData.CredentialsRequest, realAmountCredentialRequestData.CredentialsRequest, zeroVsizeCredentialRequestData.CredentialsRequest, realVsizeCredentialRequestData.CredentialsRequest), cancellationToken).ConfigureAwait(false); var zeroAmountCredentials = AmountCredentialClient.HandleResponse(confirmConnectionResponse.ZeroAmountCredentials, zeroAmountCredentialRequestData.CredentialsResponseValidation); var zeroVsizeCredentials = VsizeCredentialClient.HandleResponse(confirmConnectionResponse.ZeroVsizeCredentials, zeroVsizeCredentialRequestData.CredentialsResponseValidation); if (confirmConnectionResponse is { RealAmountCredentials : { }, RealVsizeCredentials : { } })
public async Task <(ArenaResponse <Guid> ArenaResponse, bool IsPayingZeroCoordinationFee)> RegisterInputAsync( uint256 roundId, OutPoint outPoint, OwnershipProof ownershipProof, CancellationToken cancellationToken) { var zeroAmountCredentialRequestData = AmountCredentialClient.CreateRequestForZeroAmount(); var zeroVsizeCredentialRequestData = VsizeCredentialClient.CreateRequestForZeroAmount(); var inputRegistrationResponse = await RequestHandler.RegisterInputAsync( new InputRegistrationRequest( roundId, outPoint, ownershipProof, zeroAmountCredentialRequestData.CredentialsRequest, zeroVsizeCredentialRequestData.CredentialsRequest), cancellationToken).ConfigureAwait(false); var realAmountCredentials = AmountCredentialClient.HandleResponse(inputRegistrationResponse.AmountCredentials, zeroAmountCredentialRequestData.CredentialsResponseValidation); var realVsizeCredentials = VsizeCredentialClient.HandleResponse(inputRegistrationResponse.VsizeCredentials, zeroVsizeCredentialRequestData.CredentialsResponseValidation); return(new(inputRegistrationResponse.AliceId, realAmountCredentials, realVsizeCredentials), inputRegistrationResponse.IsPayingZeroCoordinationFee); }