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

Change most assert_except into assert. #11

Merged
merged 1 commit into from
Feb 10, 2017
Merged

Change most assert_except into assert. #11

merged 1 commit into from
Feb 10, 2017

Conversation

ebfull
Copy link

@ebfull ebfull commented Feb 9, 2017

This PR changes most assert_except into assert in the interest of avoiding exceptions inside of OpenMP parallel regions.

The remaining:

src/algebra/curves/alt_bn128/alt_bn128_pairing.cpp
14:#include "common/assert_except.hpp"
348:    assert_except(Q1.Z == alt_bn128_Fq2::one());
350:    assert_except(Q2.Z == alt_bn128_Fq2::one());

src/algebra/fields/fp.tcc
18:#include "common/assert_except.hpp"
728:        assert_except(0);

src/algebra/fields/fp2.tcc
169:        assert_except(0);

src/common/assert_except.hpp
6:inline void assert_except(bool condition) {

The one in the pairing is there because libsnark's pairing function doesn't appear to work properly for zero inputs (scipr-lab#62) and we don't want a remote DoS (zcash/zcash#437), and the two in fp/fp2 are for sqrt which is not used at all inside of parallel code.

This PR also removes the evaluation domains that we don't use.

@@ -187,7 +186,7 @@ inline void bigint<n>::div_qr(bigint<n-d+1>& quotient, bigint<d>& remainder,
const bigint<n>& dividend, const bigint<d>& divisor)
{
static_assert(n >= d, "dividend must not be smaller than divisor for bigint::div_qr");
assert_except(divisor.data[d-1] != 0);
assert(divisor.data[d-1] != 0);
Copy link
Author

Choose a reason for hiding this comment

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

(The divisor for our purposes is always the modulus.)

@radix42
Copy link

radix42 commented Feb 9, 2017

This looks good to me, I've previously tested a version of libsnark with all assert_except instances changed to assert, I'll track this change downstream once its merged

@str4d
Copy link

str4d commented Feb 9, 2017

LGTM, although I can only check that the assert_except -> assert was done correctly.

This PR also removes the evaluation domains that we don't use.

I'd personally prefer that this was split into a separate commit.

Copy link

@daira daira left a comment

Choose a reason for hiding this comment

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

ACK

@@ -257,7 +256,7 @@ alt_bn128_G1 alt_bn128_G1::add(const alt_bn128_G1 &other) const
alt_bn128_G1 alt_bn128_G1::mixed_add(const alt_bn128_G1 &other) const
{
#ifdef DEBUG
assert_except(other.is_special());
assert(other.is_special());
Copy link

Choose a reason for hiding this comment

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

We don't compile with DEBUG, I think (based on cursory inspection of depends/packages/libsnark.mk.) But why is this in an #ifdef DEBUG conditional anyway?

@@ -224,7 +223,7 @@ inline bool bigint<n>::operator>(const bigint<n>& other) const
template<mp_size_t n>
bigint<n>& bigint<n>::randomize()
{
assert_except(GMP_NUMB_BITS == sizeof(mp_limb_t) * 8);
assert(GMP_NUMB_BITS == sizeof(mp_limb_t) * 8);
Copy link

Choose a reason for hiding this comment

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

I think this could be a static assert. Does not block.

@daira daira merged commit 9ada3f8 into master Feb 10, 2017
@daira
Copy link

daira commented Feb 10, 2017

Oops, I didn't notice @str4d's #11 (comment) before merging.

zkbot added a commit to zcash/zcash that referenced this pull request Feb 10, 2017
Update libsnark.

This updates libsnark to adopt zcash/libsnark#11. Do not merge this until zcash/libsnark#11 is merged.

Closes #2043
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants