Rename methods in ProofSystem
MODIFY
WalletWasabi.Tests/UnitTests/Crypto/ProofSystemHelpers.cs
WalletWasabi.Tests/UnitTests/Crypto/ProofSystemHelpers.cs
@@ -9,7 +9,7 @@ using Xunit;
namespace WalletWasabi.Tests.UnitTests.Crypto
{
- public class ProofSystemHelpers
+ internal class ProofSystemHelpers
{
public static bool Verify(Statement statement, Proof proof)
{

MODIFY
WalletWasabi.Tests/UnitTests/Crypto/ProofSystemTests.cs
WalletWasabi.Tests/UnitTests/Crypto/ProofSystemTests.cs
@@ -34,12 +34,12 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var t = rnd.GetScalar();
var mac = MAC.ComputeMAC(coordinatorKey, Ma, t);
- var coordinatorKnowledge = ProofSystem.IssuerParameters(mac, Ma, coordinatorKey);
+ var coordinatorKnowledge = ProofSystem.IssuerParametersKnowledge(mac, Ma, coordinatorKey);
var proofOfMac = ProofSystemHelpers.Prove(coordinatorKnowledge, rnd);
// 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.IssuerParametersStmt(coordinatorParameters, mac, Ma);
+ var clientStatement = ProofSystem.IssuerParametersStatement(coordinatorParameters, mac, Ma);
var isValidProof = ProofSystemHelpers.Verify(clientStatement, proofOfMac);
Assert.True(isValidProof);
@@ -80,14 +80,14 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var credential = new Credential(amount, r, mac);
var z = rnd.GetScalar();
var randomizedCredential = credential.Present(z);
- var knowledge = ProofSystem.ShowCredential(randomizedCredential, z, credential, coordinatorParameters);
+ var knowledge = ProofSystem.ShowCredentialKnowledge(randomizedCredential, z, credential, coordinatorParameters);
var proofOfMacShow = ProofSystemHelpers.Prove(knowledge, rnd);
// The coordinator must verify the received randomized credential is valid.
var Z = randomizedCredential.ComputeZ(coordinatorKey);
Assert.Equal(Z, z * coordinatorParameters.I);
- var statement = ProofSystem.ShowCredentialStmt(randomizedCredential, Z, coordinatorParameters);
+ var statement = ProofSystem.ShowCredentialStatement(randomizedCredential, Z, coordinatorParameters);
var isValidProof = ProofSystemHelpers.Verify(statement, proofOfMacShow);
Assert.True(isValidProof);
@@ -104,16 +104,16 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var z = rnd.GetScalar();
var Ca = z * Generators.Ga + a * Generators.Gg + r * Generators.Gh;
- var knowledge = ProofSystem.BalanceProof(z, r);
+ var knowledge = ProofSystem.BalanceProofKnowledge(z, r);
var proofOfBalance = ProofSystemHelpers.Prove(knowledge, rnd);
- var statement = ProofSystem.BalanceProofStmt(Ca - a * Generators.Gg);
+ var statement = ProofSystem.BalanceProofStatement(Ca - a * Generators.Gg);
Assert.True(ProofSystemHelpers.Verify(statement, proofOfBalance));
- var badStatement = ProofSystem.BalanceProofStmt(Ca + Generators.Gg - a * Generators.Gg);
+ var badStatement = ProofSystem.BalanceProofStatement(Ca + Generators.Gg - a * Generators.Gg);
Assert.False(ProofSystemHelpers.Verify(badStatement, proofOfBalance));
- badStatement = ProofSystem.BalanceProofStmt(Ca);
+ badStatement = ProofSystem.BalanceProofStatement(Ca);
Assert.False(ProofSystemHelpers.Verify(badStatement, proofOfBalance));
}
@@ -127,13 +127,13 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var r = rnd.GetScalar();
var Ma = a * Generators.Gg + r * Generators.Gh;
- var knowledge = ProofSystem.BalanceProof(Scalar.Zero, r.Negate());
+ var knowledge = ProofSystem.BalanceProofKnowledge(Scalar.Zero, r.Negate());
var proofOfBalance = ProofSystemHelpers.Prove(knowledge, rnd);
- var statement = ProofSystem.BalanceProofStmt(a * Generators.Gg - Ma);
+ var statement = ProofSystem.BalanceProofStatement(a * Generators.Gg - Ma);
Assert.True(ProofSystemHelpers.Verify(statement, proofOfBalance));
- var badStatement = ProofSystem.BalanceProofStmt(Ma);
+ var badStatement = ProofSystem.BalanceProofStatement(Ma);
Assert.False(ProofSystemHelpers.Verify(badStatement, proofOfBalance));
}
@@ -166,14 +166,14 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var delta = new Scalar((uint)Math.Abs(presentedAmount - requestedAmount));
delta = presentedAmount > requestedAmount ? delta.Negate() : delta;
- var knowledge = ProofSystem.BalanceProof(z, r + rp.Negate());
+ var knowledge = ProofSystem.BalanceProofKnowledge(z, r + rp.Negate());
var proofOfBalance = ProofSystemHelpers.Prove(knowledge, rnd);
- var statement = ProofSystem.BalanceProofStmt(Ca + delta * Generators.Gg - Ma);
+ var statement = ProofSystem.BalanceProofStatement(Ca + delta * Generators.Gg - Ma);
Assert.True(ProofSystemHelpers.Verify(statement, proofOfBalance));
- var badStatement = ProofSystem.BalanceProofStmt(Ca + (delta + Scalar.One) * Generators.Gg - Ma);
+ var badStatement = ProofSystem.BalanceProofStatement(Ca + (delta + Scalar.One) * Generators.Gg - Ma);
Assert.False(ProofSystemHelpers.Verify(badStatement, proofOfBalance));
}
@@ -203,15 +203,15 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var commitment = amountScalar * Generators.Gg + randomness * Generators.Gh;
var maskedScalar = new Scalar(amount & ((1ul << width) - 1));
- var (knowledge, bitCommitments) = ProofSystem.RangeProof(maskedScalar, randomness, width, rnd);
+ var (knowledge, bitCommitments) = ProofSystem.RangeProofKnowledge(maskedScalar, randomness, width, rnd);
var rangeProof = ProofSystemHelpers.Prove(knowledge, rnd);
- Assert.Equal(pass, ProofSystemHelpers.Verify(ProofSystem.RangeProofStmt(commitment, bitCommitments), rangeProof));
+ Assert.Equal(pass, ProofSystemHelpers.Verify(ProofSystem.RangeProofStatement(commitment, bitCommitments), rangeProof));
if (!pass)
{
- Assert.Throws<ArgumentException>(() => ProofSystem.RangeProof(amountScalar, randomness, width, rnd));
+ Assert.Throws<ArgumentException>(() => ProofSystem.RangeProofKnowledge(amountScalar, randomness, width, rnd));
}
}
@@ -231,16 +231,16 @@ namespace WalletWasabi.Tests.UnitTests.Crypto
var knowledge = new[]
{
- ProofSystem.ZeroProof(Ma0, r0),
- ProofSystem.ZeroProof(Ma1, r1)
+ ProofSystem.ZeroProofKnowledge(Ma0, r0),
+ ProofSystem.ZeroProofKnowledge(Ma1, r1)
};
var proofs = ProofSystem.Prove(new Transcript(new byte[0]), knowledge, rnd);
var statements = new[]
{
- ProofSystem.ZeroProofStmt(Ma0),
- ProofSystem.ZeroProofStmt(Ma1)
+ ProofSystem.ZeroProofStatement(Ma0),
+ ProofSystem.ZeroProofStatement(Ma1)
};
Assert.True(ProofSystem.Verify(new Transcript(new byte[0]), statements, proofs));

