532 Commits

Author SHA1 Message Date
Roman Zeyde
d4d270a59c
Allow field_10x26_arm.s to compile for ARMv7 architecture 2019-05-07 22:37:35 +03:00
Pieter Wuille
e6d01e9347 Use size_t shifts when computing a size_t 2019-03-30 16:09:17 -07:00
Gregory Maxwell
d58bc93f2c Switch x86_64 asm to use "i" instead of "n" for immediate values.
The constraint "n" is a more obscure setting which is needed for
 special cases that don't apply to our use.

Use of "n" exposed some bugs in pre-release versions of clang.
This fixes #594
2019-03-10 22:52:12 +00:00
Jonas Nick
2277af5ff0 Fix integer overflow in ecmult_multi_var when n is large 2019-02-25 16:13:17 +00:00
Gregory Maxwell
85d0e1bcce
Merge #591: Make bench_internal obey secp256k1_fe_sqrt's contract wrt aliasing.
b76e45d Make bench_internal obey secp256k1_fe_sqrt's contract wrt aliasing. (Gregory Maxwell)

Pull request description:

  Bench_internal was previously incorrect but wasn't detected by -DVERIFY until PR #551.

Tree-SHA512: 5ecb9e3ba63ddf28cde4012154dbb1dda9b7178016d970dba58a4af20c31aa1ec3458ba2623541233fb16fceff7b3053054d6eee0229d0bfb6281d1a10554e9f
2019-02-24 19:20:54 +00:00
Jonas Nick
a697d82da9 Add trivial ecmult_multi to the benchmark tool 2019-02-23 20:30:31 +00:00
Jonas Nick
bade617417 Add trivial ecmult_multi algorithm. It is selected when no scratch space is given and just multiplies and adds the points. 2019-02-23 20:24:28 +00:00
Gregory Maxwell
20c5869df2
Merge #516: improvements to random seed in src/tests.c
be40c4d Fixup for C90 mixed declarations. (Gregory Maxwell)
8b3841c fix bug in fread() failure check (Don Viszneki)
cddef0c tests: add warning message when /dev/urandom fails (Don Viszneki)

Pull request description:

  I've made two small changes to `src/tests.c` circa random seed generation.

  Added a warning when `/dev/urandom` fails, mostly to defend against the case that someone should use the code verbatim, but also to enhance its illustrative power.

  Also I fixed a bug with how the return value of `fread()` was being evaluated. In fact, `/dev/urandom` was never being applied before as the check on the return value of `fread()` always failed!

Tree-SHA512: 239dbe8316220c2f0e5b370bf9a18f78196e96cc4a7edea58cf2521b2c9cbc8da065be96aa859f90324d57e388d30f7670ce6bc1cca52e5162e5ca66b1a55b34
2019-02-21 11:46:13 +00:00
Gregory Maxwell
b76e45d5d6 Make bench_internal obey secp256k1_fe_sqrt's contract wrt aliasing.
Bench_internal was previously incorrect but wasn't detected by
 -DVERIFY until PR #551.
2019-02-21 05:58:33 +00:00
Gregory Maxwell
870a977644
Merge #562: Make use of TAG_PUBKEY constants in secp256k1_eckey_pubkey_parse
d3cb1f9 Make use of TAG_PUBKEY constants in secp256k1_eckey_pubkey_parse (Ben Woosley)

Pull request description:

  This results in more self-documenting code.

  Constants defined here:
  1e6f1f5ad5/include/secp256k1.h (L175-L180)

Tree-SHA512: 2026103c487a5ebdea9a2f5ec2be96d74e38d5b2269b4df11e354bb54aba2925b47c3185f530205019840b00fc3501121acfa5234faf1d095d71777826414f69
2019-02-21 05:35:10 +00:00
Gregory Maxwell
be40c4d0b5 Fixup for C90 mixed declarations.
Reported-by: Jonas Nick <jonasd.nick@gmail.com>
2019-02-21 05:00:29 +00:00
Gregory Maxwell
c71dd2c08f
Merge #509: Fix algorithm selection in bench_ecmult
0f05173 Fix algorithm selection in bench_ecmult (Jonas Nick)

