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

WIP Group verification #1032

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,11 @@ static void secp256k1_fe_half(secp256k1_fe *r);
* magnitude set to 'm' and is normalized if (and only if) 'm' is zero. */
static void secp256k1_fe_get_bounds(secp256k1_fe *r, int m);

#ifdef VERIFY

/** Assert a context-specific limit m on the magnitude of a. m cannot be outside the intrinsic range of magnitudes supported by this field implementation. */
static void secp256k1_fe_verify_magnitude(const secp256k1_fe *a, int m);

#endif

#endif /* SECP256K1_FIELD_H */
6 changes: 6 additions & 0 deletions src/field_10x26_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ static void secp256k1_fe_verify(const secp256k1_fe *a) {
}
VERIFY_CHECK(r == 1);
}

static void secp256k1_fe_verify_magnitude(const secp256k1_fe *a, int m) {
VERIFY_CHECK(m >= 0);
VERIFY_CHECK(m <= 32);
VERIFY_CHECK(a->magnitude <= m);
}
#endif

static void secp256k1_fe_get_bounds(secp256k1_fe *r, int m) {
Expand Down
7 changes: 7 additions & 0 deletions src/field_5x52_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ static void secp256k1_fe_verify(const secp256k1_fe *a) {
}
VERIFY_CHECK(r == 1);
}

static void secp256k1_fe_verify_magnitude(const secp256k1_fe *a, int m) {
VERIFY_CHECK(m >= 0);
VERIFY_CHECK(m <= 2048);
VERIFY_CHECK(a->magnitude <= m);
}

#endif

static void secp256k1_fe_get_bounds(secp256k1_fe *r, int m) {
Expand Down