cryptobiu / libscapi

Comprehensive Open Source Library for Secure Multiparty Computation
MIT License
180 stars 66 forks source link

Error using AND compositions for Sigma protocols #72

Open Ruth1993 opened 4 years ago

Ruth1993 commented 4 years ago

Hello,

Could anyone help me with the following problem? I want to use AND compositions for Sigma protocols, but I'm getting the following error:

src/primitives/Dlog.cpp:414: virtual void ECElementSendableData::initFromString(const string&): Assertionstr_vec.size() == 2' failed.`

This is my (simplified) code:

Prover class:

auto dlog = make_shared<OpenSSLDlogECF2m>("K-233");
auto g = dlog->getGenerator();
vector<shared_ptr<SigmaProverComputation>> provers;

provers.push_back(make_shared<SigmaDlogProverComputation>(dlog, 40));

ZKFromSigmaProver prover(channel, make_shared<SigmaANDProverComputation>(provers, 40));
biginteger q = dlog->getOrder();
biginteger r = 5;
auto co1 = dlog->exponentiate(g.get(), r);

vector<shared_ptr<SigmaProverInput>> inputs;

inputs.push_back(make_shared<SigmaDlogProverInput>(co1, r));

shared_ptr<SigmaMultipleProverInput> input = make_shared<SigmaMultipleProverInput>(inputs);
prover.prove(input);

Verifier class:

auto dlog = make_shared<OpenSSLDlogECF2m>("K-233");
auto g = dlog->getGenerator();

vector<shared_ptr<SigmaVerifierComputation>> verifiers;

biginteger r = 5;
auto co1 = dlog->exponentiate(g.get(), r);

verifiers.push_back(make_shared<SigmaDlogVerifierComputation>(dlog, 40, get_seeded_prg()));

ZKFromSigmaVerifier verifier(channel, make_shared<SigmaANDVerifierComputation>(verifiers, 40), get_seeded_prg());

vector<shared_ptr<SigmaProtocolMsg>> msgAs;
vector<shared_ptr<SigmaProtocolMsg>> msgZs;

msgAs.push_back(make_shared<SigmaGroupElementMsg(dlog->getIdentity()->generateSendableData()));
msgZs.push_back(make_shared<SigmaBIMsg>());

auto msgA = make_shared<SigmaMultipleMsg>(msgAs);
auto msgZ = make_shared<SigmaMultipleMsg>(msgZs);

vector<shared_ptr<SigmaCommonInput>> inputs;

inputs.push_back(make_shared<SigmaDlogCommonInput>(co1));

shared_ptr<SigmaMultipleCommonInput> input = make_shared<SigmaMultipleCommonInput>(inputs);

cout << "verified: " << verifier.verify(input.get(), msgA, msgZ) << endl;

It goes wrong at line 109 of ZeroKnowledge.cpp. For some reason it is not able to interpret the incoming message as an element of the dlog group. However, when I use a dlog object based on primes instead of elliptic curves, it works fine. Also when I remove the AND compositions and execute the following code, it works perfectly, so I don't know if the problem really lies in the use of elliptic curves (because the error points me in that direction) or the AND compositions.

Prover class (with AND compositions removed, so "standard" dlog sigma protocol):

auto dlog = make_shared<OpenSSLDlogECF2m>("K-233");
auto g = dlog->getGenerator();
ZKFromSigmaProver prover(channel, make_shared<SigmaDlogProverComputation>(dlog, 40));
biginteger q = dlog->getOrder();
biginteger r = 5;
auto co = dlog->exponentiate(g.get(), r);
shared_ptr<SigmaDlogProverInput> input = make_shared<SigmaDlogProverInput>(co, r);

prover.prove(input);

Verifier class:

auto dlog = make_shared<OpenSSLDlogECF2m>("K-233");
auto g = dlog->getGenerator();
ZKFromSigmaVerifier verifier(channel, make_shared<SigmaDlogVerifierComputation>(dlog, 40, get_seeded_prg()), get_seeded_prg());
auto msgA = make_shared<SigmaGroupElementMsg>(dlog->getIdentity()->generateSendableData());
auto msgZ = make_shared<SigmaBIMsg>();
auto co = dlog->exponentiate(g.get(), 5);
shared_ptr<SigmaDlogCommonInput> input = make_shared<SigmaDlogCommonInput>(co);

cout << verifier.verify(input.get(), msgA, msgZ) << endl;

If anyone could help me out, that would be great. :) Thanks in advance!

Kind regards, Ruth