Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support other curves in mpc #223

Merged
merged 4 commits into from
May 29, 2020
Merged

Support other curves in mpc #223

merged 4 commits into from
May 29, 2020

Conversation

dtebbs
Copy link
Contributor

@dtebbs dtebbs commented May 21, 2020

Support for other curves in groth16 mpc.

@@ -8,7 +8,7 @@
#include "libzeth/snarks/groth16/groth16_snark.hpp"

#include <istream>
#include <libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp>
// #include <libff/algebra/curves/alt_bn128/alt_bn128_pp.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall this comment be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.


using ppT = libzeth::ppT;
// Test data is specifically for alt_bn128

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extraneous line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@@ -71,33 +71,38 @@ srs_mpc_phase2_accumulator<ppT> dummy_initial_accumulator(

TEST(MPCTests, HashToG2)
{
// Data here is specialised for alt_bn128. Call init_public_params on it,
// just in case `ppT` is set to a different curve.
using pp = libff::alt_bn128_pp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use ppT which is defined as using ppT = libff::alt_bn128_pp; at the top of the file? I mean, you called alt_bn_128::init_params() in the entry point exactly for the reason you mention in your comment, i.e. in case ppT is set to another curve, no?
As such, if this test only works for alt_bn128, I'd remove pp all together, and use alt_bn_128 here, and rely on the init_params done in main. This is confusing otherwise since we have ppT, pp and alt_bn128_pp in this test file..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. ppT is supposed to represent the pairing used to run the tests, except those that are specialized for a specific pairing. So ppT is the default (eventually it would be nice to parameterize all these tests by ppT so we can run over all pairings - there should be no reason to restrict to the default - but I didn't plan to address that here), the second call to init_params in main is just in case ppT is not set to alt_bn_128.

The pp is kind of independent - it's just local to the function for convenience. If we expand everything to libff::alt_bn128_pp everywhere its many extra lines of code for no extra clarity.

Hope it's clear in the new version.

// Data here is specialised for alt_bn128. Call init_public_params on it,
// just in case `ppT` is set to a different curve.
using pp = libff::alt_bn128_pp;
pp::init_public_params();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary as you already init the params of ppT and of alt_bn_128 in the entry point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(covered by the above)

@dtebbs dtebbs force-pushed the mpc-other-curves branch 2 times, most recently from 5465cd3 to 3ab5170 Compare May 28, 2020 09:21
@dtebbs dtebbs changed the title Support other curves in mpc (depends on #213) Support other curves in mpc May 28, 2020
@dtebbs dtebbs changed the base branch from clang-tidy-incremental-fixes to develop May 28, 2020 09:31
@AntoineRondelet
Copy link
Contributor

Tackles #176 @dtebbs

mpc_hash_t hash;
const std::string seed = hex_to_bytes(
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef");
memcpy(hash, seed.data(), sizeof(mpc_hash_t));

Fr expect_fr;
libff::alt_bn128_Fr expect_fr;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use libff::Fr<pp>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

@AntoineRondelet AntoineRondelet merged commit 037dc91 into develop May 29, 2020
@AntoineRondelet AntoineRondelet deleted the mpc-other-curves branch July 28, 2020 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants