bitcoin/src/secp256k1/src/modinv64_impl.h

630 lines
30 KiB
C
Raw Normal View History

Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/***********************************************************************
* Copyright (c) 2020 Peter Dettman *
* Distributed under the MIT software license, see the accompanying *
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
**********************************************************************/
#ifndef SECP256K1_MODINV64_IMPL_H
#define SECP256K1_MODINV64_IMPL_H
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
#include "int128.h"
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
#include "modinv64.h"
/* This file implements modular inversion based on the paper "Fast constant-time gcd computation and
* modular inversion" by Daniel J. Bernstein and Bo-Yin Yang.
*
* For an explanation of the algorithm, see doc/safegcd_implementation.md. This file contains an
* implementation for N=62, using 62-bit signed limbs represented as int64_t.
*/
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
/* Data type for transition matrices (see section 3 of explanation).
*
* t = [ u v ]
* [ q r ]
*/
typedef struct {
int64_t u, v, q, r;
} secp256k1_modinv64_trans2x2;
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
#ifdef VERIFY
/* Helper function to compute the absolute value of an int64_t.
* (we don't use abs/labs/llabs as it depends on the int sizes). */
static int64_t secp256k1_modinv64_abs(int64_t v) {
VERIFY_CHECK(v > INT64_MIN);
if (v < 0) return -v;
return v;
}
static const secp256k1_modinv64_signed62 SECP256K1_SIGNED62_ONE = {{1}};
/* Compute a*factor and put it in r. All but the top limb in r will be in range [0,2^62). */
static void secp256k1_modinv64_mul_62(secp256k1_modinv64_signed62 *r, const secp256k1_modinv64_signed62 *a, int alen, int64_t factor) {
const int64_t M62 = (int64_t)(UINT64_MAX >> 2);
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_int128 c, d;
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
int i;
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_from_i64(&c, 0);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
for (i = 0; i < 4; ++i) {
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
if (i < alen) secp256k1_i128_accum_mul(&c, a->v[i], factor);
r->v[i] = secp256k1_i128_to_i64(&c) & M62; secp256k1_i128_rshift(&c, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
}
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
if (4 < alen) secp256k1_i128_accum_mul(&c, a->v[4], factor);
secp256k1_i128_from_i64(&d, secp256k1_i128_to_i64(&c));
VERIFY_CHECK(secp256k1_i128_eq_var(&c, &d));
r->v[4] = secp256k1_i128_to_i64(&c);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
}
/* Return -1 for a<b*factor, 0 for a==b*factor, 1 for a>b*factor. A has alen limbs; b has 5. */
static int secp256k1_modinv64_mul_cmp_62(const secp256k1_modinv64_signed62 *a, int alen, const secp256k1_modinv64_signed62 *b, int64_t factor) {
int i;
secp256k1_modinv64_signed62 am, bm;
secp256k1_modinv64_mul_62(&am, a, alen, 1); /* Normalize all but the top limb of a. */
secp256k1_modinv64_mul_62(&bm, b, 5, factor);
for (i = 0; i < 4; ++i) {
/* Verify that all but the top limb of a and b are normalized. */
VERIFY_CHECK(am.v[i] >> 62 == 0);
VERIFY_CHECK(bm.v[i] >> 62 == 0);
}
for (i = 4; i >= 0; --i) {
if (am.v[i] < bm.v[i]) return -1;
if (am.v[i] > bm.v[i]) return 1;
}
return 0;
}
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
/* Check if the determinant of t is equal to 1 << n. */
static int secp256k1_modinv64_det_check_pow2(const secp256k1_modinv64_trans2x2 *t, unsigned int n) {
secp256k1_int128 a;
secp256k1_i128_det(&a, t->u, t->v, t->q, t->r);
return secp256k1_i128_check_pow2(&a, n);
}
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
#endif
/* Take as input a signed62 number in range (-2*modulus,modulus), and add a multiple of the modulus
* to it to bring it to range [0,modulus). If sign < 0, the input will also be negated in the
* process. The input must have limbs in range (-2^62,2^62). The output will have limbs in range
* [0,2^62). */
static void secp256k1_modinv64_normalize_62(secp256k1_modinv64_signed62 *r, int64_t sign, const secp256k1_modinv64_modinfo *modinfo) {
const int64_t M62 = (int64_t)(UINT64_MAX >> 2);
int64_t r0 = r->v[0], r1 = r->v[1], r2 = r->v[2], r3 = r->v[3], r4 = r->v[4];
int64_t cond_add, cond_negate;
#ifdef VERIFY
/* Verify that all limbs are in range (-2^62,2^62). */
int i;
for (i = 0; i < 5; ++i) {
VERIFY_CHECK(r->v[i] >= -M62);
VERIFY_CHECK(r->v[i] <= M62);
}
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(r, 5, &modinfo->modulus, -2) > 0); /* r > -2*modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(r, 5, &modinfo->modulus, 1) < 0); /* r < modulus */
#endif
/* In a first step, add the modulus if the input is negative, and then negate if requested.
* This brings r from range (-2*modulus,modulus) to range (-modulus,modulus). As all input
* limbs are in range (-2^62,2^62), this cannot overflow an int64_t. Note that the right
* shifts below are signed sign-extending shifts (see assumptions.h for tests that that is
* indeed the behavior of the right shift operator). */
cond_add = r4 >> 63;
r0 += modinfo->modulus.v[0] & cond_add;
r1 += modinfo->modulus.v[1] & cond_add;
r2 += modinfo->modulus.v[2] & cond_add;
r3 += modinfo->modulus.v[3] & cond_add;
r4 += modinfo->modulus.v[4] & cond_add;
cond_negate = sign >> 63;
r0 = (r0 ^ cond_negate) - cond_negate;
r1 = (r1 ^ cond_negate) - cond_negate;
r2 = (r2 ^ cond_negate) - cond_negate;
r3 = (r3 ^ cond_negate) - cond_negate;
r4 = (r4 ^ cond_negate) - cond_negate;
/* Propagate the top bits, to bring limbs back to range (-2^62,2^62). */
r1 += r0 >> 62; r0 &= M62;
r2 += r1 >> 62; r1 &= M62;
r3 += r2 >> 62; r2 &= M62;
r4 += r3 >> 62; r3 &= M62;
/* In a second step add the modulus again if the result is still negative, bringing
* r to range [0,modulus). */
cond_add = r4 >> 63;
r0 += modinfo->modulus.v[0] & cond_add;
r1 += modinfo->modulus.v[1] & cond_add;
r2 += modinfo->modulus.v[2] & cond_add;
r3 += modinfo->modulus.v[3] & cond_add;
r4 += modinfo->modulus.v[4] & cond_add;
/* And propagate again. */
r1 += r0 >> 62; r0 &= M62;
r2 += r1 >> 62; r1 &= M62;
r3 += r2 >> 62; r2 &= M62;
r4 += r3 >> 62; r3 &= M62;
r->v[0] = r0;
r->v[1] = r1;
r->v[2] = r2;
r->v[3] = r3;
r->v[4] = r4;
#ifdef VERIFY
VERIFY_CHECK(r0 >> 62 == 0);
VERIFY_CHECK(r1 >> 62 == 0);
VERIFY_CHECK(r2 >> 62 == 0);
VERIFY_CHECK(r3 >> 62 == 0);
VERIFY_CHECK(r4 >> 62 == 0);
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(r, 5, &modinfo->modulus, 0) >= 0); /* r >= 0 */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(r, 5, &modinfo->modulus, 1) < 0); /* r < modulus */
#endif
}
/* Compute the transition matrix and eta for 59 divsteps (where zeta=-(delta+1/2)).
* Note that the transformation matrix is scaled by 2^62 and not 2^59.
*
* Input: zeta: initial zeta
* f0: bottom limb of initial f
* g0: bottom limb of initial g
* Output: t: transition matrix
* Return: final zeta
*
* Implements the divsteps_n_matrix function from the explanation.
*/
static int64_t secp256k1_modinv64_divsteps_59(int64_t zeta, uint64_t f0, uint64_t g0, secp256k1_modinv64_trans2x2 *t) {
/* u,v,q,r are the elements of the transformation matrix being built up,
* starting with the identity matrix times 8 (because the caller expects
* a result scaled by 2^62). Semantically they are signed integers
* in range [-2^62,2^62], but here represented as unsigned mod 2^64. This
* permits left shifting (which is UB for negative numbers). The range
* being inside [-2^63,2^63) means that casting to signed works correctly.
*/
uint64_t u = 8, v = 0, q = 0, r = 8;
uint64_t c1, c2, f = f0, g = g0, x, y, z;
int i;
for (i = 3; i < 62; ++i) {
VERIFY_CHECK((f & 1) == 1); /* f must always be odd */
VERIFY_CHECK((u * f0 + v * g0) == f << i);
VERIFY_CHECK((q * f0 + r * g0) == g << i);
/* Compute conditional masks for (zeta < 0) and for (g & 1). */
c1 = zeta >> 63;
c2 = -(g & 1);
/* Compute x,y,z, conditionally negated versions of f,u,v. */
x = (f ^ c1) - c1;
y = (u ^ c1) - c1;
z = (v ^ c1) - c1;
/* Conditionally add x,y,z to g,q,r. */
g += x & c2;
q += y & c2;
r += z & c2;
/* In what follows, c1 is a condition mask for (zeta < 0) and (g & 1). */
c1 &= c2;
/* Conditionally change zeta into -zeta-2 or zeta-1. */
zeta = (zeta ^ c1) - 1;
/* Conditionally add g,q,r to f,u,v. */
f += g & c1;
u += q & c1;
v += r & c1;
/* Shifts */
g >>= 1;
u <<= 1;
v <<= 1;
/* Bounds on zeta that follow from the bounds on iteration count (max 10*59 divsteps). */
VERIFY_CHECK(zeta >= -591 && zeta <= 591);
}
/* Return data in t and return value. */
t->u = (int64_t)u;
t->v = (int64_t)v;
t->q = (int64_t)q;
t->r = (int64_t)r;
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
#ifdef VERIFY
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* The determinant of t must be a power of two. This guarantees that multiplication with t
* does not change the gcd of f and g, apart from adding a power-of-2 factor to it (which
* will be divided out again). As each divstep's individual matrix has determinant 2, the
* aggregate of 59 of them will have determinant 2^59. Multiplying with the initial
* 8*identity (which has determinant 2^6) means the overall outputs has determinant
* 2^65. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
VERIFY_CHECK(secp256k1_modinv64_det_check_pow2(t, 65));
#endif
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
return zeta;
}
/* Compute the transition matrix and eta for 62 divsteps (variable time, eta=-delta).
*
* Input: eta: initial eta
* f0: bottom limb of initial f
* g0: bottom limb of initial g
* Output: t: transition matrix
* Return: final eta
*
* Implements the divsteps_n_matrix_var function from the explanation.
*/
static int64_t secp256k1_modinv64_divsteps_62_var(int64_t eta, uint64_t f0, uint64_t g0, secp256k1_modinv64_trans2x2 *t) {
/* Transformation matrix; see comments in secp256k1_modinv64_divsteps_62. */
uint64_t u = 1, v = 0, q = 0, r = 1;
uint64_t f = f0, g = g0, m;
uint32_t w;
int i = 62, limit, zeros;
for (;;) {
/* Use a sentinel bit to count zeros only up to i. */
zeros = secp256k1_ctz64_var(g | (UINT64_MAX << i));
/* Perform zeros divsteps at once; they all just divide g by two. */
g >>= zeros;
u <<= zeros;
v <<= zeros;
eta -= zeros;
i -= zeros;
/* We're done once we've done 62 divsteps. */
if (i == 0) break;
VERIFY_CHECK((f & 1) == 1);
VERIFY_CHECK((g & 1) == 1);
VERIFY_CHECK((u * f0 + v * g0) == f << (62 - i));
VERIFY_CHECK((q * f0 + r * g0) == g << (62 - i));
/* Bounds on eta that follow from the bounds on iteration count (max 12*62 divsteps). */
VERIFY_CHECK(eta >= -745 && eta <= 745);
/* If eta is negative, negate it and replace f,g with g,-f. */
if (eta < 0) {
uint64_t tmp;
eta = -eta;
tmp = f; f = g; g = -tmp;
tmp = u; u = q; q = -tmp;
tmp = v; v = r; r = -tmp;
/* Use a formula to cancel out up to 6 bits of g. Also, no more than i can be cancelled
* out (as we'd be done before that point), and no more than eta+1 can be done as its
* will flip again once that happens. */
limit = ((int)eta + 1) > i ? i : ((int)eta + 1);
VERIFY_CHECK(limit > 0 && limit <= 62);
/* m is a mask for the bottom min(limit, 6) bits. */
m = (UINT64_MAX >> (64 - limit)) & 63U;
/* Find what multiple of f must be added to g to cancel its bottom min(limit, 6)
* bits. */
w = (f * g * (f * f - 2)) & m;
} else {
/* In this branch, use a simpler formula that only lets us cancel up to 4 bits of g, as
* eta tends to be smaller here. */
limit = ((int)eta + 1) > i ? i : ((int)eta + 1);
VERIFY_CHECK(limit > 0 && limit <= 62);
/* m is a mask for the bottom min(limit, 4) bits. */
m = (UINT64_MAX >> (64 - limit)) & 15U;
/* Find what multiple of f must be added to g to cancel its bottom min(limit, 4)
* bits. */
w = f + (((f + 1) & 4) << 1);
w = (-w * g) & m;
}
g += f * w;
q += u * w;
r += v * w;
VERIFY_CHECK((g & m) == 0);
}
/* Return data in t and return value. */
t->u = (int64_t)u;
t->v = (int64_t)v;
t->q = (int64_t)q;
t->r = (int64_t)r;
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
#ifdef VERIFY
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* The determinant of t must be a power of two. This guarantees that multiplication with t
* does not change the gcd of f and g, apart from adding a power-of-2 factor to it (which
* will be divided out again). As each divstep's individual matrix has determinant 2, the
* aggregate of 62 of them will have determinant 2^62. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
VERIFY_CHECK(secp256k1_modinv64_det_check_pow2(t, 62));
#endif
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
return eta;
}
/* Compute (t/2^62) * [d, e] mod modulus, where t is a transition matrix scaled by 2^62.
*
* On input and output, d and e are in range (-2*modulus,modulus). All output limbs will be in range
* (-2^62,2^62).
*
* This implements the update_de function from the explanation.
*/
static void secp256k1_modinv64_update_de_62(secp256k1_modinv64_signed62 *d, secp256k1_modinv64_signed62 *e, const secp256k1_modinv64_trans2x2 *t, const secp256k1_modinv64_modinfo* modinfo) {
const int64_t M62 = (int64_t)(UINT64_MAX >> 2);
const int64_t d0 = d->v[0], d1 = d->v[1], d2 = d->v[2], d3 = d->v[3], d4 = d->v[4];
const int64_t e0 = e->v[0], e1 = e->v[1], e2 = e->v[2], e3 = e->v[3], e4 = e->v[4];
const int64_t u = t->u, v = t->v, q = t->q, r = t->r;
int64_t md, me, sd, se;
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_int128 cd, ce;
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
#ifdef VERIFY
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(d, 5, &modinfo->modulus, -2) > 0); /* d > -2*modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(d, 5, &modinfo->modulus, 1) < 0); /* d < modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(e, 5, &modinfo->modulus, -2) > 0); /* e > -2*modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(e, 5, &modinfo->modulus, 1) < 0); /* e < modulus */
VERIFY_CHECK((secp256k1_modinv64_abs(u) + secp256k1_modinv64_abs(v)) >= 0); /* |u|+|v| doesn't overflow */
VERIFY_CHECK((secp256k1_modinv64_abs(q) + secp256k1_modinv64_abs(r)) >= 0); /* |q|+|r| doesn't overflow */
VERIFY_CHECK((secp256k1_modinv64_abs(u) + secp256k1_modinv64_abs(v)) <= M62 + 1); /* |u|+|v| <= 2^62 */
VERIFY_CHECK((secp256k1_modinv64_abs(q) + secp256k1_modinv64_abs(r)) <= M62 + 1); /* |q|+|r| <= 2^62 */
#endif
/* [md,me] start as zero; plus [u,q] if d is negative; plus [v,r] if e is negative. */
sd = d4 >> 63;
se = e4 >> 63;
md = (u & sd) + (v & se);
me = (q & sd) + (r & se);
/* Begin computing t*[d,e]. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_mul(&cd, u, d0);
secp256k1_i128_accum_mul(&cd, v, e0);
secp256k1_i128_mul(&ce, q, d0);
secp256k1_i128_accum_mul(&ce, r, e0);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Correct md,me so that t*[d,e]+modulus*[md,me] has 62 zero bottom bits. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
md -= (modinfo->modulus_inv62 * (uint64_t)secp256k1_i128_to_i64(&cd) + md) & M62;
me -= (modinfo->modulus_inv62 * (uint64_t)secp256k1_i128_to_i64(&ce) + me) & M62;
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Update the beginning of computation for t*[d,e]+modulus*[md,me] now md,me are known. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cd, modinfo->modulus.v[0], md);
secp256k1_i128_accum_mul(&ce, modinfo->modulus.v[0], me);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Verify that the low 62 bits of the computation are indeed zero, and then throw them away. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
VERIFY_CHECK((secp256k1_i128_to_i64(&cd) & M62) == 0); secp256k1_i128_rshift(&cd, 62);
VERIFY_CHECK((secp256k1_i128_to_i64(&ce) & M62) == 0); secp256k1_i128_rshift(&ce, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Compute limb 1 of t*[d,e]+modulus*[md,me], and store it as output limb 0 (= down shift). */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cd, u, d1);
secp256k1_i128_accum_mul(&cd, v, e1);
secp256k1_i128_accum_mul(&ce, q, d1);
secp256k1_i128_accum_mul(&ce, r, e1);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
if (modinfo->modulus.v[1]) { /* Optimize for the case where limb of modulus is zero. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cd, modinfo->modulus.v[1], md);
secp256k1_i128_accum_mul(&ce, modinfo->modulus.v[1], me);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
}
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
d->v[0] = secp256k1_i128_to_i64(&cd) & M62; secp256k1_i128_rshift(&cd, 62);
e->v[0] = secp256k1_i128_to_i64(&ce) & M62; secp256k1_i128_rshift(&ce, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Compute limb 2 of t*[d,e]+modulus*[md,me], and store it as output limb 1. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cd, u, d2);
secp256k1_i128_accum_mul(&cd, v, e2);
secp256k1_i128_accum_mul(&ce, q, d2);
secp256k1_i128_accum_mul(&ce, r, e2);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
if (modinfo->modulus.v[2]) { /* Optimize for the case where limb of modulus is zero. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cd, modinfo->modulus.v[2], md);
secp256k1_i128_accum_mul(&ce, modinfo->modulus.v[2], me);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
}
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
d->v[1] = secp256k1_i128_to_i64(&cd) & M62; secp256k1_i128_rshift(&cd, 62);
e->v[1] = secp256k1_i128_to_i64(&ce) & M62; secp256k1_i128_rshift(&ce, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Compute limb 3 of t*[d,e]+modulus*[md,me], and store it as output limb 2. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cd, u, d3);
secp256k1_i128_accum_mul(&cd, v, e3);
secp256k1_i128_accum_mul(&ce, q, d3);
secp256k1_i128_accum_mul(&ce, r, e3);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
if (modinfo->modulus.v[3]) { /* Optimize for the case where limb of modulus is zero. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cd, modinfo->modulus.v[3], md);
secp256k1_i128_accum_mul(&ce, modinfo->modulus.v[3], me);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
}
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
d->v[2] = secp256k1_i128_to_i64(&cd) & M62; secp256k1_i128_rshift(&cd, 62);
e->v[2] = secp256k1_i128_to_i64(&ce) & M62; secp256k1_i128_rshift(&ce, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Compute limb 4 of t*[d,e]+modulus*[md,me], and store it as output limb 3. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cd, u, d4);
secp256k1_i128_accum_mul(&cd, v, e4);
secp256k1_i128_accum_mul(&ce, q, d4);
secp256k1_i128_accum_mul(&ce, r, e4);
secp256k1_i128_accum_mul(&cd, modinfo->modulus.v[4], md);
secp256k1_i128_accum_mul(&ce, modinfo->modulus.v[4], me);
d->v[3] = secp256k1_i128_to_i64(&cd) & M62; secp256k1_i128_rshift(&cd, 62);
e->v[3] = secp256k1_i128_to_i64(&ce) & M62; secp256k1_i128_rshift(&ce, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* What remains is limb 5 of t*[d,e]+modulus*[md,me]; store it as output limb 4. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
d->v[4] = secp256k1_i128_to_i64(&cd);
e->v[4] = secp256k1_i128_to_i64(&ce);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
#ifdef VERIFY
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(d, 5, &modinfo->modulus, -2) > 0); /* d > -2*modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(d, 5, &modinfo->modulus, 1) < 0); /* d < modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(e, 5, &modinfo->modulus, -2) > 0); /* e > -2*modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(e, 5, &modinfo->modulus, 1) < 0); /* e < modulus */
#endif
}
/* Compute (t/2^62) * [f, g], where t is a transition matrix scaled by 2^62.
*
* This implements the update_fg function from the explanation.
*/
static void secp256k1_modinv64_update_fg_62(secp256k1_modinv64_signed62 *f, secp256k1_modinv64_signed62 *g, const secp256k1_modinv64_trans2x2 *t) {
const int64_t M62 = (int64_t)(UINT64_MAX >> 2);
const int64_t f0 = f->v[0], f1 = f->v[1], f2 = f->v[2], f3 = f->v[3], f4 = f->v[4];
const int64_t g0 = g->v[0], g1 = g->v[1], g2 = g->v[2], g3 = g->v[3], g4 = g->v[4];
const int64_t u = t->u, v = t->v, q = t->q, r = t->r;
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_int128 cf, cg;
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Start computing t*[f,g]. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_mul(&cf, u, f0);
secp256k1_i128_accum_mul(&cf, v, g0);
secp256k1_i128_mul(&cg, q, f0);
secp256k1_i128_accum_mul(&cg, r, g0);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Verify that the bottom 62 bits of the result are zero, and then throw them away. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
VERIFY_CHECK((secp256k1_i128_to_i64(&cf) & M62) == 0); secp256k1_i128_rshift(&cf, 62);
VERIFY_CHECK((secp256k1_i128_to_i64(&cg) & M62) == 0); secp256k1_i128_rshift(&cg, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Compute limb 1 of t*[f,g], and store it as output limb 0 (= down shift). */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cf, u, f1);
secp256k1_i128_accum_mul(&cf, v, g1);
secp256k1_i128_accum_mul(&cg, q, f1);
secp256k1_i128_accum_mul(&cg, r, g1);
f->v[0] = secp256k1_i128_to_i64(&cf) & M62; secp256k1_i128_rshift(&cf, 62);
g->v[0] = secp256k1_i128_to_i64(&cg) & M62; secp256k1_i128_rshift(&cg, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Compute limb 2 of t*[f,g], and store it as output limb 1. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cf, u, f2);
secp256k1_i128_accum_mul(&cf, v, g2);
secp256k1_i128_accum_mul(&cg, q, f2);
secp256k1_i128_accum_mul(&cg, r, g2);
f->v[1] = secp256k1_i128_to_i64(&cf) & M62; secp256k1_i128_rshift(&cf, 62);
g->v[1] = secp256k1_i128_to_i64(&cg) & M62; secp256k1_i128_rshift(&cg, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Compute limb 3 of t*[f,g], and store it as output limb 2. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cf, u, f3);
secp256k1_i128_accum_mul(&cf, v, g3);
secp256k1_i128_accum_mul(&cg, q, f3);
secp256k1_i128_accum_mul(&cg, r, g3);
f->v[2] = secp256k1_i128_to_i64(&cf) & M62; secp256k1_i128_rshift(&cf, 62);
g->v[2] = secp256k1_i128_to_i64(&cg) & M62; secp256k1_i128_rshift(&cg, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Compute limb 4 of t*[f,g], and store it as output limb 3. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cf, u, f4);
secp256k1_i128_accum_mul(&cf, v, g4);
secp256k1_i128_accum_mul(&cg, q, f4);
secp256k1_i128_accum_mul(&cg, r, g4);
f->v[3] = secp256k1_i128_to_i64(&cf) & M62; secp256k1_i128_rshift(&cf, 62);
g->v[3] = secp256k1_i128_to_i64(&cg) & M62; secp256k1_i128_rshift(&cg, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* What remains is limb 5 of t*[f,g]; store it as output limb 4. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
f->v[4] = secp256k1_i128_to_i64(&cf);
g->v[4] = secp256k1_i128_to_i64(&cg);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
}
/* Compute (t/2^62) * [f, g], where t is a transition matrix for 62 divsteps.
*
* Version that operates on a variable number of limbs in f and g.
*
* This implements the update_fg function from the explanation.
*/
static void secp256k1_modinv64_update_fg_62_var(int len, secp256k1_modinv64_signed62 *f, secp256k1_modinv64_signed62 *g, const secp256k1_modinv64_trans2x2 *t) {
const int64_t M62 = (int64_t)(UINT64_MAX >> 2);
const int64_t u = t->u, v = t->v, q = t->q, r = t->r;
int64_t fi, gi;
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_int128 cf, cg;
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
int i;
VERIFY_CHECK(len > 0);
/* Start computing t*[f,g]. */
fi = f->v[0];
gi = g->v[0];
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_mul(&cf, u, fi);
secp256k1_i128_accum_mul(&cf, v, gi);
secp256k1_i128_mul(&cg, q, fi);
secp256k1_i128_accum_mul(&cg, r, gi);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Verify that the bottom 62 bits of the result are zero, and then throw them away. */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
VERIFY_CHECK((secp256k1_i128_to_i64(&cf) & M62) == 0); secp256k1_i128_rshift(&cf, 62);
VERIFY_CHECK((secp256k1_i128_to_i64(&cg) & M62) == 0); secp256k1_i128_rshift(&cg, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
/* Now iteratively compute limb i=1..len of t*[f,g], and store them in output limb i-1 (shifting
* down by 62 bits). */
for (i = 1; i < len; ++i) {
fi = f->v[i];
gi = g->v[i];
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
secp256k1_i128_accum_mul(&cf, u, fi);
secp256k1_i128_accum_mul(&cf, v, gi);
secp256k1_i128_accum_mul(&cg, q, fi);
secp256k1_i128_accum_mul(&cg, r, gi);
f->v[i - 1] = secp256k1_i128_to_i64(&cf) & M62; secp256k1_i128_rshift(&cf, 62);
g->v[i - 1] = secp256k1_i128_to_i64(&cg) & M62; secp256k1_i128_rshift(&cg, 62);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
}
/* What remains is limb (len) of t*[f,g]; store it as output limb (len-1). */
Squashed 'src/secp256k1/' changes from 44c2452fd3..21ffe4b22a 21ffe4b22a Merge bitcoin-core/secp256k1#1055: Prepare initial release e025ccdf74 release: prepare for initial release 0.2.0 6d1784a2e2 build: add missing files to EXTRA_DIST 8c949f56da Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now 13bf1b6b32 changelog: make order of change types match keepachangelog.com b1f992a552 doc: improve release process 7e5b22684f Don't use compute credits for now ad39e2dc41 build: change package version to 0.1.0-dev 5c789dcd73 Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags with NONE in benchmarks and tests d6dc0f4ae3 tests: Switch to NONE contexts in module tests 0c8a5caddd tests: Switch to NONE contexts in tests.c 86540e9e1f tests: add test for deprecated flags and rm them from run_context caa0ad631e group: add gej_eq_var 37ba744f5b tests: Switch to NONE contexts in exhaustive and ctime tests 8d7a9a8eda benchmarks: Switch to NONE contexts 90618e9263 doc: move CHANGELOG from doc/ to root directory e3f84777eb Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts 4386a2306c examples: Switch to NONE contexts 7289b51d31 docs: Use doxygen style if and only if comment is user-facing e7d0185c90 docs: Get rid of "initialized for signing" terminology 06126364ad docs: Tidy and improve docs about contexts and randomization e02d6862bd selftest: Expose in public API e383fbfa66 selftest: Rename internal function to make name available for API d2c6d48de3 tests: Use new name of static context 53796d2b24 contexts: Rename static context 72fedf8a6c docs: Improve docs for static context 316ac7625a contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE 477f02c4de Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files autogenerated by sage [skip ci] 092be61c5e gitignore: Add *.sage.py files autogenerated by sage 1a553ee8be docs: Change signature "validation" to "verification" ee7341fbac docs: Never require a verification context 751c4354d5 Merge bitcoin-core/secp256k1#1152: Update macOS image for CI 2286f80902 Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by default e40fd277b7 Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic 99bd335599 Make int128 overflow test use secp256k1_[ui]128_mul a8494b02bf Use compute credits for macOS jobs 3afce0af7c Avoid signed overflow in MSVC AMR64 secp256k1_mul128 c0ae48c995 Update macOS image for CI 9b5f589d30 Heuristically decide whether to use int128_struct 63ff064d2f int128: Add test override for testing __(u)mulh on MSVC X64 f2b7e88768 Add int128 randomized tests 6138d73be4 Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs ddf2b2910e Merge bitcoin-core/secp256k1#1000: Synthetic int128 type. 86e3b38a4a Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-test file 00a42b91b3 Add MSan CI job 44916ae915 Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing the job outside of CI c2ee9175e9 Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not found" irrelevant error e13fae487e Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log a340d9500a ci: add int128_struct tests dceaa1f579 int128: Tidy #includes of int128.h and int128_impl.h 2914bccbc0 Simulated int128 type. 6a965b6b98 Remove usage of CHECK from non-test file 5c9f1a5c37 ci: always cat all logs_snippets 49ae843592 ci: mostly prevent "-v/--version: not found" irrelevant error 4e54c03153 ci: print env to allow reproducing the job outside of CI a43e982bca Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file f5039cb66c Cleanup `.gitignore` file 798727ae1e Revert "Add test logs to gitignore" 41e8704b48 build: Enable some modules by default 694ce8fb2d Merge bitcoin-core/secp256k1#1131: readme: Misc improvements 88b00897e7 readme: Fix line break 78f5296da4 readme: Sell "no runtime dependencies" ef48f088ad readme: Add IRC channel 9f8a13dc8e Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros again (reintroduced by mismerge) cabe085bb4 configure: Remove pkgconfig macros again (reintroduced by mismerge) 3efeb9da21 Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults for ECMULT_* config values 6a873cc4a9 Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with probability 15/16 instead of 1/4 17065f48ae tests: Randomize the context with probability 15/16 instead of 1/4 c27ae45144 config: Remove basic-config.h da6514a04a config: Introduce DEBUG_CONFIG macro for debug output of config 63a3565e97 Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating blinding if no seed is available d0cf55e13a config: Set preprocessor defaults for ECMULT_* config values 55f8bc99dc ecmult_gen: Improve comments about projective blinding 7a86955800 ecmult_gen: Simplify code (no observable change) 4cc0b1b669 ecmult_gen: Skip RNG when creating blinding if no seed is available af65d30cc8 Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to get rid of further -I arguments 40a3473a9d build: Fix #include "..." paths to get rid of further -I arguments 43756da819 Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in group.h 069aba8125 Fix sepc256k1 -> secp256k1 typo in group.h accadc94df Merge bitcoin-core/secp256k1#1114: `_scratch_destroy`: move `VERIFY_CHECK` after invalid scrach space check cd47033335 Merge bitcoin-core/secp256k1#1084: ci: Add MSVC builds 1827c9bf2b scratch_destroy: move VERIFY_CHECK after invalid scrach space check 49e2acd927 configure: Improve rationale for WERROR_CFLAGS 8dc4b03341 ci: Add a C++ job that compiles the public headers without -fpermissive 51f296a46c ci: Run persistent wineserver to speed up wine 3fb3269c22 ci: Add 32-bit MinGW64 build 9efc2e5221 ci: Add MSVC builds 2be6ba0fed configure: Convince autotools to work with MSVC's archiver lib.exe bd81f4140a schnorrsig bench: Suppress a stupid warning in MSVC 09f3d71c51 configure: Add a few CFLAGS for MSVC 3b4f3d0d46 build: Reject C++ compilers in the preprocessor 1cc0941414 configure: Don't abort if the compiler does not define __STDC__ cca8cbbac8 configure: Output message when checking for valgrind 1a6be5745f bench: Make benchmarks compile on MSVC git-subtree-dir: src/secp256k1 git-subtree-split: 21ffe4b22a9683cf24ae0763359e401d1284cc7a
2022-12-13 05:40:36 +01:00
f->v[len - 1] = secp256k1_i128_to_i64(&cf);
g->v[len - 1] = secp256k1_i128_to_i64(&cg);
Squashed 'src/secp256k1/' changes from 3967d96bf1..efad3506a8 efad3506a8 Merge #906: Use modified divsteps with initial delta=1/2 for constant-time cc2c09e3a7 Merge #918: Clean up configuration in gen_context 07067967ee add ECMULT_GEN_PREC_BITS to basic_config.h a3aa2628c7 gen_context: Don't include basic-config.h be0609fd54 Add unit tests for edge cases with delta=1/2 variant of divsteps cd393ce228 Optimization: only do 59 hddivsteps per iteration instead of 62 277b224b6a Use modified divsteps with initial delta=1/2 for constant-time 376ca366db Fix typo in explanation 1e5d50fa93 Merge #889: fix uninitialized read in tests c083cc6e52 Merge #903: Make argument of fe_normalizes_to_zero{_var} const 6e898534ff Merge #907: changed import to use brackets <> for openssl 4504472269 changed import to use brackets <> for openssl as they are not local to the project 26de4dfeb1 Merge #831: Safegcd inverses, drop Jacobi symbols, remove libgmp 23c3fb629b Make argument of fe_normalizes_to_zero{_var} const 24ad04fc06 Make scalar_inverse{,_var} benchmark scale with SECP256K1_BENCH_ITERS ebc1af700f Optimization: track f,g limb count and pass to new variable-time update_fg_var b306935ac1 Optimization: use formulas instead of lookup tables for cancelling g bits 9164a1b658 Optimization: special-case zero modulus limbs in modinv64 1f233b3fa0 Remove num/gmp support 20448b8d09 Remove unused Jacobi symbol support 5437e7bdfb Remove unused scalar_sqr aa9cc52180 Improve field/scalar inverse tests 1e0e885c8a Make field/scalar code use the new modinv modules for inverses 436281afdc Move secp256k1_fe_inverse{_var} to per-impl files aa404d53be Move secp256k1_scalar_{inverse{_var},is_even} to per-impl files 08d54964e5 Improve bounds checks in modinv modules 151aac00d3 Add tests for modinv modules d8a92fcc4c Add extensive comments on the safegcd algorithm and implementation 8e415acba2 Add safegcd based modular inverse modules de0a643c3d Add secp256k1_ctz{32,64}_var functions 4c3ba88c3a Merge #901: ci: Switch all Linux builds to Debian and more improvements 9361f360bb ci: Select number of parallel make jobs depending on CI environment 28eccdf806 ci: Split output of logs into multiple sections c7f754fe4d ci: Run PRs on merge result instead of on the source branch b994a8be3c ci: Print information about binaries using "file" f24e122d13 ci: Switch all Linux builds to Debian ebdba03cb5 Merge #891: build: Add workaround for automake 1.13 and older 3a8b47bc6d Merge #894: ctime_test: move context randomization test to the end 7d3497cdc4 ctime_test: move context randomization test to the end 99a1cfec17 print warnings for conditional-uninitialized 3d2cf6c5bd initialize variable in tests f329bba244 build: Add workaround for automake 1.13 and older 24d1656c32 Merge #882: Use bit ops instead of int mult for constant-time logic in gej_add_ge e491d06b98 Use bit ops instead of int mult for constant-time logic in gej_add_ge f8c0b57e6b Merge #864: Add support for Cirrus CI cc2a5451dc ci: Refactor Nix shell files 2480e55c8f ci: Remove support for Travis CI 2b359f1c1d ci: Enable simple cache for brewing valgrind on macOS 8c02e465c5 ci: Add support for Cirrus CI 659d0d4798 Merge #880: Add parens around ROUND_TO_ALIGN's parameter. b6f649889a Add parens around ROUND_TO_ALIGN's parameter. This makes the macro robust against a hypothetical ROUND_TO_ALIGN(foo ? sizeA : size B) invocation. a4abaab793 Merge #877: Add missing secp256k1_ge_set_gej_var decl. 5671e5f3fd Merge #874: Remove underscores from header defs. db726782fa Merge #878: Remove unused secp256k1_fe_inv_all_var b732701faa Merge #875: Avoid casting (void**) values. 75d2ae149e Remove unused secp256k1_fe_inv_all_var 482e4a9cfc Add missing secp256k1_ge_set_gej_var decl. 2730618604 Avoid casting (void**) values. Replaced with an expression that only casts (void*) values. fb390c5299 Remove underscores from header defs. This makes them consistent with other files and avoids reserved identifiers. f2d9aeae6d Merge #862: Autoconf improvements 328aaef22a Merge #845: Extract the secret key from a keypair 3c15130709 Improve CC_FOR_BUILD detection 47802a4762 Restructure and tidy configure.ac 252c19dfc6 Ask brew for valgrind include path 8c727b9087 Merge #860: fixed trivial typo b7bc3a4aaa fixed typo 33cb3c2b1f Add secret key extraction from keypair to constant time tests 36d9dc1e8e Add seckey extraction from keypair to the extrakeys tests fc96aa73f5 Add a function to extract the secretkey from a keypair 98dac87839 Merge #858: Fix insecure links 07aa4c70ff Fix insecure links b61f9da54e Merge #857: docs: fix simple typo, dependecy -> dependency 18aadf9d28 docs: fix simple typo, dependecy -> dependency 2d9e7175c6 Merge #852: Add sage script for generating scalar_split_lambda constants dc6e5c3a5c Merge #854: Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 6e85d675aa Rename tweak to tweak32 in public API f587f04e35 Rename msg32 to msghash32 in ecdsa_sign/verify and add explanation 329a2e0a3f sage: Add script for generating scalar_split_lambda constants 8f0c6f1545 Merge #851: make test count iteration configurable by environment variable f4fa8d226a forbid a test iteration of 0 or less f554dfc708 sage: Reorganize files 3a106966aa Merge #849: Convert Sage code to Python 3 (as used by Sage >= 9) 13c88efed0 Convert Sage code to Python 3 (as used by Sage >= 9) 0ce4554881 make test count iteration configurable by environment variable 9e5939d284 Merge #835: Don't use reserved identifiers memczero and benchmark_verify_t d0a83f7328 Merge #839: Prevent arithmetic on NULL pointer if the scratch space is too small 903b16aa6c Merge #840: Return NULL early in context_preallocated_create if flags invalid 1f4dd03838 Typedef (u)int128_t only when they're not provided by the compiler ebfa2058e9 Return NULL early in context_preallocated_create if flags invalid 29a299e373 Run the undefined behaviour sanitizer on Travis 7506e064d7 Prevent arithmetic on NULL pointer if the scratch space is too small e89278f211 Don't use reserved identifiers memczero and benchmark_verify_t git-subtree-dir: src/secp256k1 git-subtree-split: efad3506a8937162e8010f5839fdf3771dfcf516
2021-04-23 20:35:15 +02:00
}
/* Compute the inverse of x modulo modinfo->modulus, and replace x with it (constant time in x). */
static void secp256k1_modinv64(secp256k1_modinv64_signed62 *x, const secp256k1_modinv64_modinfo *modinfo) {
/* Start with d=0, e=1, f=modulus, g=x, zeta=-1. */
secp256k1_modinv64_signed62 d = {{0, 0, 0, 0, 0}};
secp256k1_modinv64_signed62 e = {{1, 0, 0, 0, 0}};
secp256k1_modinv64_signed62 f = modinfo->modulus;
secp256k1_modinv64_signed62 g = *x;
int i;
int64_t zeta = -1; /* zeta = -(delta+1/2); delta starts at 1/2. */
/* Do 10 iterations of 59 divsteps each = 590 divsteps. This suffices for 256-bit inputs. */
for (i = 0; i < 10; ++i) {
/* Compute transition matrix and new zeta after 59 divsteps. */
secp256k1_modinv64_trans2x2 t;
zeta = secp256k1_modinv64_divsteps_59(zeta, f.v[0], g.v[0], &t);
/* Update d,e using that transition matrix. */
secp256k1_modinv64_update_de_62(&d, &e, &t, modinfo);
/* Update f,g using that transition matrix. */
#ifdef VERIFY
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&f, 5, &modinfo->modulus, -1) > 0); /* f > -modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&f, 5, &modinfo->modulus, 1) <= 0); /* f <= modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&g, 5, &modinfo->modulus, -1) > 0); /* g > -modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&g, 5, &modinfo->modulus, 1) < 0); /* g < modulus */
#endif
secp256k1_modinv64_update_fg_62(&f, &g, &t);
#ifdef VERIFY
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&f, 5, &modinfo->modulus, -1) > 0); /* f > -modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&f, 5, &modinfo->modulus, 1) <= 0); /* f <= modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&g, 5, &modinfo->modulus, -1) > 0); /* g > -modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&g, 5, &modinfo->modulus, 1) < 0); /* g < modulus */
#endif
}
/* At this point sufficient iterations have been performed that g must have reached 0
* and (if g was not originally 0) f must now equal +/- GCD of the initial f, g
* values i.e. +/- 1, and d now contains +/- the modular inverse. */
#ifdef VERIFY
/* g == 0 */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&g, 5, &SECP256K1_SIGNED62_ONE, 0) == 0);
/* |f| == 1, or (x == 0 and d == 0 and |f|=modulus) */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&f, 5, &SECP256K1_SIGNED62_ONE, -1) == 0 ||
secp256k1_modinv64_mul_cmp_62(&f, 5, &SECP256K1_SIGNED62_ONE, 1) == 0 ||
(secp256k1_modinv64_mul_cmp_62(x, 5, &SECP256K1_SIGNED62_ONE, 0) == 0 &&
secp256k1_modinv64_mul_cmp_62(&d, 5, &SECP256K1_SIGNED62_ONE, 0) == 0 &&
(secp256k1_modinv64_mul_cmp_62(&f, 5, &modinfo->modulus, 1) == 0 ||
secp256k1_modinv64_mul_cmp_62(&f, 5, &modinfo->modulus, -1) == 0)));
#endif
/* Optionally negate d, normalize to [0,modulus), and return it. */
secp256k1_modinv64_normalize_62(&d, f.v[4], modinfo);
*x = d;
}
/* Compute the inverse of x modulo modinfo->modulus, and replace x with it (variable time). */
static void secp256k1_modinv64_var(secp256k1_modinv64_signed62 *x, const secp256k1_modinv64_modinfo *modinfo) {
/* Start with d=0, e=1, f=modulus, g=x, eta=-1. */
secp256k1_modinv64_signed62 d = {{0, 0, 0, 0, 0}};
secp256k1_modinv64_signed62 e = {{1, 0, 0, 0, 0}};
secp256k1_modinv64_signed62 f = modinfo->modulus;
secp256k1_modinv64_signed62 g = *x;
#ifdef VERIFY
int i = 0;
#endif
int j, len = 5;
int64_t eta = -1; /* eta = -delta; delta is initially 1 */
int64_t cond, fn, gn;
/* Do iterations of 62 divsteps each until g=0. */
while (1) {
/* Compute transition matrix and new eta after 62 divsteps. */
secp256k1_modinv64_trans2x2 t;
eta = secp256k1_modinv64_divsteps_62_var(eta, f.v[0], g.v[0], &t);
/* Update d,e using that transition matrix. */
secp256k1_modinv64_update_de_62(&d, &e, &t, modinfo);
/* Update f,g using that transition matrix. */
#ifdef VERIFY
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&f, len, &modinfo->modulus, -1) > 0); /* f > -modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&f, len, &modinfo->modulus, 1) <= 0); /* f <= modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&g, len, &modinfo->modulus, -1) > 0); /* g > -modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&g, len, &modinfo->modulus, 1) < 0); /* g < modulus */
#endif
secp256k1_modinv64_update_fg_62_var(len, &f, &g, &t);
/* If the bottom limb of g is zero, there is a chance that g=0. */
if (g.v[0] == 0) {
cond = 0;
/* Check if the other limbs are also 0. */
for (j = 1; j < len; ++j) {
cond |= g.v[j];
}
/* If so, we're done. */
if (cond == 0) break;
}
/* Determine if len>1 and limb (len-1) of both f and g is 0 or -1. */
fn = f.v[len - 1];
gn = g.v[len - 1];
cond = ((int64_t)len - 2) >> 63;
cond |= fn ^ (fn >> 63);
cond |= gn ^ (gn >> 63);
/* If so, reduce length, propagating the sign of f and g's top limb into the one below. */
if (cond == 0) {
f.v[len - 2] |= (uint64_t)fn << 62;
g.v[len - 2] |= (uint64_t)gn << 62;
--len;
}
#ifdef VERIFY
VERIFY_CHECK(++i < 12); /* We should never need more than 12*62 = 744 divsteps */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&f, len, &modinfo->modulus, -1) > 0); /* f > -modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&f, len, &modinfo->modulus, 1) <= 0); /* f <= modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&g, len, &modinfo->modulus, -1) > 0); /* g > -modulus */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&g, len, &modinfo->modulus, 1) < 0); /* g < modulus */
#endif
}
/* At this point g is 0 and (if g was not originally 0) f must now equal +/- GCD of
* the initial f, g values i.e. +/- 1, and d now contains +/- the modular inverse. */
#ifdef VERIFY
/* g == 0 */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&g, len, &SECP256K1_SIGNED62_ONE, 0) == 0);
/* |f| == 1, or (x == 0 and d == 0 and |f|=modulus) */
VERIFY_CHECK(secp256k1_modinv64_mul_cmp_62(&f, len, &SECP256K1_SIGNED62_ONE, -1) == 0 ||
secp256k1_modinv64_mul_cmp_62(&f, len, &SECP256K1_SIGNED62_ONE, 1) == 0 ||
(secp256k1_modinv64_mul_cmp_62(x, 5, &SECP256K1_SIGNED62_ONE, 0) == 0 &&
secp256k1_modinv64_mul_cmp_62(&d, 5, &SECP256K1_SIGNED62_ONE, 0) == 0 &&
(secp256k1_modinv64_mul_cmp_62(&f, len, &modinfo->modulus, 1) == 0 ||
secp256k1_modinv64_mul_cmp_62(&f, len, &modinfo->modulus, -1) == 0)));
#endif
/* Optionally negate d, normalize to [0,modulus), and return it. */
secp256k1_modinv64_normalize_62(&d, f.v[len - 1], modinfo);
*x = d;
}
#endif /* SECP256K1_MODINV64_IMPL_H */