Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream PRs 1228, 1236, 1243, 1238, 1246, 1247, 1242, 1250, 1244, 1241, 1257, 1226, 1252, 1118, 1245, 1266, 1269 #253

Closed
wants to merge 274 commits into from
Closed
Changes from 3 commits
Commits
Show all changes
274 commits
Select commit Hold shift + click to select a range
43756da
Merge bitcoin-core/secp256k1#1115: Fix sepc256k1 -> secp256k1 typo in…
real-or-random Jun 30, 2022
40a3473
build: Fix #include "..." paths to get rid of further -I arguments
real-or-random Jun 30, 2022
af65d30
Merge bitcoin-core/secp256k1#1116: build: Fix #include "..." paths to…
real-or-random Jul 1, 2022
4cc0b1b
ecmult_gen: Skip RNG when creating blinding if no seed is available
real-or-random Jul 5, 2022
7a86955
ecmult_gen: Simplify code (no observable change)
real-or-random Jul 5, 2022
55f8bc9
ecmult_gen: Improve comments about projective blinding
real-or-random Jul 5, 2022
d0cf55e
config: Set preprocessor defaults for ECMULT_* config values
real-or-random Jul 6, 2022
63a3565
Merge bitcoin-core/secp256k1#1120: ecmult_gen: Skip RNG when creating…
real-or-random Jul 7, 2022
da6514a
config: Introduce DEBUG_CONFIG macro for debug output of config
real-or-random Jul 6, 2022
c27ae45
config: Remove basic-config.h
real-or-random Jul 6, 2022
17065f4
tests: Randomize the context with probability 15/16 instead of 1/4
real-or-random Jul 7, 2022
6a873cc
Merge bitcoin-core/secp256k1#1122: tests: Randomize the context with …
jonasnick Jul 11, 2022
3efeb9d
Merge bitcoin-core/secp256k1#1121: config: Set preprocessor defaults …
jonasnick Jul 11, 2022
cabe085
configure: Remove pkgconfig macros again (reintroduced by mismerge)
real-or-random Jul 21, 2022
9f8a13d
Merge bitcoin-core/secp256k1#1128: configure: Remove pkgconfig macros…
real-or-random Jul 21, 2022
ef48f08
readme: Add IRC channel
real-or-random Aug 2, 2022
78f5296
readme: Sell "no runtime dependencies"
real-or-random Aug 2, 2022
88b0089
readme: Fix line break
real-or-random Aug 2, 2022
694ce8f
Merge bitcoin-core/secp256k1#1131: readme: Misc improvements
real-or-random Aug 2, 2022
41e8704
build: Enable some modules by default
real-or-random Oct 19, 2021
798727a
Revert "Add test logs to gitignore"
hebasto Oct 28, 2022
f5039cb
Cleanup `.gitignore` file
hebasto Oct 28, 2022
a43e982
Merge bitcoin-core/secp256k1#1144: Cleanup `.gitignore` file
jonasnick Nov 1, 2022
4e54c03
ci: print env to allow reproducing the job outside of CI
jonasnick Nov 2, 2022
49ae843
ci: mostly prevent "-v/--version: not found" irrelevant error
jonasnick Nov 2, 2022
5c9f1a5
ci: always cat all logs_snippets
jonasnick Nov 7, 2022
6a965b6
Remove usage of CHECK from non-test file
tcharding Nov 4, 2022
2914bcc
Simulated int128 type.
roconnor-blockstream Jul 27, 2022
dceaa1f
int128: Tidy #includes of int128.h and int128_impl.h
real-or-random Feb 1, 2022
a340d95
ci: add int128_struct tests
jonasnick Nov 2, 2022
e13fae4
Merge bitcoin-core/secp256k1#1150: ci: always cat test_env.log
jonasnick Nov 8, 2022
c2ee917
Merge bitcoin-core/secp256k1#1146: ci: prevent "-v/--version: not fou…
jonasnick Nov 8, 2022
44916ae
Merge bitcoin-core/secp256k1#1147: ci: print env to allow reproducing…
real-or-random Nov 14, 2022
00a42b9
Add MSan CI job
sipa Nov 16, 2022
86e3b38
Merge bitcoin-core/secp256k1#1149: Remove usage of CHECK from non-tes…
real-or-random Nov 16, 2022
ddf2b29
Merge bitcoin-core/secp256k1#1000: Synthetic int128 type.
real-or-random Nov 16, 2022
6138d73
Merge bitcoin-core/secp256k1#1155: Add MSan CI jobs
jonasnick Nov 17, 2022
f2b7e88
Add int128 randomized tests
sipa Nov 14, 2022
63ff064
int128: Add test override for testing __(u)mulh on MSVC X64
real-or-random Nov 14, 2022
9b5f589
Heuristically decide whether to use int128_struct
sipa Nov 16, 2022
c0ae48c
Update macOS image for CI
sipa Nov 14, 2022
3afce0a
Avoid signed overflow in MSVC AMR64 secp256k1_mul128
sipa Nov 17, 2022
a8494b0
Use compute credits for macOS jobs
sipa Nov 15, 2022
99bd335
Make int128 overflow test use secp256k1_[ui]128_mul
sipa Nov 17, 2022
e40fd27
Merge bitcoin-core/secp256k1#1156: Followups to int128_struct arithmetic
real-or-random Nov 18, 2022
4bc4290
Add a secp256k1_i128_to_u64 function.
roconnor-blockstream Oct 25, 2022
d216475
test secp256k1_i128_to_i64
roconnor-blockstream Nov 21, 2022
2286f80
Merge bitcoin-core/secp256k1#993: Enable non-experimental modules by …
real-or-random Nov 22, 2022
751c435
Merge bitcoin-core/secp256k1#1152: Update macOS image for CI
jonasnick Nov 24, 2022
ee7341f
docs: Never require a verification context
real-or-random Jul 5, 2022
1a553ee
docs: Change signature "validation" to "verification"
real-or-random Jul 5, 2022
092be61
gitignore: Add *.sage.py files autogenerated by sage
real-or-random Dec 1, 2022
477f02c
Merge bitcoin-core/secp256k1#1165: gitignore: Add *.sage.py files aut…
jonasnick Dec 1, 2022
316ac76
contexts: Deprecate all context flags except SECP256K1_CONTEXT_NONE
real-or-random Jul 6, 2022
72fedf8
docs: Improve docs for static context
real-or-random Dec 5, 2022
53796d2
contexts: Rename static context
real-or-random Jul 6, 2022
d2c6d48
tests: Use new name of static context
real-or-random Jul 18, 2022
e383fbf
selftest: Rename internal function to make name available for API
real-or-random Jul 6, 2022
e02d686
selftest: Expose in public API
real-or-random Jul 15, 2022
0612636
docs: Tidy and improve docs about contexts and randomization
real-or-random Dec 5, 2022
e7d0185
docs: Get rid of "initialized for signing" terminology
real-or-random Nov 25, 2022
7289b51
docs: Use doxygen style if and only if comment is user-facing
real-or-random Nov 23, 2022
4386a23
examples: Switch to NONE contexts
real-or-random Nov 25, 2022
e3f8477
Merge bitcoin-core/secp256k1#1126: API cleanup with respect to contexts
jonasnick Dec 6, 2022
90618e9
doc: move CHANGELOG from doc/ to root directory
jonasnick Dec 6, 2022
8d7a9a8
benchmarks: Switch to NONE contexts
jonasnick Nov 28, 2022
37ba744
tests: Switch to NONE contexts in exhaustive and ctime tests
jonasnick Nov 28, 2022
caa0ad6
group: add gej_eq_var
jonasnick Dec 5, 2022
86540e9
tests: add test for deprecated flags and rm them from run_context
jonasnick Nov 28, 2022
0c8a5ca
tests: Switch to NONE contexts in tests.c
jonasnick Nov 28, 2022
d6dc0f4
tests: Switch to NONE contexts in module tests
jonasnick Nov 28, 2022
5c789dc
Merge bitcoin-core/secp256k1#1168: Replace deprecated context flags w…
real-or-random Dec 7, 2022
ad39e2d
build: change package version to 0.1.0-dev
jonasnick Dec 6, 2022
cf66f23
refactor: Add helper function secp256k1_context_is_proper()
real-or-random Dec 5, 2022
c635c1b
Change ARG_CHECK_NO_RETURN to ARG_CHECK_VOID which returns (void)
real-or-random Dec 7, 2022
2551cda
tests: Fix code formatting
real-or-random Dec 7, 2022
a49e094
docs: Fix typo
real-or-random Dec 8, 2022
7e5b226
Don't use compute credits for now
sipa Dec 12, 2022
b1f992a
doc: improve release process
jonasnick Dec 23, 2021
13bf1b6
changelog: make order of change types match keepachangelog.com
jonasnick Dec 12, 2022
8c949f5
Merge bitcoin-core/secp256k1#1173: Don't use compute credits for now
jonasnick Dec 12, 2022
6d1784a
build: add missing files to EXTRA_DIST
jonasnick Dec 12, 2022
e025ccd
release: prepare for initial release 0.2.0
jonasnick Dec 23, 2021
21ffe4b
Merge bitcoin-core/secp256k1#1055: Prepare initial release
sipa Dec 12, 2022
b6b360e
doc: improve message of cleanup commit
jonasnick Dec 12, 2022
02ebc29
release cleanup: bump version after 0.2.0
jonasnick Dec 12, 2022
9a8d65f
Merge bitcoin-core/secp256k1#1174: release cleanup: bump version afte…
jonasnick Dec 12, 2022
cee8223
Mention semantic versioning in changelog
sipa Dec 13, 2022
ac233e1
Add links to diffs to changelog
sipa Dec 13, 2022
2dc133a
Add more changelog entries
sipa Dec 13, 2022
9ecf814
Reduce font size in changelog
sipa Dec 13, 2022
b627ba7
Remove dependency on `src/libsecp256k1-config.h`
hebasto Dec 15, 2022
ad8647f
Drop no longer relevant files from `.gitignore`
hebasto Dec 15, 2022
9c5a4d2
Do not define unused `HAVE_VALGRIND` macro
hebasto Dec 15, 2022
c2e0fda
ci: set -u in cirrus.sh to treat unset variables as an error
jonasnick Nov 8, 2022
7a74688
ci: add missing CFLAGS & CPPFLAGS variable to print_environment
jonasnick Nov 17, 2022
75d7b7f
Merge bitcoin-core/secp256k1#1154: ci: set -u in cirrus.sh to treat u…
real-or-random Dec 19, 2022
665ba77
Merge bitcoin-core/secp256k1#1178: Drop `src/libsecp256k1-config.h`
sipa Dec 20, 2022
881fc33
Consistency in naming of modules
sipa Dec 20, 2022
c30b889
Clarify that the ABI-incompatible versions are earlier
sipa Dec 20, 2022
3f57b9f
Merge bitcoin-core/secp256k1#1177: Some improvements to the changelog
jonasnick Dec 20, 2022
eacad90
Merge bitcoin-core/secp256k1#1171: Change ARG_CHECK_NO_RETURN to ARG_…
jonasnick Dec 21, 2022
01b819a
Merge bitcoin-core/secp256k1#1158: Add a secp256k1_i128_to_u64 function.
real-or-random Dec 21, 2022
c0a555b
Bugfix: pass SECP_CONFIG_DEFINES to bench compilation
sipa Dec 29, 2022
31ed538
Merge bitcoin-core/secp256k1#1183: Bugfix: pass SECP_CONFIG_DEFINES t…
real-or-random Jan 2, 2023
2f9ca28
Drop `SECP_CONFIG_DEFINES` from examples
hebasto Jan 3, 2023
2a39ac1
Merge bitcoin-core/secp256k1#1185: Drop `SECP_CONFIG_DEFINES` from ex…
real-or-random Jan 3, 2023
b198061
tests: Use global copy of secp256k1_context_static instead of clone
real-or-random Dec 7, 2022
18e0db3
tests: Don't recreate global context in scratch space test
real-or-random Jan 4, 2023
ce4f936
tests: Tidy run_context_tests() by extracting functions
real-or-random Dec 7, 2022
f32a36f
tests: Don't use global context for context tests
real-or-random Dec 7, 2022
fc90bb5
refactor: Tidy up main()
real-or-random Jan 4, 2023
a4a0937
tests: Clean up and improve run_context_tests() further
real-or-random Jan 4, 2023
39e8f0e
refactor: Separate run_context_tests into static vs proper contexts
real-or-random Jan 4, 2023
0eb3000
Merge bitcoin-core/secp256k1#1186: tests: Tidy context tests
real-or-random Jan 6, 2023
e862c4a
Makefile: add -I$(top_srcdir)/src to CPPFLAGS for precomputed
whitslack Nov 22, 2022
2037600
tests: Add noverify_tests which is like tests but without VERIFY
real-or-random Jan 5, 2023
cbe41ac
Merge bitcoin-core/secp256k1#1188: tests: Add noverify_tests which is…
sipa Jan 9, 2023
e03ef86
Make all non-API functions (except main) static
sipa Jan 9, 2023
3385a26
refactor: Rename global variables to uppercase in tests
real-or-random Jan 5, 2023
9a93f48
refactor: Rename STTC to STATIC_CTX in tests
real-or-random Jan 5, 2023
cc3b8a4
Merge bitcoin-core/secp256k1#1187: refactor: Rename global variables …
real-or-random Jan 11, 2023
4f1a54e
Move valgrind CPPFLAGS into SECP_CONFIG_DEFINES
sipa Dec 7, 2022
0db05a7
Abstract interactions with valgrind behind new checkmem.h
sipa Dec 6, 2022
8dc6407
Add compile-time error to valgrind_ctime_test
sipa Dec 6, 2022
8e11f89
Add support for msan integration to checkmem.h
sipa Dec 6, 2022
6eed6c1
Update error messages to suggest msan as well
sipa Dec 6, 2022
5048be1
Rename valgrind_ctime_test -> ctime_tests
sipa Dec 6, 2022
1897406
Make ctime tests building configurable
sipa Dec 7, 2022
5e2e6fc
Run ctime test in Linux MSan CI job
sipa Dec 6, 2022
74b026f
Add runtime checking for DECLASSIFY flag
sipa Dec 20, 2022
0f088ec
Rename CTIMETEST -> CTIMETESTS
sipa Dec 20, 2022
88e8072
Merge bitcoin-core/secp256k1#1160: Makefile: add `-I$(top_srcdir)/{in…
real-or-random Jan 12, 2023
d4a6b58
Add `noverify_tests` to `.gitignore`
hebasto Jan 13, 2023
4934aa7
Switch to exhaustive groups with small B coefficient
sipa Jan 10, 2023
ce60785
Introduce SECP256K1_B macro for curve b coefficient
sipa Jan 10, 2023
ff8edf8
Merge bitcoin-core/secp256k1#1193: Add `noverify_tests` to `.gitignore`
real-or-random Jan 14, 2023
f29a327
Merge bitcoin-core/secp256k1#1169: Add support for msan instead of va…
real-or-random Jan 16, 2023
a7a7bfa
Merge bitcoin-core/secp256k1#1190: Make all non-API functions (except…
real-or-random Jan 16, 2023
a01a7d8
Merge bitcoin-core/secp256k1#1192: Switch to exhaustive groups with s…
real-or-random Jan 16, 2023
d6ff738
Ensure safety of ctz_debruijn implementation.
roconnor-blockstream Jan 17, 2023
8f51229
ctime_tests: improve output when CHECKMEM_RUNNING is not defined
jonasnick Jan 18, 2023
b1579cf
Merge bitcoin-core/secp256k1#1194: Ensure safety of ctz_debruijn impl…
real-or-random Jan 18, 2023
4b6df5e
contexts: Forbid cloning/destroying secp256k1_context_static
real-or-random Dec 7, 2022
61841fc
contexts: Forbid randomizing secp256k1_context_static
real-or-random Dec 7, 2022
613626f
Drop no longer used `SECP_TEST_{LIBS,INCLUDE}` variables
hebasto Jan 19, 2023
2cd4e3c
Drop no longer used `SECP_{LIBS,INCLUDE}` variables
hebasto Jan 19, 2023
e39d954
tests: Add CHECK_ILLEGAL(_VOID) macros and use in static ctx tests
real-or-random Jan 17, 2023
ad7433b
Merge bitcoin-core/secp256k1#1196: Drop no longer used variables from…
sipa Jan 19, 2023
233822d
Merge bitcoin-core/secp256k1#1195: ctime_tests: improve output when C…
sipa Jan 19, 2023
5fbff5d
Merge bitcoin-core/secp256k1#1170: contexts: Forbid destroying, cloni…
sipa Jan 19, 2023
620ba3d
benchmarks: fix bench_scalar_split
jonasnick Dec 9, 2022
7f49aa7
ci: add test job with -DVERIFY
jonasnick Dec 9, 2022
eb6beba
scalar: restrict split_lambda args, improve doc and VERIFY_CHECKs
jonasnick Jan 4, 2023
2b77240
Merge bitcoin-core/secp256k1#1172: benchmarks: fix bench_scalar_split
sipa Jan 19, 2023
0ecf318
ci: Use remote pull/merge ref instead of local git merge
real-or-random Jan 27, 2023
c241586
ci: Don't fetch git history
real-or-random Jan 27, 2023
9b7d186
Drop no longer used Autoheader macros
hebasto Jan 28, 2023
1bff200
Merge bitcoin-core/secp256k1#1200: Drop no longer used Autoheader macros
sipa Jan 30, 2023
e1817a6
Merge bitcoin-core/secp256k1#1199: ci: Minor improvements inspired by…
real-or-random Jan 30, 2023
9b60e31
ci: Do not set git's `user.{email,name}` config options
hebasto Jan 30, 2023
ef39721
Do not link `bench` and `ctime_tests` to `COMMON_LIB`
hebasto Jan 30, 2023
5596ec5
Merge bitcoin-core/secp256k1#1203: Do not link `bench` and `ctime_tes…
real-or-random Jan 31, 2023
8ebe5c5
Merge bitcoin-core/secp256k1#1201: ci: Do not set git's `user.{email,…
real-or-random Jan 31, 2023
8c7e0fc
build: Add -Wreserved-identifier supported by clang
real-or-random Feb 2, 2023
1cca7c1
Merge bitcoin-core/secp256k1#1206: build: Add -Wreserved-identifier s…
real-or-random Feb 3, 2023
914276e
build: Add SECP256K1_API_VAR to fix importing variables from DLLs
real-or-random Jan 28, 2023
739c53b
examples: Extend sig examples by call that uses static context
real-or-random Feb 6, 2023
9a5a611
build: Suppress stupid MSVC linker warning
real-or-random Feb 6, 2023
e433034
ci: Shutdown wineserver whenever CI script exits
real-or-random Jan 28, 2023
1b21aa5
Merge bitcoin-core/secp256k1#1078: group: Save a normalize_to_zero in…
sipa Feb 14, 2023
cbd2555
Merge bitcoin-core/secp256k1#1209: build: Add SECP256K1_API_VAR to fi…
real-or-random Feb 21, 2023
5fffb2c
Make secp256k1_i128_check_pow2 support -(2^n)
sipa Dec 10, 2022
04c6c1b
Make secp256k1_modinv64_det_check_pow2 support abs val
sipa Dec 10, 2022
1de2a01
Native jacobi symbol algorithm
sipa Sep 11, 2021
6be0103
Add secp256k1_fe_is_square_var function
sipa Jan 4, 2023
ce3cfc7
doc: Describe Jacobi calculation in safegcd_implementation.md
robot-dreams Nov 10, 2021
09b1d46
Merge bitcoin-core/secp256k1#979: Native jacobi symbol algorithm
real-or-random Mar 1, 2023
5660c13
prevent optimization in algorithms
Harshil-Jani Feb 17, 2023
b081f7e
Add secp256k1_fe_add_int function
sipa Mar 1, 2023
5757318
Merge bitcoin-core/secp256k1#1212: Prevent dead-store elimination whe…
real-or-random Mar 2, 2023
2ef1c9b
Update overflow check
roconnor-blockstream Mar 6, 2023
8962fc9
Merge bitcoin-core/secp256k1#1218: Update overflow check
real-or-random Mar 7, 2023
d232112
Update Changelog
real-or-random Mar 7, 2023
9d1b458
Merge bitcoin-core/secp256k1#1217: Add secp256k1_fe_add_int function
jonasnick Mar 7, 2023
5d8f53e
Remove redudent checks.
roconnor-blockstream Mar 7, 2023
eb8749f
Merge bitcoin-core/secp256k1#1221: Update Changelog
real-or-random Mar 8, 2023
6048e6c
Merge bitcoin-core/secp256k1#1222: Remove redundant checks.
real-or-random Mar 8, 2023
5468d70
build: Add CMake-based build system
hebasto Mar 8, 2023
10602b0
cmake: Export config files
hebasto Mar 8, 2023
e1eb337
ci: Add "x86_64: Windows (VS 2022)" task
hebasto Mar 8, 2023
df323b5
Merge bitcoin-core/secp256k1#1113: build: Add CMake-based build system
sipa Mar 8, 2023
92098d8
changelog: Add entry for CMake
real-or-random Mar 8, 2023
3295aa1
Merge bitcoin-core/secp256k1#1225: changelog: Add entry for CMake
real-or-random Mar 8, 2023
756b61d
readme: Use correct build type in CMake/Windows build instructions
real-or-random Mar 8, 2023
ef4f8bd
Merge bitcoin-core/secp256k1#1227: readme: Use correct build type in …
real-or-random Mar 8, 2023
8be82d4
cmake: Rename project to "libsecp256k1"
hebasto Mar 8, 2023
90b513a
Merge bitcoin-core/secp256k1#1229: cmake: Rename project to "libsecp2…
sipa Mar 8, 2023
b40adf2
release: prepare for 0.3.0
jonasnick Mar 7, 2023
28e63f7
release cleanup: bump version after 0.3.0
jonasnick Mar 8, 2023
bdf3900
Merge bitcoin-core/secp256k1#1223: release: prepare for 0.3.0
jonasnick Mar 8, 2023
5658209
Merge bitcoin-core/secp256k1#1228: release cleanup: bump version afte…
real-or-random Mar 8, 2023
647f0a5
Update comment for secp256k1_modinv32_inv256
roconnor-blockstream Mar 10, 2023
427bc3c
Merge bitcoin-core/secp256k1#1236: Update comment for secp256k1_modin…
sipa Mar 11, 2023
96dd062
build: bump CMake minimum requirement to 3.13
theuni Mar 9, 2023
8e79c7e
build: Ensure no optimization when building for coverage analysis
hebasto Mar 14, 2023
4429a8c
Suppress `-Wunused-parameter` when building for coverage analysis
hebasto Mar 14, 2023
fd2a408
Set ARM ASM symbol visibility to `hidden`
hebasto Mar 15, 2023
0cf2fb9
Merge bitcoin-core/secp256k1#1243: build: Ensure no optimization when…
real-or-random Mar 21, 2023
9c8c4f4
Merge bitcoin-core/secp256k1#1238: build: bump CMake minimum requirem…
real-or-random Mar 21, 2023
5bb03c2
Replace `SECP256K1_ECMULT_TABLE_VERIFY` macro by a function
hebasto Mar 21, 2023
d1e7ca1
Typo
roconnor-blockstream Mar 23, 2023
4ebd828
Apply Checks only in VERIFY mode.
roconnor-blockstream Mar 23, 2023
70be3ca
Merge bitcoin-core/secp256k1#1246: Typo
jonasnick Mar 23, 2023
f16a709
Merge bitcoin-core/secp256k1#1247: Apply Checks only in VERIFY mode.
sipa Mar 24, 2023
464a911
Merge bitcoin-core/secp256k1#1242: Set ARM ASM symbol visibility to `…
real-or-random Mar 26, 2023
0c07c82
Add CMake instructions to release process
real-or-random Mar 8, 2023
3addb4c
build: Improve `SECP_TRY_APPEND_DEFAULT_CFLAGS` macro
hebasto Mar 26, 2023
3e43041
No need to subtract 1 before doing a right shift
roconnor-blockstream Mar 27, 2023
1d8f367
Merge bitcoin-core/secp256k1#1250: No need to subtract 1 before doing…
jonasnick Mar 28, 2023
afd8b23
Merge bitcoin-core/secp256k1#1244: Suppress `-Wunused-parameter` when…
jonasnick Mar 28, 2023
2bca0a5
Merge bitcoin-core/secp256k1#1241: build: Improve `SECP_TRY_APPEND_DE…
jonasnick Mar 28, 2023
3d1f430
Make position of * in pointer declarations in include/ consistent
jonasnick Mar 28, 2023
4a496a3
ct: Use volatile "trick" in all fe/scalar cmov implementations
real-or-random Apr 1, 2023
2d51a45
Merge bitcoin-core/secp256k1#1257: ct: Use volatile "trick" in all fe…
real-or-random Apr 6, 2023
4e68262
Merge bitcoin-core/secp256k1#1226: Add CMake instructions to release …
jonasnick Apr 7, 2023
a0f4644
Merge bitcoin-core/secp256k1#1252: Make position of * in pointer decl…
real-or-random Apr 8, 2023
4485926
Add x-only ecmult_const version for x=n/d
sipa Jul 3, 2022
0f86420
Add exhaustive tests for ecmult_const_xonly
sipa Jan 11, 2023
e5de454
tests: Add Wycheproof ECDSA vectors
RandomLattice Mar 22, 2023
145078c
Merge bitcoin-core/secp256k1#1118: Add x-only ecmult_const version wi…
real-or-random Apr 10, 2023
7b7503d
Merge bitcoin-core/secp256k1#1245: tests: Add Wycheproof ECDSA vectors
sipa Apr 10, 2023
0e09166
changelog: Catch up in preparation of 0.3.1
real-or-random Apr 10, 2023
1d9a13f
changelog: Remove inconsistent newlines
real-or-random Apr 10, 2023
898e1c6
release: Prepare for 0.3.1
real-or-random Apr 10, 2023
ec98fce
Merge bitcoin-core/secp256k1#1266: release: Prepare for 0.3.1
jonasnick Apr 10, 2023
6a37b2a
changelog: Fix link
real-or-random Apr 10, 2023
346a053
Merge bitcoin-core/secp256k1#1269: changelog: Fix link
jonasnick Apr 10, 2023
9a98106
Merge commits '8b013fce 485f608f 44c2452f cd470333 accadc94 43756da8 …
jonasnick Jul 17, 2023
64717a7
Merge commits '8b013fce 485f608f 44c2452f cd470333 accadc94 43756da8 …
jonasnick Jul 17, 2023
e996d07
Merge commits '44916ae9 86e3b38a ddf2b291 6138d73b e40fd277 ' into te…
jonasnick Jul 17, 2023
6c54db1
Merge commits '2286f809 751c4354 477f02c4 e3f84777 5c789dcd 8c949f56 …
jonasnick Jul 18, 2023
304fc88
Merge commits '9a8d65f0 75d7b7f5 665ba77e 3f57b9f7 eacad90f 01b819a8 …
jonasnick Jul 19, 2023
7aa9887
Merge pull request #246 from jonasnick/temp-merge-1187
jonasnick Jul 20, 2023
0d540ec
Merge commits '88e80722 ff8edf89 f29a3270 a7a7bfaf a01a7d86 b1579cf5 …
jonasnick Jul 20, 2023
897c765
Merge elementsproject/secp256k1-zkp#251: Update sync-upstream with ma…
jonasnick Jul 21, 2023
3937cef
Merge elementsproject/secp256k1-zkp#249: Upstream PRs 1160, 1193, 116…
jonasnick Jul 21, 2023
dc73359
Merge commits 'df323b5c 3295aa14 ef4f8bd0 90b513aa bdf39000 ' into te…
jonasnick Jul 21, 2023
d47e4d4
Merge elementsproject/secp256k1-zkp#252: Upstream PRs 1113, 1225, 122…
jonasnick Jul 21, 2023
ecbbfd4
Merge commits '56582094 427bc3cd 0cf2fb91 9c8c4f44 70be3cad f16a709f …
jonasnick Jul 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/ecmult_const.h
Original file line number Diff line number Diff line change
@@ -18,4 +18,25 @@
*/
static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, const secp256k1_scalar *q, int bits);