Pull request description:

  Without this commit using an unknown argument results in a segmentation fault.

Tree-SHA512: 85b8f977e62fa360ff6dc923bd86f08725c30e178d58f43d33cbd8eb69e54fa4ec76e4407624611a80554cf9961689bce6b216da735ac95b256d0d2f60fe3328
2019-02-21 04:47:12 +00:00
Gregory Maxwell
e96901a4b9
Merge #587: Make randomization of a non-signing context a noop
6198375 Make randomization of a non-signing context a noop (Tim Ruffing)

Pull request description:

  Before this commit secp256k1_context_randomize called illegal_callback
  when called on a context not initialized for signing. This is not
  documented. Moreover, it is not desirable because non-signing contexts
  may use randomization in the future.

  This commit makes secp256k1_context_randomize a noop in this case. This
  is safe because the context cannot be used for signing anyway.

  This fixes #573 and it fixes rust-bitcoin/rust-secp256k1#82.

Tree-SHA512: 34ddfeb004d9da8f4a77c739fa2110544c28939378e779226da52f410a0e36b3aacb3ebd2e3f3918832a9027684c161789cfdc27a133f2f0e0f1c47e8363029c
2019-02-21 04:33:59 +00:00
Gregory Maxwell
2ebdad772a
Merge #552: Make constants static:
496c5b4 Make constants static: static const secp256k1_ge secp256k1_ge_const_g; static const int CURVE_B; (Russell O'Connor)

Pull request description:

  static const secp256k1_ge secp256k1_ge_const_g;
  static const int CURVE_B;

Tree-SHA512: df8d34777d3b1b90eef875d50c2870e2480f08685b399a22eaf584ce294766e0de3a41523757a23e311e633886c89400313421282beca791326a06695f348940
2019-02-21 04:26:40 +00:00
Gregory Maxwell
1c131affd3
Merge #551: secp256k1_fe_sqrt: Verify that the arguments don't alias.
bf8b86c secp256k1_fe_sqrt: Verify that the arguments don't alias. (Russell O'Connor)

Pull request description:

