// Given a witness and secret nonces, respond to a challenge proving the equation holds w.r.t the witness internal static ScalarVector Respond(ScalarVector witness, ScalarVector secretNonces, Scalar challenge) { // blinding terms are required in order to protect the witness (unless the // challenge is 0), so only respond if that is the case foreach (var secretNonce in secretNonces) { CryptoGuard.NotZero(nameof(secretNonce), secretNonce); } // Taking the discrete logarithms of both sides of the verification // equation with respect to G results in a formula for the response s // given k, e and x: // s = k + ex return(secretNonces + challenge * witness); }
public Proof(GroupElementVector publicNonces, IEnumerable <ScalarVector> allResponses) { CryptoGuard.NotNullOrInfinity(nameof(publicNonces), publicNonces); Guard.NotNullOrEmpty(nameof(allResponses), allResponses); // Ensure allResponses isn't jagged var n = allResponses.First().Count(); Guard.True(nameof(allResponses), allResponses.All(responses => Guard.NotNullOrEmpty(nameof(responses), responses).Count() == n)); // Ensure there is a vector of response scalars for each public nonce Guard.True(nameof(allResponses), allResponses.Count() == publicNonces.Count()); PublicNonces = publicNonces; Responses = allResponses; }
public void CommitPublicNonces(IEnumerable <GroupElement> nonces) { CryptoGuard.NotInfinity(nameof(nonces), nonces); AddMessages(NonceTag, nonces.Select(x => x.ToBytes())); }
public Statement(GroupElement publicPoint, IEnumerable <GroupElement> generators) { PublicPoint = CryptoGuard.NotNullOrInfinity(nameof(publicPoint), publicPoint); Generators = CryptoGuard.NotNullOrInfinity(nameof(generators), generators); }
public void CommitStatement(LinearRelation.Statement statement) { Guard.NotNull(nameof(statement.Generators), statement.Generators); CryptoGuard.NotNullOrInfinity(nameof(statement.PublicPoints), statement.PublicPoints); AddMessages(StatementTag, statement.PublicPoints.Select(x => x.ToBytes()).Concat(statement.Generators.Select(x => x.ToBytes()))); }