/**
* Same as secp256k1_ecmult_const, but takes in an x coordinate of the base point
* only, specified as fraction n/d (numerator/denominator). Only the x coordinate of the result is
* returned.
*
* If known_on_curve is 0, a verification is performed that n/d is a valid X
* coordinate, and 0 is returned if not. Otherwise, 1 is returned.
*
* d being NULL is interpreted as d=1. If non-NULL, d must not be zero. q must not be zero.
*
* Constant time in the value of q, but not any other inputs.
*/
static int secp256k1_ecmult_const_xonly(
secp256k1_fe *r,
const secp256k1_fe *n,
const secp256k1_fe *d,
const secp256k1_scalar *q,
int bits,
int known_on_curve
);

#endif /* SECP256K1_ECMULT_CONST_H */
135 changes: 135 additions & 0 deletions src/ecmult_const_impl.h
Original file line number Diff line number Diff line change
@@ -228,4 +228,139 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, cons
secp256k1_fe_mul(&r->z, &r->z, &Z);
}

static int secp256k1_ecmult_const_xonly(secp256k1_fe* r, const secp256k1_fe *n, const secp256k1_fe *d, const secp256k1_scalar *q, int bits, int known_on_curve) {

/* This algorithm is a generalization of Peter Dettman's technique for
* avoiding the square root in a random-basepoint x-only multiplication
* on a Weierstrass curve:
* https://mailarchive.ietf.org/arch/msg/cfrg/7DyYY6gg32wDgHAhgSb6XxMDlJA/
*
*
* === Background: the effective affine technique ===
*
* Let phi_u be the isomorphism that maps (x, y) on secp256k1 curve y^2 = x^3 + 7 to
* x' = u^2*x, y' = u^3*y on curve y'^2 = x'^3 + u^6*7. This new curve has the same order as
* the original (it is isomorphic), but moreover, has the same addition/doubling formulas, as
* the curve b=7 coefficient does not appear in those formulas (or at least does not appear in
* the formulas implemented in this codebase, both affine and Jacobian). See also Example 9.5.2
* in https://www.math.auckland.ac.nz/~sgal018/crypto-book/ch9.pdf.
*
* This means any linear combination of secp256k1 points can be computed by applying phi_u
* (with non-zero u) on all input points (including the generator, if used), computing the
* linear combination on the isomorphic curve (using the same group laws), and then applying
* phi_u^{-1} to get back to secp256k1.
*
* Switching to Jacobian coordinates, note that phi_u applied to (X, Y, Z) is simply
* (X, Y, Z/u). Thus, if we want to compute (X1, Y1, Z) + (X2, Y2, Z), with identical Z
* coordinates, we can use phi_Z to transform it to (X1, Y1, 1) + (X2, Y2, 1) on an isomorphic
* curve where the affine addition formula can be used instead.
* If (X3, Y3, Z3) = (X1, Y1) + (X2, Y2) on that curve, then our answer on secp256k1 is
* (X3, Y3, Z3*Z).
*
* This is the effective affine technique: if we have a linear combination of group elements
* to compute, and all those group elements have the same Z coordinate, we can simply pretend
* that all those Z coordinates are 1, perform the computation that way, and then multiply the
* original Z coordinate back in.
*
* The technique works on any a=0 short Weierstrass curve. It is possible to generalize it to
* other curves too, but there the isomorphic curves will have different 'a' coefficients,
* which typically does affect the group laws.
*
*
* === Avoiding the square root for x-only point multiplication ===
*
* In this function, we want to compute the X coordinate of q*(n/d, y), for
* y = sqrt((n/d)^3 + 7). Its negation would also be a valid Y coordinate, but by convention
* we pick whatever sqrt returns (which we assume to be a deterministic function).
*
* Let g = y^2*d^3 = n^3 + 7*d^3. This also means y = sqrt(g/d^3).
* Further let v = sqrt(d*g), which must exist as d*g = y^2*d^4 = (y*d^2)^2.
*
* The input point (n/d, y) also has Jacobian coordinates:
*
* (n/d, y, 1)
* = (n/d * v^2, y * v^3, v)
* = (n/d * d*g, y * sqrt(d^3*g^3), v)
* = (n/d * d*g, sqrt(y^2 * d^3*g^3), v)
* = (n*g, sqrt(g/d^3 * d^3*g^3), v)
* = (n*g, sqrt(g^4), v)
* = (n*g, g^2, v)
*
* It is easy to verify that both (n*g, g^2, v) and its negation (n*g, -g^2, v) have affine X
* coordinate n/d, and this holds even when the square root function doesn't have a
* determinstic sign. We choose the (n*g, g^2, v) version.
*
* Now switch to the effective affine curve using phi_v, where the input point has coordinates
* (n*g, g^2). Compute (X, Y, Z) = q * (n*g, g^2) there.
*
* Back on secp256k1, that means q * (n*g, g^2, v) = (X, Y, v*Z). This last point has affine X
* coordinate X / (v^2*Z^2) = X / (d*g*Z^2). Determining the affine Y coordinate would involve
* a square root, but as long as we only care about the resulting X coordinate, no square root
* is needed anywhere in this computation.
*/

secp256k1_fe g, i;
secp256k1_ge p;
secp256k1_gej rj;

/* Compute g = (n^3 + B*d^3). */
secp256k1_fe_sqr(&g, n);
secp256k1_fe_mul(&g, &g, n);
if (d) {
secp256k1_fe b;
#ifdef VERIFY
VERIFY_CHECK(!secp256k1_fe_normalizes_to_zero(d));
#endif
secp256k1_fe_sqr(&b, d);
VERIFY_CHECK(SECP256K1_B <= 8); /* magnitude of b will be <= 8 after the next call */
secp256k1_fe_mul_int(&b, SECP256K1_B);
secp256k1_fe_mul(&b, &b, d);
secp256k1_fe_add(&g, &b);
if (!known_on_curve) {
/* We need to determine whether (n/d)^3 + 7 is square.
*
* is_square((n/d)^3 + 7)
* <=> is_square(((n/d)^3 + 7) * d^4)
* <=> is_square((n^3 + 7*d^3) * d)
* <=> is_square(g * d)
*/
secp256k1_fe c;
secp256k1_fe_mul(&c, &g, d);
if (!secp256k1_fe_is_square_var(&c)) return 0;
}
} else {
secp256k1_fe_add_int(&g, SECP256K1_B);
if (!known_on_curve) {
/* g at this point equals x^3 + 7. Test if it is square. */
if (!secp256k1_fe_is_square_var(&g)) return 0;
}
}

/* Compute base point P = (n*g, g^2), the effective affine version of (n*g, g^2, v), which has
* corresponding affine X coordinate n/d. */
secp256k1_fe_mul(&p.x, &g, n);
secp256k1_fe_sqr(&p.y, &g);
p.infinity = 0;

/* Perform x-only EC multiplication of P with q. */
#ifdef VERIFY
VERIFY_CHECK(!secp256k1_scalar_is_zero(q));
#endif
secp256k1_ecmult_const(&rj, &p, q, bits);
#ifdef VERIFY
VERIFY_CHECK(!secp256k1_gej_is_infinity(&rj));
#endif

/* The resulting (X, Y, Z) point on the effective-affine isomorphic curve corresponds to
* (X, Y, Z*v) on the secp256k1 curve. The affine version of that has X coordinate
* (X / (Z^2*d*g)). */
secp256k1_fe_sqr(&i, &rj.z);
secp256k1_fe_mul(&i, &i, &g);
if (d) secp256k1_fe_mul(&i, &i, d);
secp256k1_fe_inv(&i, &i);
secp256k1_fe_mul(r, &rj.x, &i);

return 1;
}