Tree-SHA512: 4e9128625817be83a1259e7dbdb82c4be8ee0174af7d5e76eeac3245d23d6bf01378d9697dcb870eb61577afd7c0556cb3c6633e3b27504add14c10b18f7c607
2019-02-21 04:23:50 +00:00
Gregory Maxwell
ba698f883b
Merge #539: Assorted minor corrections
52ab96f clean dependendies in field_*_impl.h (Russell O'Connor)
deff5ed Correct math typos in field_*.h (Russell O'Connor)
4efb3f8 Add check that restrict pointers don't alias with all parameters. (Russell O'Connor)

Pull request description:

  * add more checks for restrict pointers.
  * correct math typos.
  * refine dependencies on "num.h"

Tree-SHA512: c368f577927db2ace3e7f46850cb2fdf9d7d169b698a9697767e1f82e9e7091f2b2fea0f7cf173048eb4c1bb56824c884fa849c04c595ee97766c01f346a54ec
2019-02-21 04:20:35 +00:00
Gregory Maxwell
949e85b009
Merge #550: Optimize secp256k1_fe_normalize_weak calls.
9bd89c8 Optimize secp256k1_fe_normalize_weak calls. Move secp256k1_fe_normalize_weak calls out of ECMULT_TABLE_GET_GE and ECMULT_TABLE_GET_GE_STORAGE and into secp256k1_ge_globalz_set_table_gej instead. (Russell O'Connor)

Pull request description:

  Move secp256k1_fe_normalize_weak calls out of ECMULT_TABLE_GET_GE and ECMULT_TABLE_GET_GE_STORAGE and into secp256k1_ge_globalz_set_table_gej instead.

Tree-SHA512: 7bbb1aca8e37a268a26d7061bd1f390db129e697792f1d5ddd10ea34927616edc26ef118b500c3e5e14d1d463196033ef64e4d34b765380325c24835458b7a9b
2019-02-21 04:14:40 +00:00
Tim Ruffing
6198375218 Make randomization of a non-signing context a noop
Before this commit secp256k1_context_randomize called illegal_callback
when called on a context not initialized for signing. This is not
documented. Moreover, it is not desirable because non-signing contexts
may use randomization in the future.

This commit makes secp256k1_context_randomize a noop in this case. This
is safe because the context cannot be used for signing anyway.

This fixes #573 and it fixes rust-bitcoin/rust-secp256k1#82.
2019-01-27 13:33:52 +01:00
Tim Ruffing
c663397f46 Use __GNUC_PREREQ for detecting __builtin_expect 2018-12-17 11:47:25 +01:00
Andrew Poelstra
b3bf5f99a3 ecmult_impl: expand comment to explain how effective affine interacts with everything 2018-11-10 14:01:13 +00:00
Peter Dettman
efa783f8f0 Store z-ratios in the 'x' coord they'll recover 2018-11-10 13:14:43 +00:00
Andrew Poelstra
ffd3b346fe add secp256k1_ge_set_all_gej_var test which deals with many infinite points 2018-11-09 00:20:53 +00:00
Andrew Poelstra
84740acd2a ecmult_impl: save one fe_inv_var 2018-11-09 00:20:53 +00:00
Andrew Poelstra
47045270fa ecmult_impl: eliminate scratch memory used when generating context 2018-11-09 00:20:51 +00:00
Andrew Poelstra
7f7a2ed3a8 ecmult_gen_impl: eliminate scratch memory used when generating context 2018-11-09 00:16:06 +00:00
Pieter Wuille
314a61d724
Merge #553: add static context object which has no capabilities
40fde61 prevent attempts to modify `secp256k1_context_no_precomp` (Andrew Poelstra)
ed7c084 add static context object which has no capabilities (Andrew Poelstra)

Pull request description:

Tree-SHA512: a843ed7ba00a00a46eec3146ce428d4b49eb440af766f44d731b1f51553d08de8cc9a0af5ed114d0dfdca6f4bf4a2ede4dbd6a37d6bd818b81630089424a0ba5
2018-11-05 18:25:56 -08:00
Pieter Wuille
1086fda4c1
Merge #354: [ECDH API change] Support custom hash function
c8fbc3c [ECDH API change] Allow pass arbitrary data to hash function (Kirill Fomichev)
b00be65 [ECDH API change] Support custom hash function (Kirill Fomichev)

Pull request description:

  Solve #352

Tree-SHA512: f5985874d03e976cdb3d59036af7720636ad1488da40fd3bd7881b1fb71b05036a952013d519baa84c4ce4b558bdef25c4ce76b384b297e4d0aece9e37e78a01
2018-10-17 12:14:48 -07:00
Ben Woosley
d3cb1f95eb
Make use of TAG_PUBKEY constants in secp256k1_eckey_pubkey_parse
This results in more self-documenting code.
2018-10-09 15:40:41 +09:00
Andrew Poelstra
40fde611bd prevent attempts to modify secp256k1_context_no_precomp 2018-10-04 15:16:38 +00:00
Andrew Poelstra
ed7c08417a add static context object which has no capabilities 2018-10-04 15:16:34 +00:00
Russell O'Connor
496c5b43b8 Make constants static:
static const secp256k1_ge secp256k1_ge_const_g;
static const int CURVE_B;
2018-08-15 15:42:06 -04:00
Russell O'Connor
bf8b86cc07 secp256k1_fe_sqrt: Verify that the arguments don't alias. 2018-08-14 18:21:13 -04:00
Russell O'Connor
9bd89c836b Optimize secp256k1_fe_normalize_weak calls.
Move secp256k1_fe_normalize_weak calls out of ECMULT_TABLE_GET_GE and ECMULT_TABLE_GET_GE_STORAGE and into secp256k1_ge_globalz_set_table_gej instead.
2018-08-12 23:47:38 -04:00
Russell O'Connor
52ab96fedb clean dependendies in field_*_impl.h 2018-07-06 08:40:35 -04:00
Russell O'Connor
deff5edd42 Correct math typos in field_*.h 2018-07-06 08:40:35 -04:00
Russell O'Connor
4efb3f8dd1 Add check that restrict pointers don't alias with all parameters. 2018-07-06 08:40:34 -04:00
Kirill Fomichev
c8fbc3c397 [ECDH API change] Allow pass arbitrary data to hash function 2018-05-17 00:38:58 +03:00
Kirill Fomichev
b00be65056 [ECDH API change] Support custom hash function 2018-05-17 00:05:09 +03:00
Andrew Poelstra
95e99f196f fix tests.c in the count == 0 case 2018-04-10 19:32:04 +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
Pieter Wuille
dbc3ddd5e2
Merge #513: Increase sparsity of pippenger fixed window naf representation
ec0a7b3 Don't touch leading zeros in wnaf_fixed. (Jonas Nick)
9e36d1b Fix bug in wnaf_fixed where the wnaf array is not completely zeroed when given a 0 scalar. (Jonas Nick)
96f68a0 Don't invert scalar in wnaf_fixed when it is even because a caller might intentionally give a scalar with many leading zeros. (Jonas Nick)
6dbb007 Increase sparsity of pippenger fixed window naf representation (Jonas Nick)

Pull request description:

  Fixes #506

Tree-SHA512: 49a237a7d09c0c376ba4e6b1f522b9aff2517e420dfef9df810fd5ba920e0b98be8fe3f730b32e41b4aef475bc4cf3b13220024bd8d6f40c2744e6f392ff97a8
2018-04-05 09:46:08 -07:00
Jonas Nick
0f0517369c Fix algorithm selection in bench_ecmult 2018-03-27 09:21:11 +00:00
Pieter Wuille
fb9271dcf0
Merge #510: add a couple missing consts to ecmult_pippenger_wnaf
9b3ff03 add a couple missing `const`s to ecmult_pippenger_wnaf (Andrew Poelstra)

Pull request description:

Tree-SHA512: a58458bb4cb1af357b13a506ce8720ce9ecd0c1771a49d9f3ce9398ba7afc56977d722bbd30a63c7c76e63e659ed956d5e82ff762efc4b49488adf0756dc656a
2018-03-26 18:28:56 -07:00
Jonas Nick
ec0a7b3ae3 Don't touch leading zeros in wnaf_fixed. 2018-03-23 14:52:13 +00:00
Jonas Nick
9e36d1bfe2 Fix bug in wnaf_fixed where the wnaf array is not completely zeroed when given a 0 scalar. 2018-03-23 14:52:02 +00:00
Jonas Nick
96f68a0afc Don't invert scalar in wnaf_fixed when it is even because a caller might
intentionally give a scalar with many leading zeros.
2018-03-23 14:51:53 +00:00
Don Viszneki
8b3841c91d fix bug in fread() failure check
the two middle arguments to fread() are easily confused, and cause the
checking of return value to fail incorrectly (and possibly succeed
incorrectly.)
2018-03-05 18:45:00 -08:00
Don Viszneki
cddef0c0be tests: add warning message when /dev/urandom fails
in case this code should ever be used as an example, a warning is a nice
way of helping ensure insecure keys are not generated
2018-03-05 18:43:31 -08:00
Dimitris Apostolou
9b7c47a21e
Fix typo 2018-03-05 18:53:33 +02:00