Use new credential type
MODIFY
WalletWasabi.Tests/UnitTests/Crypto/ProofSystemTests.cs
WalletWasabi.Tests/UnitTests/Crypto/ProofSystemTests.cs
@@ -81,7 +81,7 @@ 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, mac.T, amount, r, coordinatorParameters);
+ var knowledge = ProofSystem.ShowCredential(randomizedCredential, z, credential, coordinatorParameters);
var proofOfMacShow = ProofSystem.Prove(knowledge, rnd);
// The coordinator must verify the received randomized credential is valid.

MODIFY
WalletWasabi/Crypto/ZeroKnowledge/Credential.cs
WalletWasabi/Crypto/ZeroKnowledge/Credential.cs
@@ -12,11 +12,19 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
Mac = mac;
}
- public Scalar Amount { get; } // could consider uint, but only really makes sense for credential requests because of range proofs
+ public Scalar Amount { get; }
public Scalar Randomness { get; }
public MAC Mac { get; }
public CredentialPresentation Present(Scalar z)
- => CredentialPresentation.FromMAC(Mac, z, Amount, Randomness);
+ {
+ GroupElement Randomize(GroupElement G, GroupElement M) => M + z * G;
+ return new CredentialPresentation(
+ Ca: Randomize(Generators.Ga, Amount * Generators.Gg + Randomness * Generators.Gh),
+ Cx0: Randomize(Generators.Gx0, Mac.U),
+ Cx1: Randomize(Generators.Gx1, Mac.T * Mac.U),
+ CV: Randomize(Generators.GV, Mac.V),
+ S: Randomness * Generators.Gs);
+ }
}
}

MODIFY
WalletWasabi/Crypto/ZeroKnowledge/ProofSystem.cs
WalletWasabi/Crypto/ZeroKnowledge/ProofSystem.cs
@@ -42,8 +42,10 @@ namespace WalletWasabi.Crypto.ZeroKnowledge
{ iparams.Cw, Generators.Gw, Generators.Gwp, O, O, O },
});
- public static Knowledge ShowCredential(CredentialPresentation c, Scalar z, Scalar t, Scalar a, Scalar r, CoordinatorParameters iparams)
- => new Knowledge(ShowCredential(c, z * iparams.I, iparams), new ScalarVector(z, (t * z).Negate(), t, a, r));
+ public static Knowledge ShowCredential(CredentialPresentation c, Scalar z, Credential credential, CoordinatorParameters iparams)
+ => new Knowledge(
+ ShowCredential(c, 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)
=> new Statement(new GroupElement[,]

Use new credential type