#endif /* SECP256K1_ECMULT_CONST_IMPL_H */
63 changes: 63 additions & 0 deletions src/tests.c
Original file line number Diff line number Diff line change
@@ -4452,6 +4452,68 @@ static void ecmult_const_mult_zero_one(void) {
ge_equals_ge(&res2, &point);
}

static void ecmult_const_mult_xonly(void) {
int i;

/* Test correspondence between secp256k1_ecmult_const and secp256k1_ecmult_const_xonly. */
for (i = 0; i < 2*COUNT; ++i) {
secp256k1_ge base;
secp256k1_gej basej, resj;
secp256k1_fe n, d, resx, v;
secp256k1_scalar q;
int res;
/* Random base point. */
random_group_element_test(&base);
/* Random scalar to multiply it with. */
random_scalar_order_test(&q);
/* If i is odd, n=d*base.x for random non-zero d */
if (i & 1) {
do {
random_field_element_test(&d);
} while (secp256k1_fe_normalizes_to_zero_var(&d));
secp256k1_fe_mul(&n, &base.x, &d);
} else {
n = base.x;
}
/* Perform x-only multiplication. */
res = secp256k1_ecmult_const_xonly(&resx, &n, (i & 1) ? &d : NULL, &q, 256, i & 2);
CHECK(res);
/* Perform normal multiplication. */
secp256k1_gej_set_ge(&basej, &base);
secp256k1_ecmult(&resj, &basej, &q, NULL);
/* Check that resj's X coordinate corresponds with resx. */
secp256k1_fe_sqr(&v, &resj.z);
secp256k1_fe_mul(&v, &v, &resx);
CHECK(check_fe_equal(&v, &resj.x));
}

/* Test that secp256k1_ecmult_const_xonly correctly rejects X coordinates not on curve. */
for (i = 0; i < 2*COUNT; ++i) {
secp256k1_fe x, n, d, c, r;
int res;
secp256k1_scalar q;
random_scalar_order_test(&q);
/* Generate random X coordinate not on the curve. */
do {
random_field_element_test(&x);
secp256k1_fe_sqr(&c, &x);
secp256k1_fe_mul(&c, &c, &x);
secp256k1_fe_add(&c, &secp256k1_fe_const_b);
} while (secp256k1_fe_is_square_var(&c));
/* If i is odd, n=d*x for random non-zero d. */
if (i & 1) {
do {
random_field_element_test(&d);
} while (secp256k1_fe_normalizes_to_zero_var(&d));
secp256k1_fe_mul(&n, &x, &d);
} else {
n = x;
}
res = secp256k1_ecmult_const_xonly(&r, &n, (i & 1) ? &d : NULL, &q, 256, 0);
CHECK(res == 0);
}
}

