1968 Commits

Author SHA1 Message Date
Tim Ruffing
ff33018fe7
Merge ElementsProject/secp256k1-zkp#232: Backports from libsecp256k1 v0.3.2
39407c3f5999aa10e1470bc9eae8f63800a63e51 Mark stack variables as early clobber for technical correctness (Pieter Wuille)
56a5d41429a4daed2b02b59c45022044c3575955 Bugfix: mark outputs as early clobber in scalar x86_64 asm (Pieter Wuille)
c8c0f55a1132c0fc9a726f0a4a1417288163b904 ct: Be cautious and use volatile trick in more "conditional" paths (Tim Ruffing)
3e9428996698257aa2a3b4e974f574b8479f1261 ct: Use volatile trick in scalar_cond_negate (Tim Ruffing)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK 39407c3f5999aa10e1470bc9eae8f63800a63e51 I also verified that the ct time tests pass on GCC 13.1.1 and Clang 15.0.7.

Tree-SHA512: b7e695527ea58cc7b94a5f2fff6473b6779a469bc5c38baf92624b655cbdf303fbd204e6c1395fa02b98db3bc47bab32afe64bae4ab4fab18da856b621aab070
2023-05-14 20:21:19 +02:00
Pieter Wuille
39407c3f59
Mark stack variables as early clobber for technical correctness
In the field 5x52 asm for x86_64, stack variables are provided as outputs.
The existing inputs are all forcibly allocated to registers, so cannot
coincide, but mark them as early clobber anyway to make this clearer.
2023-05-14 17:20:10 +00:00
Pieter Wuille
56a5d41429
Bugfix: mark outputs as early clobber in scalar x86_64 asm
In the existing code, the compiler is allowed to allocate the RSI register
for outputs m0, m1, or m2, which are written to before the input in RSI is
read from. Fix this by marking them as early clobber.

Reported by ehoffman2 in https://github.com/bitcoin-core/secp256k1/issues/766
2023-05-14 17:20:01 +00:00
Tim Ruffing
c8c0f55a11
ct: Be cautious and use volatile trick in more "conditional" paths
- secp256k1_scalar_cadd_bit
 - secp256k1_modinvXX_normalize_YY
 - secp256k1_modinvXX_divsteps_ZZ
 - ECMULT_CONST_TABLE_GET_GE

