Distinguish statement from knowledge methods
MODIFY
WalletWasabi.Tests/UnitTests/Crypto/ProofSystemTests.cs
WalletWasabi.Tests/UnitTests/Crypto/ProofSystemTests.cs
@@ -39,7 +39,7 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
// The client receives the MAC and the proofOfMac which let the client know that the MAC
// was generated with the coordinator's secret key.
- var clientStatement = ProofSystem.IssuerParameters(coordinatorParameters, mac, Ma);
+ var clientStatement = ProofSystem.IssuerParametersStmt(coordinatorParameters, mac, Ma);
var isValidProof = ProofSystemHelpers.Verify(clientStatement, proofOfMac);
Assert.True(isValidProof);
@@ -87,7 +87,7 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var Z = randomizedCredential.ComputeZ(coordinatorKey);
Assert.Equal(Z, z * coordinatorParameters.I);
- var statement = ProofSystem.ShowCredential(randomizedCredential, Z, coordinatorParameters);
+ var statement = ProofSystem.ShowCredentialStmt(randomizedCredential, Z, coordinatorParameters);
var isValidProof = ProofSystemHelpers.Verify(statement, proofOfMacShow);
Assert.True(isValidProof);
@@ -107,13 +107,13 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var knowledge = ProofSystem.BalanceProof(z, r);
var proofOfBalance = ProofSystemHelpers.Prove(knowledge, rnd);
- var statement = ProofSystem.BalanceProof(Ca - a * Generators.Gg);
+ var statement = ProofSystem.BalanceProofStmt(Ca - a * Generators.Gg);
Assert.True(ProofSystemHelpers.Verify(statement, proofOfBalance));
- var badStatement = ProofSystem.BalanceProof(Ca + Generators.Gg - a * Generators.Gg);
+ var badStatement = ProofSystem.BalanceProofStmt(Ca + Generators.Gg - a * Generators.Gg);
Assert.False(ProofSystemHelpers.Verify(badStatement, proofOfBalance));
- badStatement = ProofSystem.BalanceProof(Ca);
+ badStatement = ProofSystem.BalanceProofStmt(Ca);
Assert.False(ProofSystemHelpers.Verify(badStatement, proofOfBalance));
}
@@ -130,10 +130,10 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var knowledge = ProofSystem.BalanceProof(Scalar.Zero, r.Negate());
var proofOfBalance = ProofSystemHelpers.Prove(knowledge, rnd);
- var statement = ProofSystem.BalanceProof(a * Generators.Gg - Ma);
+ var statement = ProofSystem.BalanceProofStmt(a * Generators.Gg - Ma);
Assert.True(ProofSystemHelpers.Verify(statement, proofOfBalance));
- var badStatement = ProofSystem.BalanceProof(Ma);
+ var badStatement = ProofSystem.BalanceProofStmt(Ma);
Assert.False(ProofSystemHelpers.Verify(badStatement, proofOfBalance));
}
@@ -170,10 +170,10 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var proofOfBalance = ProofSystemHelpers.Prove(knowledge, rnd);
- var statement = ProofSystem.BalanceProof(Ca + delta * Generators.Gg - Ma);
+ var statement = ProofSystem.BalanceProofStmt(Ca + delta * Generators.Gg - Ma);
Assert.True(ProofSystemHelpers.Verify(statement, proofOfBalance));
- var badStatement = ProofSystem.BalanceProof(Ca + (delta + Scalar.One) * Generators.Gg - Ma);
+ var badStatement = ProofSystem.BalanceProofStmt(Ca + (delta + Scalar.One) * Generators.Gg - Ma);
Assert.False(ProofSystemHelpers.Verify(badStatement, proofOfBalance));
}
@@ -207,7 +207,7 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var rangeProof = ProofSystemHelpers.Prove(knowledge, rnd);
- Assert.Equal(pass, ProofSystemHelpers.Verify(ProofSystem.RangeProof(commitment, bitCommitments), rangeProof));
+ Assert.Equal(pass, ProofSystemHelpers.Verify(ProofSystem.RangeProofStmt(commitment, bitCommitments), rangeProof));
if (!pass)
{
@@ -239,8 +239,8 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var statements = new[]
{
- ProofSystem.ZeroProof(Ma0),
- ProofSystem.ZeroProof(Ma1)
+ ProofSystem.ZeroProofStmt(Ma0),
+ ProofSystem.ZeroProofStmt(Ma1)
};
Assert.True(ProofSystem.Verify(new Transcript(new byte[0]), statements, proofs));

MODIFY
WalletWasabi/Crypto/ZeroKnowledge/ProofSystem.cs
WalletWasabi/Crypto/ZeroKnowledge/ProofSystem.cs
-using NBitcoin.Secp256k1;
-using System.Collections.Generic;
using System.Linq;
+using System.Collections.Generic;
+using NBitcoin.Secp256k1;
using WalletWasabi.Crypto.Groups;
using WalletWasabi.Crypto.Randomness;
using WalletWasabi.Crypto.ZeroKnowledge.LinearRelation;
@@ -8,7 +8,7 @@ using WalletWasabi.Helpers;
namespace WalletWasabi.Crypto.ZeroKnowledge
{
- public static partial class ProofSystem
+ public partial class ProofSystem
{
private static GroupElement O = GroupElement.Infinity;
@@ -87,9 +87,9 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
}
public static Knowledge IssuerParameters(MAC mac, GroupElement ma, CoordinatorSecretKey sk)
- => new Knowledge(IssuerParameters(sk.ComputeCoordinatorParameters(), mac, ma), new ScalarVector(sk.W, sk.Wp, sk.X0, sk.X1, sk.Ya));
+ => new Knowledge(IssuerParametersStmt(sk.ComputeCoordinatorParameters(), mac, ma), new ScalarVector(sk.W, sk.Wp, sk.X0, sk.X1, sk.Ya));
- public static Statement IssuerParameters(CoordinatorParameters iparams, MAC mac, GroupElement ma)
+ public static Statement IssuerParametersStmt(CoordinatorParameters iparams, MAC mac, GroupElement ma)
=> new Statement(new GroupElement[,]
{
// public Witness terms:
@@ -101,10 +101,10 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
public static Knowledge ShowCredential(CredentialPresentation presentation, Scalar z, Credential credential, CoordinatorParameters iparams)
=> new Knowledge(
- ShowCredential(presentation, z * iparams.I, iparams),
+ ShowCredentialStmt(presentation, z * iparams.I, iparams),
new ScalarVector(z, (credential.Mac.T * z).Negate(), credential.Mac.T, credential.Amount, credential.Randomness));
- public static Statement ShowCredential(CredentialPresentation c, GroupElement Z, CoordinatorParameters iparams)
+ public static Statement ShowCredentialStmt(CredentialPresentation c, GroupElement Z, CoordinatorParameters iparams)
=> new Statement(new GroupElement[,]
{
// public Witness terms:
@@ -116,19 +116,19 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
});
public static Knowledge BalanceProof(Scalar zSum, Scalar rDeltaSum)
- => new Knowledge(BalanceProof(zSum * Generators.Ga + rDeltaSum * Generators.Gh), new ScalarVector(zSum, rDeltaSum));
+ => new Knowledge(BalanceProofStmt(zSum * Generators.Ga + rDeltaSum * Generators.Gh), new ScalarVector(zSum, rDeltaSum));
// Balance commitment must be a commitment to 0, with randomness in Gh and
// additional randomness from attribute randomization in Show protocol,
// using generator Ga. Witness terms: (\sum z, \sum r_i - r'_i)
- public static Statement BalanceProof(GroupElement balanceCommitment)
+ public static Statement BalanceProofStmt(GroupElement balanceCommitment)
=> new Statement(balanceCommitment, Generators.Ga, Generators.Gh);
// overload for bootstrap credential request proofs.
// this is just a range proof with width=0
// equivalent to proof of representation w/ Gh
public static Knowledge ZeroProof(GroupElement ma, Scalar r)
- => new Knowledge(ZeroProof(ma), new ScalarVector(r));
+ => new Knowledge(ZeroProofStmt(ma), new ScalarVector(r));
// TODO swap return value order, remove GroupElement argument
// expect nonce provider instead of WasabiRandom?
@@ -167,16 +167,16 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
witness[ProductColumn(i)] = r_i * b_i;
}
- return (new Knowledge(RangeProof(ma, bitCommitments), new ScalarVector(witness)), bitCommitments);
+ return (new Knowledge(RangeProofStmt(ma, bitCommitments), new ScalarVector(witness)), bitCommitments);
}
// overload for bootstrap credential request proofs.
// this is just a range proof with width=0
// equivalent to new Statement(ma, Generators.Gh)
- public static Statement ZeroProof(GroupElement ma)
- => RangeProof(ma, new GroupElement[0]);
+ public static Statement ZeroProofStmt(GroupElement ma)
+ => RangeProofStmt(ma, new GroupElement[0]);
- public static Statement RangeProof(GroupElement ma, IEnumerable<GroupElement> bitCommitments)
+ public static Statement RangeProofStmt(GroupElement ma, IEnumerable<GroupElement> bitCommitments)
{
var width = bitCommitments.Count(); // can be 0
Guard.InRangeAndNotNull(nameof(width), width, 0, Constants.RangeProofWidth);

MODIFY
WalletWasabi/Wabisabi/CredentialIssuer.cs
WalletWasabi/Wabisabi/CredentialIssuer.cs
@@ -94,7 +94,7 @@ namespace WalletWasabi.Wabisabi
var Z = presentation.ComputeZ(CoordinatorSecretKey);
// Add the credential presentation to the statements to be verified.
- statements.Add(ProofSystem.ShowCredential(presentation, Z, CoordinatorParameters));
+ statements.Add(ProofSystem.ShowCredentialStmt(presentation, Z, CoordinatorParameters));
// Check if the serial numbers have been used before. Note that
// the serial numbers have not yet been verified at this point, but a
@@ -109,8 +109,8 @@ namespace WalletWasabi.Wabisabi
foreach (var credentialRequest in requested)
{
statements.Add(registrationRequest.IsNullRequest
- ? ProofSystem.ZeroProof(credentialRequest.Ma)
- : ProofSystem.RangeProof(credentialRequest.Ma, credentialRequest.BitCommitments));
+ ? ProofSystem.ZeroProofStmt(credentialRequest.Ma)
+ : ProofSystem.RangeProofStmt(credentialRequest.Ma, credentialRequest.BitCommitments));
}
// Balance proof
@@ -127,7 +127,7 @@ namespace WalletWasabi.Wabisabi
var absAmountDelta = new Scalar(registrationRequest.DeltaAmount.Abs());
var deltaA = registrationRequest.DeltaAmount < Money.Zero ? absAmountDelta.Negate() : absAmountDelta;
var balanceTweak = deltaA * Generators.Gg;
- statements.Add(ProofSystem.BalanceProof(balanceTweak + sumCa - sumMa));
+ statements.Add(ProofSystem.BalanceProofStmt(balanceTweak + sumCa - sumMa));
}
var transcript = BuildTransnscript(registrationRequest.IsNullRequest);

MODIFY
WalletWasabi/Wabisabi/WabiSabiClient.cs
WalletWasabi/Wabisabi/WabiSabiClient.cs
@@ -170,7 +170,7 @@ namespace WalletWasabi.Wabisabi
.ToArray();
var statements = credentials
- .Select(x => ProofSystem.IssuerParameters(CoordinatorParameters, x.Issued, x.Requested.Ma));
+ .Select(x => ProofSystem.IssuerParametersStmt(CoordinatorParameters, x.Issued, x.Requested.Ma));
var areCorrectlyIssued = ProofSystem.Verify(registrationValidationData.Transcript, statements, registrationResponse.Proofs);
if (!areCorrectlyIssued)

Distinguish statement from knowledge methods