static void ecmult_const_chain_multiply(void) {
/* Check known result (randomly generated test problem from sage) */
const secp256k1_scalar scalar = SECP256K1_SCALAR_CONST(
@@ -4483,6 +4545,7 @@ static void run_ecmult_const_tests(void) {
ecmult_const_random_mult();
ecmult_const_commutativity();
ecmult_const_chain_multiply();
ecmult_const_mult_xonly();
}

typedef struct {
48 changes: 44 additions & 4 deletions src/tests_exhaustive.c
Original file line number Diff line number Diff line change
@@ -59,6 +59,19 @@ static void random_fe(secp256k1_fe *x) {
}
} while(1);
}

static void random_fe_non_zero(secp256k1_fe *nz) {
int tries = 10;
while (--tries >= 0) {
random_fe(nz);
secp256k1_fe_normalize(nz);
if (!secp256k1_fe_is_zero(nz)) {
break;
}
}
/* Infinitesimal probability of spurious failure here */
CHECK(tries >= 0);
}
/** END stolen from tests.c */

static uint32_t num_cores = 1;
@@ -174,10 +187,37 @@ static void test_exhaustive_ecmult(const secp256k1_ge *group, const secp256k1_ge
secp256k1_ecmult(&tmp, &groupj[r_log], &na, &ng);
ge_equals_gej(&group[(i * r_log + j) % EXHAUSTIVE_TEST_ORDER], &tmp);

if (i > 0) {
secp256k1_ecmult_const(&tmp, &group[i], &ng, 256);
ge_equals_gej(&group[(i * j) % EXHAUSTIVE_TEST_ORDER], &tmp);
}
}
}
}

