Commit Graph
35 Commits
Author SHA1 Message Date
Peter Dettman efa783f8f0 Store z-ratios in the 'x' coord they'll recover 2018-11-10 13:14:43 +00:00
Peter Dettman 4c950bbeaf Save some additions per window in _pippenger_wnaf 2017-12-07 20:13:04 +00:00
Peter Dettman cf12fa13cb Minor optimizations to _scalar_inverse to save 4M
- Precalculate x^5 and use for "01010" patterns during accumulation. (net -2M)
- Further use of x^5 to allow shorter addition chain (net -2M)
2017-04-18 11:55:07 +07:00
Peter Dettman efd953a7a7 Add Jacobi symbol test via GMP
Also add native Jacobi symbol test (Andrew)

Rebased-by: Andrew Poelstra
Rebased-by: Pieter Wuille
2016-07-04 13:16:35 +02:00
Peter Dettman 72ae443afb Improve perf. of cmov-based table lookup 2015-08-01 10:57:36 -05:00
Peter Dettman 55399c23f7 Further performance improvements to _ecmult_wnaf
- Initialize 'wnaf' to zeroes using memset
- Add new 'len' arg to speed up smaller scalars (mostly for endo=yes)
2015-07-13 22:46:42 +10:00
Peter Dettman 145cc6ea8f Improve performance of _ecmult_wnaf
- Track carry explicitly instead of adding to scalar
- Branch-free code for carry calculations
2015-07-11 13:49:04 +10:00
Peter Dettman 5a43124c69 Save 1 _fe_negate since s1 == -s2 2015-07-07 22:30:00 +10:00
Peter Dettman a5d796e0b1 Update code comments 2015-07-07 09:16:15 +09:30
Peter Dettman 3f3964e49c Add specific VERIFY tests for _fe_cmov 2015-07-06 12:41:30 +09:30
Peter Dettman 7d054cd030 Refactor to save a _fe_negate 2015-07-04 16:38:46 +09:30
Peter Dettman b28d02a5d5 Refactor to remove a local var 2015-07-04 16:30:56 +09:30
Peter Dettman 55e7fc32cb Perf. improvement in _gej_add_ge
- Avoid one weak normalization
- Change one full normalization to weak
- Avoid unnecessary fe assignment
- Update magnitude annotations
2015-07-04 16:21:35 +09:30
Peter Dettman a0601cd79c Fix VERIFY calculations in _fe_cmov methods 2015-07-04 13:50:15 +09:30
Peter Dettman 2d5a186cee Apply effective-affine trick to precomp 2015-04-30 09:25:44 -07:00
Peter Dettman 4f9791abba Effective affine addition in EC multiplication
* Make secp256k1_gej_add_var and secp256k1_gej_double return the
  Z ratio to go from a.z to r.z.
* Use these Z ratios to speed up batch point conversion to affine
  coordinates, and to speed up batch conversion of points to a
  common Z coordinate.
* Add a point addition function that takes a point with a known
  Z inverse.
* Due to secp256k1's endomorphism, all additions in the EC
  multiplication code can work on affine coordinate (with an
  implicit common Z coordinate), correcting the Z coordinate of
  the result afterwards.

Refactoring by Pieter Wuille:
* Move more global-z logic into the group code.
* Separate code for computing the odd multiples from the code to bring it
  to either storage or globalz format.
* Rename functions.
* Make all addition operations return Z ratios, and test them.
* Make the zr table format compatible with future batch chaining
  (the first entry in zr becomes the ratio between the input and the
  first output).

Original idea and code by Peter Dettman.
2015-04-30 09:23:21 -07:00
Peter Dettman 49ee0dbe16 Add _normalizes_to_zero_var variant 2014-12-20 14:38:29 +01:00
Peter Dettman eed599dd72 Add _fe_normalizes_to_zero method 2014-12-20 14:38:24 +01:00
Peter Dettman cc604e9842 Avoid division when decomposing scalars
- In secp256k1_gej_split_exp, there are two divisions used. Since the denominator is a constant known at compile-time, each can be replaced by a multiplication followed by a right-shift (and rounding).
- Add the constants g1, g2 for this purpose and rewrite secp256k1_scalar_split_lambda_var accordingly.
- Remove secp256k1_num_div since no longer used

Rebased-by: Pieter Wuille
2014-12-02 16:50:00 +01:00
Peter Dettman 5dd421bab5 Rewrite mul/sqr for 32bit/64bit
- interleave calculation of the lower and upper partial product ranges, and reduction
- less registers needed, more opportunities for parallel ops
2014-11-13 04:46:17 -08:00
Peter Dettman fb1bb0b445 Rearrange _gej_add_ge to save an _fe_negate 2014-11-12 02:16:36 -08:00
Peter Dettman 137e77afb4 Address 'constant-time' TODOs in field impls 2014-11-04 14:57:04 +07:00
Peter Dettman e2d66a2c62 Fix build for 64bit field under OSX
- caused by https://github.com/bitcoin/secp256k1/commit/8881212ebc43e67052ec06dec8beb459769fbab7
- OSX's ar tool doesn't work for empty archives ("ar: no archive members specified")
- introduce COMMON_LIB variable; leave empty when not using asm
2014-11-03 09:50:05 +07:00
Peter Dettman 7d681ac636 Add verification to 32bit field
- implement _fe_verify for 10x26
- fe is normalized after _fe_clear
- a few corresponding changes in 64bit field
2014-11-01 16:58:42 +07:00
Peter Dettman 59447da38d Test demonstrating discrepancy in sqr output 2014-07-17 21:07:38 +02:00
Peter Dettman f16be77ffc Use batch inversion in G precomputation 2014-07-17 15:33:00 +07:00
Peter Dettman 42822baaa8 Improve normalization performance for 32bit
- Uses a similar approach to the latest 64bit _normalize.
- Add one useful optimization back into the 64bit _normalize too.

Performance of 'bench' improved by around 0.5% for the 32bit field (but tested on a 64-bit machine).
2014-06-23 12:12:58 +07:00
Peter Dettman 9037707720 Rewrite 5x52 normalize method to be faster 2014-06-03 18:59:21 +07:00
Peter Dettman 6d6102fee4 A few improvements to the sqrt tests 2014-06-03 17:50:27 +07:00
Peter Dettman 17eec032c8 Support 64bit_asm field on OSX 2014-06-02 15:33:35 +07:00
Peter Dettman d7fd4d0f6b Use endomorphism in precomputations 2014-05-22 10:17:30 +07:00
Peter Dettman 09ca4f32e2 secp256k1_fe_sqrt checks for success
- secp256k1_fe_sqrt now checks that the value it calculated is actually a square root.
- Add return values to secp256k1_fe_sqrt and secp256k1_ge_set_xo.
- Callers of secp256k1_ge_set_xo can use return value instead of explicit validity checks
- Add random value tests for secp256k1_fe_sqrt
2014-05-21 10:22:14 +07:00
Peter Dettman a86f241d08 Add MacPorts default include/lib paths for OSX 2014-05-20 11:39:54 +07:00
Peter Dettman bb7bb81d07 Fix addition chain entry in comments 2014-01-31 11:43:57 +07:00
Peter Dettman f8ccd9befd Re-write secp256k1_fe_sqrt and secp256k1_fe_inv to use a sliding window over blocks of 1s 2014-01-30 19:16:20 +07:00