Even though those code loations are not problematic right now
(with current compilers).
2023-05-14 17:19:04 +00:00
Tim Ruffing
3e94289966
ct: Use volatile trick in scalar_cond_negate 2023-05-14 17:16:50 +00:00
Jonas Nick
edcba04c28
Merge elementsproject/secp256k1-zkp#231: musig: add note about missing verification to partial_sign to doc
4ab4ec38a04c8cc820294704bb5d8958bc222787 musig: add note about missing verification to partial_sign to doc (Jonas Nick)
f50ad760049bb86e81e288456e01fc38ea289776 musig: update version number of BIP (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK 4ab4ec38a04c8cc820294704bb5d8958bc222787

Tree-SHA512: 1e35d83dd97bac96dfbc02d58841582afe67c38562c728bc3c593a797e1316dfdd550c4988dc78557f25a1633711ec13b35f6c5bae0f7dd29c9f1c994ad5c82c
2023-05-12 09:40:51 +00:00
Jonas Nick
4ab4ec38a0
musig: add note about missing verification to partial_sign to doc 2023-05-11 17:50:18 +00:00
Jonas Nick
f50ad76004
musig: update version number of BIP 2023-05-11 17:50:06 +00:00
Jonas Nick
4eab2c2fd8
Merge elementsproject/secp256k1-zkp#230: norm arg: add prove test vectors
f3126fdfec7c4dbfab3acf01714325b027110aff norm arg: remove prove edge tests which are now covered by vectors (Jonas Nick)
847ed9ecb2233f1e233fae1791b5adcdeb3be52b norm arg: add verification to prove vectors (Jonas Nick)
cf797ed2a4ccc7422de2f4081a6d6bcf536d72c8 norm arg: add prove test vectors (Jonas Nick)
095c1e749c106285e8252d6490073974dd4d8fcc norm arg: add prove_const to tests (Jonas Nick)
bf7bf8a64fa7a7256ad64f75ae0bcb9fccbd0ea4 norm arg: split norm_arg_zero into prove_edge and verify_zero_len (Jonas Nick)
a70c4d4a8a6970f8e299de541cc75f2fc2e39e76 norm arg: add test vector for |n| = 0 (Jonas Nick)
f5e4b16f0f96ae871d221900673f426e9c9ce85e norm arg: add test vector for sign bit malleability (Jonas Nick)
c0de361fc53dbfb0b058895f4824eba4d423e191 norm arg: allow X and R to be the point at infinity (Jonas Nick)
f22834f20252f9ca3e17f36093940e2aa2735790 norm arg: add verify vector for n = [0], l = [0] (Jonas Nick)
d8e7f3763bac9e52d07643a01c8352cadded64d2 musig: move ge_{serialize,parse}_ext to module-independent file (Jonas Nick)

Pull request description:

ACKs for top commit:
  Liam-Eagen:
    ACK f3126fd

Tree-SHA512: 1aad86521fce74435beabe7690c7fcc38ad9ae7a884ddcab69ef825b573433f700723a7672d29df1b4465bc33d5957b6a46f657f988cfd2cc73fa94a3472357d
2023-05-09 10:42:07 +00:00
Jonas Nick
f3126fdfec
norm arg: remove prove edge tests which are now covered by vectors 2023-04-25 15:06:57 +00:00
Jonas Nick
847ed9ecb2
norm arg: add verification to prove vectors 2023-04-25 15:06:40 +00:00
Jonas Nick
cf797ed2a4
norm arg: add prove test vectors 2023-04-25 14:56:42 +00:00
Jonas Nick
095c1e749c
norm arg: add prove_const to tests 2023-04-25 14:54:30 +00:00
Jonas Nick
ce18267b66
Merge elementsproject/secp256k1-zkp#229: musig: Fix nits left open in #211
a0b51afc01dfc8dbdc43e4c36825fadf760daa3c musig: VERIFY_CHECK preconditions of _musig_keyaggcoef_internal() (Tim Ruffing)
da7702844e212f0cc165d1560a4dc09a05811dae extrakeys: Clarify comparison order of compare/sort functions (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK a0b51afc01dfc8dbdc43e4c36825fadf760daa3c

Tree-SHA512: ad509d7a55c6f832a25b896b0fe38e259b79864b2a8d1fb337b9d9b4a5e1950a9d579040285465c89d815becc6e49af4129ab2d904d32ac98cef74357a440c89
2023-04-23 08:06:33 +00:00
Jonas Nick
78ed0e09ca
Merge elementsproject/secp256k1-zkp#227: Use relative #include paths and tidy header guards (as in upstream)
e444d24bcad57091746784fcea6d07e95d058cd3 Fix include guards: No _ prefix/suffix but _H suffix (as in upstream) (Tim Ruffing)
0eea7d97abba0cc07515368981c6a30b96ab2428 Use relative #include paths in tests (as in upstream) (Tim Ruffing)
c690d6df700fe63529f7dc2fc02166d107c6b686 Use relative #include paths in benchmarks (as in upstream) (Tim Ruffing)
c565827c1a332c96253d35b85accae9cda4ef00d Use relative #include paths in ctime_test (as in upstream) (Tim Ruffing)
4eca406f4c71646d1812389d684219b481098b7d Use relative #include paths in library (as in upstream) (Tim Ruffing)

Pull request description:

ACKs for top commit:
  apoelstra:
    ACK e444d24bcad57091746784fcea6d07e95d058cd3
  jonasnick:
    ACK e444d24bcad57091746784fcea6d07e95d058cd3

Tree-SHA512: 4d125cf75748f4a921b70ca933ee59c3cf5c0845c6960e6915a322e53840cb3a0955fe5952e654d133ad36991f3268aeee44430cbd6f7d83e333a554c436f39b
2023-04-23 07:50:30 +00:00
Jonas Nick
e7fc61ff16
Merge elementsproject/secp256k1-zkp#228: Simple dedicated -zkp README
4d9d8f92d411edc81f971cdf90696ae2952f4231 Simple dedicated -zkp README (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 4d9d8f92d411edc81f971cdf90696ae2952f4231

Tree-SHA512: bae7aafed0d524d2fea956261547ca094dbaa4b444b56b6f3fb947764cc5647b5eec82ac392f988df3d3d88d1357ae2aa34550c7a596b386a2d0a774f9764661
2023-04-21 16:22:17 +00:00
Tim Ruffing
a0b51afc01 musig: VERIFY_CHECK preconditions of _musig_keyaggcoef_internal() 2023-04-21 16:18:19 +02:00
Tim Ruffing
da7702844e extrakeys: Clarify comparison order of compare/sort functions
Note that the touched functions don't exist upstream currently.
2023-04-21 16:17:52 +02:00
Tim Ruffing
4d9d8f92d4
Simple dedicated -zkp README 2023-04-21 12:38:34 +02:00
Tim Ruffing
e444d24bca Fix include guards: No _ prefix/suffix but _H suffix (as in upstream) 2023-04-21 12:02:28 +02:00
Tim Ruffing
0eea7d97ab Use relative #include paths in tests (as in upstream) 2023-04-21 11:51:04 +02:00
Tim Ruffing
c690d6df70 Use relative #include paths in benchmarks (as in upstream) 2023-04-21 11:50:46 +02:00
Tim Ruffing
c565827c1a Use relative #include paths in ctime_test (as in upstream) 2023-04-21 11:50:34 +02:00
Tim Ruffing
4eca406f4c Use relative #include paths in library (as in upstream) 2023-04-21 11:50:24 +02:00
Jonas Nick
bf7bf8a64f
norm arg: split norm_arg_zero into prove_edge and verify_zero_len
One function tests prover edge cases, the other tests verifier edge cases.
2023-04-20 19:05:22 +00:00
Jonas Nick
a70c4d4a8a
norm arg: add test vector for |n| = 0 2023-04-20 19:03:27 +00:00
Jonas Nick
f5e4b16f0f
norm arg: add test vector for sign bit malleability
R is point at infinity but sign is != 0
2023-04-20 19:02:51 +00:00
Jonas Nick
c0de361fc5
norm arg: allow X and R to be the point at infinity
Add test vector
2023-04-20 19:02:41 +00:00
Jonas Nick
f22834f202
norm arg: add verify vector for n = [0], l = [0] 2023-04-20 19:00:14 +00:00
Jonas Nick
d8e7f3763b
musig: move ge_{serialize,parse}_ext to module-independent file 2023-04-20 18:56:11 +00:00
Jonas Nick
050d9b2912
Merge elementsproject/secp256k1-zkp#226: bppp: align terminology with paper
2c63d17c1e3b89950af9b6e51b14f025a2251c95 bppp: align terminology with paper (gamma) (Jonas Nick)
dbf2e4d3e1dda55a1a33dd4d86918a3c2281d8dc bppp: align terminology with paper (mu, rho) (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    utACK  2c63d17c1e3b89950af9b6e51b14f025a2251c95

Tree-SHA512: 494db14717acf95de74ca14cdbd4908b31a2e81562ca18b8e3ddd795d40f60cd8ea8d7472c348da108db7d314d510f7366dc594809cf29c0c044c701c56119cc
2023-04-20 18:54:16 +00:00
Jonas Nick
2c63d17c1e
bppp: align terminology with paper (gamma)
e -> gamma
2023-04-19 12:37:47 +00:00
Jonas Nick
dbf2e4d3e1
bppp: align terminology with paper (mu, rho)
q-> mu, r -> rho
2023-04-19 12:37:29 +00:00
Tim Ruffing
f4dd0419aa
Merge ElementsProject/secp256k1-zkp#225: sync-upstream: Use --autostash to handle uncommitted changes
13c438cdeed358a20b1f0324ee36a6cadfaf0016 sync-upstream: Use --autostash to handle uncommitted changes (Tim Ruffing)

Pull request description:

  This makes it possible to use sync-upstream with uncommitted changes. (This is in particular helpful when working on the script itself.)

  Without this commit, git pull will fail due to the uncommitted changes.

ACKs for top commit:
  apoelstra:
    utACK 13c438cdeed358a20b1f0324ee36a6cadfaf0016

Tree-SHA512: c3a2fce68382bf4e769c64bbdc5666a8f4d9cf6f387e7d8af408e9c3e07b4a875205b7cdae9f647b7127128c13ee58effc0045ac5faf5fba2851b38af40439e8
2023-04-17 11:49:56 +02:00
Tim Ruffing
13c438cdee sync-upstream: Use --autostash to handle uncommitted changes
This makes it possible to use sync-upstream with uncommitted changes. (This
is in particular helpful when working on the script itself.)

Without this commit, git pull will fail due to the uncommitted changes.
2023-04-11 12:25:51 +02:00
Jonas Nick
6ec1ff6040
Merge elementsproject/secp256k1-zkp#224: Backport of "ct: Use volatile "trick" in all fe/scalar cmov implementations"
96f48538503ff40bf0017652c4b4f3a42cd3fa94 ct: Use volatile "trick" in all fe/scalar cmov implementations (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 96f48538503ff40bf0017652c4b4f3a42cd3fa94

Tree-SHA512: b3524a817ad8787a19dd28fc38523ab0ee2ddb72c5d88dfef566a9baa849b8d6a12df93030ecf97251e078128ec8203478bf98f3e8d9b28cc595ea5e8579c762
2023-04-11 10:15:01 +00:00
Tim Ruffing
96f4853850 ct: Use volatile "trick" in all fe/scalar cmov implementations
Apparently clang 15 is able to compile our cmov code into a branch,
at least for fe_cmov and fe_storage_cmov. This commit makes the
condition volatile in all cmov implementations (except ge but that
one only calls into the fe impls).

This is just a quick fix. We should still look into other methods,
e.g., asm and #457. We should also consider not caring about
constant-time in scalar_low_impl.h

We should also consider testing on very new compilers in nightly CI,
see https://github.com/bitcoin-core/secp256k1/pull/864#issuecomment-769211867
2023-04-11 12:06:09 +02:00
Jonas Nick
1d25608900
Merge elementsproject/secp256k1-zkp#223: musig: Update to BIP v1.0.0-rc.4 (Check pubnonce in NonceGen vectors)
d23c23e24d64d9837d0ab728a88d8501b3a6130b musig: Update to BIP v1.0.0-rc.4 (Check pubnonce in NonceGen vectors) (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK d23c23e24d64d9837d0ab728a88d8501b3a6130b

Tree-SHA512: 5edc80a7c60a3699c06a46eaea300cf31478e561afa3d29efb9e1b8220969b3f0503ebd1bf906addde2c7367c4e99e2f62c7ef07198c3925d38194c4eb2e9f76
2023-03-03 21:45:23 +00:00
Tim Ruffing
d23c23e24d musig: Update to BIP v1.0.0-rc.4 (Check pubnonce in NonceGen vectors) 2023-03-03 22:31:28 +01:00
Tim Ruffing
c4862f6869
Merge ElementsProject/secp256k1-zkp#215: musig: include pubkey in secnonce and compare when signing
a1ec2bb67b05dbbec12bb6e2902cf96247a4341f musig: add test for signing with wrong secnonce for a keypair (Jonas Nick)
bd57a017aa90ac1fdde2c0f1a9df321d6a38c132 musig: include pubkey in secnonce and compare when signing (Jonas Nick)

Pull request description:

  Builds on #211.

  This PR implements a defense-in-depth measure that is specified in BIP-MuSig2. In fact, it revealed a bug in the `scriptless_atomic_swap` test.

ACKs for top commit:
  real-or-random:
    ACK a1ec2bb67b05dbbec12bb6e2902cf96247a4341f

Tree-SHA512: dfd54a07c13648e6a7163962bb516cc4ec3a25e4534da2c14a593e2da0f3779eb9b84bfa12ffd94676bb3f6ab86a323e7ec7dee938fd870f36882fee0181ca05
2023-03-03 16:53:29 +01:00
Jonas Nick
a1ec2bb67b
musig: add test for signing with wrong secnonce for a keypair 2023-03-03 12:55:00 +00:00
Jonas Nick
bd57a017aa
musig: include pubkey in secnonce and compare when signing 2023-03-03 12:55:00 +00:00
Tim Ruffing
4f57024d86
Merge ElementsProject/secp256k1-zkp#211: Update musig module to BIP MuSig2 v1.0.0-rc.3
b43dd83b43eac0ca8ad9ee1f557e9126c9e08d9e musig: add missing static keyword to function (Jonas Nick)
068e6a036a953e48bc90f9a96b318e350f474a3a musig: add test vectors from BIP MuSig (Jonas Nick)
36621d13bedf44eeedd2a1773e30e849972e5bff musig: update to BIP v1.0.0-rc.2 "Add ''pk'' arg to ''NonceGen''" (Jonas Nick)
d717a4980bc3e2e36bd32a02466226ef49a5d625 musig: update to BIP v0.8 "Switch from X-only to plain pk inputs." (Jonas Nick)
304f1bc96d6bdb5c1b5b1b9a321eac8f9a27fde4 extrakeys: add pubkey_sort test vectors from BIP MuSig2 (Jonas Nick)
ae89051547435cab5042a13d85562def9cabdd61 extrakeys: replace xonly_sort with pubkey_sort (Jonas Nick)
98242fcdd9519d0d5a349b0344aeea0ab4e796e9 extrakeys: add secp256k1_pubkey_cmp (Jonas Nick)
73d5b6654d472eb0cebbffd5a934caf174d29307 musig: update to BIP v0.7.0 (NonceGen) (Jonas Nick)
060887e9d749062242b4de3935b27fdcb0802c87 musig: update to BIP v0.5.1 "Rename ordinary tweaking to plain" (Jonas Nick)
cbe2815633411479e8305deb8b69bce94df723af musig: update to BIP v0.4 "Allow the output of NonceAgg to be inf" (Jonas Nick)
206017d67d9bb8b21d5cc924ba53e1618274774c musig: update to BIP v0.3 (NonceGen) (Jonas Nick)
d800dd55db28a710bb510a2a5fc33519d355a91c musig: remove test vectors (Jonas Nick)

Pull request description:

  Version 1.0.0-rc.3 of BIP MuSig2 can be found [here](https://github.com/jonasnick/bips/pull/75). This PR does _not_ implement the following optional features that have been added to BIP MuSig2:

  - variable length messages
  - deterministic signing
  - identifiable aborts

  The PR also does _not_ yet change the `secnonce` structure to also contain the signer's public key (which would also imply changing the seckey argument in `sign` to a keypair). Additionally, we may want to rename some things in the future to be more consistent with the BIP (e.g. keyagg_cache vs. keyagg_ctx, applytweak vs. tweak_add).

ACKs for top commit:
  ariard:
    Light Code Review ACK b43dd83b, mostly looks on how the user API will make sense for Lightning, thanks for the answers!
  real-or-random:
    ACK b43dd83b43eac0ca8ad9ee1f557e9126c9e08d9e

Tree-SHA512: 9b1410951b55a1b0e6590b8c302052996d1fb6d9771765498b4282ff68b44ab0d6add8144c9330217b682ec5a93508b5546099db9a1f2c865f99253010dd76f4
2023-03-02 15:24:50 +01:00
Jonas Nick
8ec6d111c8
Merge elementsproject/secp256k1-zkp#205: Bulletproofs++: Norm argument
d7fb25c8ca5bda0e969ce94ccabedfd7b8432769 Make sure that bppp_log2 isn't called with value 0 (Jonas Nick)
e5a01d12c63b30d3627cd0114a042a9853b0d233 Rename buletproof_pp* to bppp* (sanket1729)
c9831868723b06cca72141651f9e27f37c6ca3eb transcript: add tests (Jonas Nick)
73edc75528a9a4d4cf69b77d38f108023a132994 norm arg: add verification vectors (Jonas Nick)
13ad32e814ece805a5bd2ef7c4b46fa37cedf136 norm arg: add tests for zero length and zero vectors (Jonas Nick)
34c4847a6a72e340dac2c078bbea4d65441e5971 ci: add bulletproofs (Jonas Nick)
25745164835669d71e86863d1de747f26480ec08 Add testcases for bulletproofs++ norm arugment (sanket1729)
46c7391154a7325133f97f9ec816ccf98ba76ede Add norm argument verify API (sanket1729)
d9145455bb741c9f363c2a085abd0109e63c961f Add bulletproofs++ norm argument prove API (sanket1729)
8638f0e0cecad113e11b826a41bed1fe7a8d3b85 Add internal BP++ commit API (sanket1729)
412f8f66a08ef0e60644c7b5b22ee2a3d19ae3e8 Add utility functions required in norm argument (sanket1729)
420353d7da7793513621da3a5ad7479feaf76713 Add utilities for log2 (sanket1729)
17417d44f307a44e42468200458c3eb2c407b6b8 Add utilities from uncompressed Bulletproofs PR (sanket1729)
48563c8c791d2d5ed50dabde9de8c0839f43c8f3 bulletproofs: add API functionality to generate a large set of generators (Andrew Poelstra)
048f9f8642297578a4e7975fa1e9837a58fc1c66 bulletproofs: add new empty module (Andrew Poelstra)
6162d577fec175c620f759675eb09ffa10368de1 generator: cleanups in Pedersen/generator code (Andrew Poelstra)
0a6006989f6215a45e982cd696339c503ddfc325 Revert "Remove unused scalar_sqr" (Andrew Poelstra)
87373f51451bed948340d6885111d04051cbfc02 MOVE ONLY: move Pedersen commitment stuff to generator module from rangeproof module (Andrew Poelstra)

Pull request description:

ACKs for top commit:
  Liam-Eagen:
    ACK d7fb25c
  jonasnick:
    ACK d7fb25c8ca5bda0e969ce94ccabedfd7b8432769

Tree-SHA512: 0a51e2b404ab594e4ce6c4a65a35f6bbf870d718e0a3cdf7ddd085ed37a0e0c0db55dabca8fe9d8b8beb3f7e60280aa46a2951408c18942dd6ad1c9a71bab5cd
2023-02-27 17:37:46 +00:00
Jonas Nick
d7fb25c8ca Make sure that bppp_log2 isn't called with value 0
Author:    Jonas Nick <jonasd.nick@gmail.com>
Date:      Thu Feb 9 21:31:43 2023 +0000
2023-02-13 23:53:36 -08:00
sanket1729
e5a01d12c6 Rename buletproof_pp* to bppp* 2023-02-13 22:16:17 -08:00
Jonas Nick
c983186872 transcript: add tests 2023-02-13 22:15:47 -08:00
Jonas Nick
73edc75528 norm arg: add verification vectors
norm arg: add verify test vector with vector size > 1
2023-02-13 22:15:47 -08:00
Jonas Nick
13ad32e814 norm arg: add tests for zero length and zero vectors 2023-02-13 22:15:47 -08:00
Jonas Nick
34c4847a6a ci: add bulletproofs 2023-02-13 22:15:47 -08:00