for (j = 0; j < EXHAUSTIVE_TEST_ORDER; j++) {
for (i = 1; i < EXHAUSTIVE_TEST_ORDER; i++) {
int ret;
secp256k1_gej tmp;
secp256k1_fe xn, xd, tmpf;
secp256k1_scalar ng;

if (skip_section(&iter)) continue;

secp256k1_scalar_set_int(&ng, j);

/* Test secp256k1_ecmult_const. */
secp256k1_ecmult_const(&tmp, &group[i], &ng, 256);
ge_equals_gej(&group[(i * j) % EXHAUSTIVE_TEST_ORDER], &tmp);

if (j != 0) {
/* Test secp256k1_ecmult_const_xonly with all curve X coordinates, and xd=NULL. */
ret = secp256k1_ecmult_const_xonly(&tmpf, &group[i].x, NULL, &ng, 256, 0);
CHECK(ret);
CHECK(secp256k1_fe_equal_var(&tmpf, &group[(i * j) % EXHAUSTIVE_TEST_ORDER].x));

/* Test secp256k1_ecmult_const_xonly with all curve X coordinates, with random xd. */
random_fe_non_zero(&xd);
secp256k1_fe_mul(&xn, &xd, &group[i].x);
ret = secp256k1_ecmult_const_xonly(&tmpf, &xn, &xd, &ng, 256, 0);
CHECK(ret);
CHECK(secp256k1_fe_equal_var(&tmpf, &group[(i * j) % EXHAUSTIVE_TEST_ORDER].x));
}
}
}