34 Commits

Author SHA1 Message Date
Pieter Wuille
38cd84a0cb Compute ecmult tables at runtime for tests_exhaustive 2021-12-18 16:12:33 -05:00
Pieter Wuille
31feab053b Rename function secp256k1_ecmult_gen_{create_prec -> compute}_table 2021-12-18 16:11:52 -05:00
Pieter Wuille
725370c3f2 Rename ecmult_gen_prec -> ecmult_gen_compute_table 2021-12-17 14:43:45 -05:00
Tim Ruffing
fdb33dd122 refactor: Make PREC_BITS a parameter of ecmult_gen_build_prec_table 2021-12-05 17:58:26 +01:00
Tim Ruffing
5106226991 exhaustive_tests: Fix with ecmult_gen table with custom generator 2021-12-03 11:23:33 +01:00
Tim Ruffing
22dc2c0a0d ecmult_gen: Move table creation to new file and force static prec 2021-11-19 13:47:05 +01:00
Russell O'Connor
6815761cf5 Remove ecmult_context.
These tables stored in this context are now statically available from the generated ecmult_static_pre_g.h file.
2021-08-20 11:11:26 -04:00
Nicolas Iooss
a1ee83c654 tests_exhaustive: check the result of secp256k1_ecdsa_sign
If `secp256k1_ecdsa_sign` fails, the signature which is then loaded by
`secp256k1_ecdsa_signature_load` is garbage. Exit early with an error
when this occurs.
2021-07-02 16:22:43 +02:00
William Bright
3c90bdda95 change local lib headers to be relative for those pointing at "include/" dir
added relative paths to header files imported from src directory

added include guards for contrib/ files when referring to secp256k1.h
2021-05-05 09:24:05 -04:00
Gregory Maxwell
ae9e648526 Define SECP256K1_BUILD in secp256k1.c directly.
This avoids building without it and makes it safer to use a custom
 building environment.  Test harnesses need to #include secp256k1.c
 first now.
2021-05-01 19:27:27 +00:00
Dimitris Apostolou
07aa4c70ff
Fix insecure links 2020-12-18 00:24:22 +02:00
Pieter Wuille
4232e5b7da Rip out non-endomorphism code 2020-10-13 11:31:13 -07:00
Pieter Wuille
a45c1fa63c Rename testrand functions to have test in name 2020-09-25 20:50:43 -07:00
Pieter Wuille
8b7dcdd955 Add exhaustive test for extrakeys and schnorrsig 2020-09-18 14:11:38 -07:00
Pieter Wuille
63e1b2aa7d Disable output buffering in tests_exhaustive.c 2020-09-18 14:11:37 -07:00
Pieter Wuille
39f67dd072 Support splitting exhaustive tests across cores 2020-09-18 14:11:02 -07:00
Pieter Wuille
e99b26fcd5 Give exhaustive_tests count and seed cmdline inputs 2020-09-18 14:10:59 -07:00
Pieter Wuille
b110c106fa Change exhaustive test groups so they have a point with X=1
This enables testing overflow is correctly encoded in the recid, and
likely triggers more edge cases.

Also introduce a Sage script to generate the parameters.
2020-09-18 14:01:15 -07:00
Pieter Wuille
cec7b18a34 Select exhaustive lambda in function of order 2020-09-18 14:01:15 -07:00
Pieter Wuille
c498366e5b Move exhaustive tests for recovery to module 2020-09-18 14:01:15 -07:00
Pieter Wuille
be31791543 Make group order purely compile-time in exhaustive tests 2020-09-18 14:01:15 -07:00
Pieter Wuille
7c068998ba Compile-time check assumptions on integer types 2020-08-14 16:12:49 -07:00
Pieter Wuille
18d36327fd secp256k1_gej_double_nonzero supports infinity 2020-07-28 18:12:30 -07:00
Gregory Maxwell
2241ae6d14 Remove secret-dependant non-constant time operation in ecmult_const.
ECMULT_CONST_TABLE_GET_GE was branching on its secret input.

Also makes secp256k1_gej_double_var implemented as a wrapper
 on secp256k1_gej_double_nonzero instead of the other way
 around.  This wasn't a constant time bug but it was fragile
 and could easily become one in the future if the double_var
 algorithm is changed.
2020-01-09 12:21:28 +00:00
Andrew Poelstra
c2b028a281 scratch space: thread error_callback into all scratch space functions
Use it when checking magic bytes
2019-05-25 22:59:50 +00:00
Andrew Poelstra
6fe50439ae scratch: add stack frame support 2018-04-05 22:49:29 +00:00
Andrew Poelstra
7c1b91ba4b parameterize ecmult_const over input size 2018-04-05 21:05:13 +00:00
Jonas Nick
355a38f113 Add pippenger_wnaf ecmult_multi 2017-12-07 20:13:04 +00:00
Andrew Poelstra
dba5471b69 Add ecmult_multi tests 2017-12-07 20:13:04 +00:00
Andrew Poelstra
2cee5fd4c9 exhaustive tests: add recovery module 2016-12-16 21:50:16 +00:00
Andrew Poelstra
678b0e5466 exhaustive tests: remove erroneous comment from ecdsa_sig_sign
Mathematically, we always overflow when using the exhaustive tests (because our
scalar order is 13 and our field order is on the order of 2^256), but the
`overflow` variable returned when parsing a b32 as a scalar is always set
to 0, to prevent infinite (or practically infinite) loops searching for
non-overflowing scalars.
2016-11-28 19:46:18 +00:00
Andrew Poelstra
b4ceedf14f Add exhaustive test for verification 2016-11-26 00:35:02 +00:00
Andrew Poelstra
83836a9547 Add exhaustive tests for group arithmetic, signing, and ecmult on a small group
If you compile without ./configure --enable-exhaustive-tests=no,
this will create a binary ./exhaustive_tests which will execute
every function possible on a group of small order obtained by
moving to a twist of our curve and locating a generator of small
order.

Currently defaults to order 13, though by changing some #ifdefs
you can get a couple other ones. (Currently 199, which will take
forever to run, and 14, which won't work because it's composite.)

TODO exhaustive tests for the various modules
2016-11-26 00:35:00 +00:00
Andrew Poelstra
20b8877be1 Add exhaustive test for group functions on a low-order subgroup
We observe that when changing the b-value in the elliptic curve formula
`y^2 = x^3 + ax + b`, the group law is unchanged. Therefore our functions
for secp256k1 will be correct if and only if they are correct when applied
to the curve defined by `y^2 = x^3 + 4` defined over the same field. This
curve has a point P of order 199.

This commit adds a test which computes the subgroup generated by P and
exhaustively checks that addition of every pair of points gives the correct
result.

Unfortunately we cannot test const-time scalar multiplication by the same
mechanism. The reason is that these ecmult functions both compute a wNAF
representation of the scalar, and this representation is tied to the order
of the group.

Testing with the incomplete version of gej_add_ge (found in 5de4c5dff^)
shows that this detects the incompleteness when adding P - 106P, which
is exactly what we expected since 106 is a cube root of 1 mod 199.
2016-11-25 20:45:29 +00:00