MODIFY
WalletWasabi/Crypto/ZeroKnowledge/ProofSystem.cs
WalletWasabi/Crypto/ZeroKnowledge/ProofSystem.cs
@@ -8,7 +8,7 @@ using WalletWasabi.Helpers;
namespace WalletWasabi.Crypto.ZeroKnowledge
{
- public partial class ProofSystem
+ internal partial class ProofSystem
{
private static GroupElement O = GroupElement.Infinity;
@@ -86,10 +86,10 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
return Enumerable.Zip(statements, proofs, (s, p) => s.CheckVerificationEquation(p.PublicNonces, challenge, p.Responses)).All(x => x);
}
- public static Knowledge IssuerParameters(MAC mac, GroupElement ma, CoordinatorSecretKey sk)
- => new Knowledge(IssuerParametersStmt(sk.ComputeCoordinatorParameters(), mac, ma), new ScalarVector(sk.W, sk.Wp, sk.X0, sk.X1, sk.Ya));
+ public static Knowledge IssuerParametersKnowledge(MAC mac, GroupElement ma, CoordinatorSecretKey sk)
+ => new Knowledge(IssuerParametersStatement(sk.ComputeCoordinatorParameters(), mac, ma), new ScalarVector(sk.W, sk.Wp, sk.X0, sk.X1, sk.Ya));
- public static Statement IssuerParametersStmt(CoordinatorParameters iparams, MAC mac, GroupElement ma)
+ public static Statement IssuerParametersStatement(CoordinatorParameters iparams, MAC mac, GroupElement ma)
=> new Statement(new GroupElement[,]
{
// public Witness terms:
@@ -99,12 +99,12 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
{ iparams.Cw, Generators.Gw, Generators.Gwp, O, O, O },
});
- public static Knowledge ShowCredential(CredentialPresentation presentation, Scalar z, Credential credential, CoordinatorParameters iparams)
+ public static Knowledge ShowCredentialKnowledge(CredentialPresentation presentation, Scalar z, Credential credential, CoordinatorParameters iparams)
=> new Knowledge(
- ShowCredentialStmt(presentation, z * iparams.I, iparams),
+ ShowCredentialStatement(presentation, z * iparams.I, iparams),
new ScalarVector(z, (credential.Mac.T * z).Negate(), credential.Mac.T, credential.Amount, credential.Randomness));
- public static Statement ShowCredentialStmt(CredentialPresentation c, GroupElement Z, CoordinatorParameters iparams)
+ public static Statement ShowCredentialStatement(CredentialPresentation c, GroupElement Z, CoordinatorParameters iparams)
=> new Statement(new GroupElement[,]
{
// public Witness terms:
@@ -115,24 +115,24 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
{ c.S, O, O, O, O, Generators.Gs }
});
- public static Knowledge BalanceProof(Scalar zSum, Scalar rDeltaSum)
- => new Knowledge(BalanceProofStmt(zSum * Generators.Ga + rDeltaSum * Generators.Gh), new ScalarVector(zSum, rDeltaSum));
+ public static Knowledge BalanceProofKnowledge(Scalar zSum, Scalar rDeltaSum)
+ => new Knowledge(BalanceProofStatement(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 BalanceProofStmt(GroupElement balanceCommitment)
+ public static Statement BalanceProofStatement(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(ZeroProofStmt(ma), new ScalarVector(r));
+ public static Knowledge ZeroProofKnowledge(GroupElement ma, Scalar r)
+ => new Knowledge(ZeroProofStatement(ma), new ScalarVector(r));
// TODO swap return value order, remove GroupElement argument
// expect nonce provider instead of WasabiRandom?
- public static (Knowledge knowledge, IEnumerable<GroupElement> bitCommitments) RangeProof(Scalar a, Scalar r, int width, WasabiRandom rnd)
+ public static (Knowledge knowledge, IEnumerable<GroupElement> bitCommitments) RangeProofKnowledge(Scalar a, Scalar r, int width, WasabiRandom rnd)
{
var ma = a * Generators.Gg + r * Generators.Gh;
var bits = Enumerable.Range(0, width).Select(i => a.GetBits(i, 1) == 0 ? Scalar.Zero : Scalar.One);
@@ -167,16 +167,16 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
witness[ProductColumn(i)] = r_i * b_i;
}
- return (new Knowledge(RangeProofStmt(ma, bitCommitments), new ScalarVector(witness)), bitCommitments);
+ return (new Knowledge(RangeProofStatement(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 ZeroProofStmt(GroupElement ma)
- => RangeProofStmt(ma, new GroupElement[0]);
+ public static Statement ZeroProofStatement(GroupElement ma)
+ => RangeProofStatement(ma, new GroupElement[0]);
- public static Statement RangeProofStmt(GroupElement ma, IEnumerable<GroupElement> bitCommitments)
+ public static Statement RangeProofStatement(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
@@ -136,7 +136,7 @@ namespace WalletWasabi.Wabisabi
var Z = presentation.ComputeZ(CoordinatorSecretKey);
// Add the credential presentation to the statements to be verified.
- statements.Add(ProofSystem.ShowCredentialStmt(presentation, Z, CoordinatorParameters));
+ statements.Add(ProofSystem.ShowCredentialStatement(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
@@ -151,8 +151,8 @@ namespace WalletWasabi.Wabisabi
foreach (var credentialRequest in requested)
{
statements.Add(registrationRequest.IsNullRequest
- ? ProofSystem.ZeroProofStmt(credentialRequest.Ma)
- : ProofSystem.RangeProofStmt(credentialRequest.Ma, credentialRequest.BitCommitments));
+ ? ProofSystem.ZeroProofStatement(credentialRequest.Ma)
+ : ProofSystem.RangeProofStatement(credentialRequest.Ma, credentialRequest.BitCommitments));
}
// Balance proof
@@ -169,7 +169,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.BalanceProofStmt(balanceTweak + sumCa - sumMa));
+ statements.Add(ProofSystem.BalanceProofStatement(balanceTweak + sumCa - sumMa));
}
var transcript = BuildTransnscript(registrationRequest.IsNullRequest);
@@ -203,7 +203,7 @@ namespace WalletWasabi.Wabisabi
{
var sk = CoordinatorSecretKey;
var mac = MAC.ComputeMAC(sk, ma, t);
- var knowledge = ProofSystem.IssuerParameters(mac, ma, sk);
+ var knowledge = ProofSystem.IssuerParametersKnowledge(mac, ma, sk);
return (mac, knowledge);
}

MODIFY
WalletWasabi/Wabisabi/WabiSabiClient.cs
WalletWasabi/Wabisabi/WabiSabiClient.cs
@@ -60,7 +60,7 @@ namespace WalletWasabi.Wabisabi
var randomness = RandomNumberGenerator.GetScalar(allowZero: false);
var Ma = randomness * Generators.Gh;
- knowledge[i] = ProofSystem.ZeroProof(Ma, randomness);
+ knowledge[i] = ProofSystem.ZeroProofKnowledge(Ma, randomness);
credentialsToRequest[i] = new IssuanceRequest(Ma, Enumerable.Empty<GroupElement>());
validationData[i] = new IssuanceValidationData(Money.Zero, randomness, Ma);
}
@@ -131,7 +131,7 @@ namespace WalletWasabi.Wabisabi
var z = RandomNumberGenerator.GetScalar();
var presentation = credential.Present(z);
presentations.Add(presentation);
- knowledgeToProve.Add(ProofSystem.ShowCredential(presentation, z, credential, CoordinatorParameters));
+ knowledgeToProve.Add(ProofSystem.ShowCredentialKnowledge(presentation, z, credential, CoordinatorParameters));
zs.Add(z);
}
@@ -146,7 +146,7 @@ namespace WalletWasabi.Wabisabi
var randomness = RandomNumberGenerator.GetScalar(allowZero: false);
var Ma = scalarAmount * Generators.Gg + randomness * Generators.Gh;
- var (rangeKnowledge, bitCommitments) = ProofSystem.RangeProof(scalarAmount, randomness, Constants.RangeProofWidth, RandomNumberGenerator);
+ var (rangeKnowledge, bitCommitments) = ProofSystem.RangeProofKnowledge(scalarAmount, randomness, Constants.RangeProofWidth, RandomNumberGenerator);
knowledgeToProve.Add(rangeKnowledge);
var credentialRequest = new IssuanceRequest(Ma, bitCommitments);
@@ -160,7 +160,7 @@ namespace WalletWasabi.Wabisabi
var r = validationData.Select(x => x.Randomness).Sum();
var deltaR = cr + r.Negate();
- var balanceKnowledge = ProofSystem.BalanceProof(sumOfZ, deltaR);
+ var balanceKnowledge = ProofSystem.BalanceProofKnowledge(sumOfZ, deltaR);
knowledgeToProve.Add(balanceKnowledge);
var transcript = BuildTransnscript(isNullRequest: false);
@@ -206,7 +206,7 @@ namespace WalletWasabi.Wabisabi
.ToArray();
var statements = credentials
- .Select(x => ProofSystem.IssuerParametersStmt(CoordinatorParameters, x.Issued, x.Requested.Ma));
+ .Select(x => ProofSystem.IssuerParametersStatement(CoordinatorParameters, x.Issued, x.Requested.Ma));
var areCorrectlyIssued = ProofSystem.Verify(registrationValidationData.Transcript, statements, registrationResponse.Proofs);
if (!areCorrectlyIssued)

Rename methods in ProofSystem