1444 Commits

Author SHA1 Message Date
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
sanket1729
2574516483 Add testcases for bulletproofs++ norm arugment 2023-02-13 22:15:47 -08:00
sanket1729
46c7391154 Add norm argument verify API 2023-02-13 22:15:46 -08:00
Jonas Nick
b43dd83b43
musig: add missing static keyword to function 2023-02-13 14:03:51 +00:00
Jonas Nick
068e6a036a
musig: add test vectors from BIP MuSig 2023-02-13 14:03:51 +00:00
Jonas Nick
36621d13be
musig: update to BIP v1.0.0-rc.2 "Add ''pk'' arg to ''NonceGen''" 2023-02-13 14:03:51 +00:00
Jonas Nick
d717a4980b
musig: update to BIP v0.8 "Switch from X-only to plain pk inputs." 2023-02-13 14:03:51 +00:00
Jonas Nick
304f1bc96d
extrakeys: add pubkey_sort test vectors from BIP MuSig2 2023-02-13 14:03:51 +00:00
Jonas Nick
ae89051547
extrakeys: replace xonly_sort with pubkey_sort 2023-02-13 14:03:51 +00:00
Jonas Nick
98242fcdd9
extrakeys: add secp256k1_pubkey_cmp 2023-02-13 14:03:51 +00:00
Jonas Nick
73d5b6654d
musig: update to BIP v0.7.0 (NonceGen)
- 0.7.0: Change ''NonceGen'' such that output when message is not present is different from when message is present but has length 0.
- 0.6.0: Change order of arguments and serialization of the message in the ''NonceGen'' hash function
2023-02-13 14:03:51 +00:00
Jonas Nick
060887e9d7
musig: update to BIP v0.5.1 "Rename ordinary tweaking to plain" 2023-02-13 14:03:51 +00:00
sanket1729
d9145455bb Add bulletproofs++ norm argument prove API 2023-02-08 13:07:05 -08:00
sanket1729
8638f0e0ce Add internal BP++ commit API 2023-02-08 13:07:05 -08:00
sanket1729
412f8f66a0 Add utility functions required in norm argument 2023-02-08 03:09:11 -08:00
sanket1729
420353d7da Add utilities for log2 2023-02-08 03:09:11 -08:00
sanket1729
17417d44f3 Add utilities from uncompressed Bulletproofs PR
Add a transcript module for doing a generic Fiat Shamir
2023-02-08 03:09:11 -08:00
Andrew Poelstra
48563c8c79 bulletproofs: add API functionality to generate a large set of generators 2023-02-08 03:09:11 -08:00
Andrew Poelstra
048f9f8642 bulletproofs: add new empty module 2023-02-08 03:09:11 -08:00
Andrew Poelstra
6162d577fe generator: cleanups in Pedersen/generator code
Silence a compiler warning about an unitialized use of a scalar in case
the user tries to provide a 0-length list of commitments.

Also ensures that commitments have normalized field elements when they
are loaded into ges.
2023-02-08 03:09:11 -08:00
Tim Ruffing
ca92a35d01 field: Simplify code in secp256k1_fe_set_b32 2023-02-01 12:29:34 +01:00
Tim Ruffing
d93f62e369 field: Verify field element even after secp256k1_fe_set_b32 fails 2023-02-01 12:29:03 +01:00
Andrew Poelstra
0a6006989f Revert "Remove unused scalar_sqr"
This reverts commit 5437e7bdfbffddf69fdf7b4af7e997c78f5dafbf.
2023-01-23 10:18:21 -08:00
Andrew Poelstra
87373f5145 MOVE ONLY: move Pedersen commitment stuff to generator module from rangeproof module
You can verify this commit with `git diff --color-moved=zebra`
2023-01-23 10:18:21 -08:00
Jonas Nick
cbe2815633
musig: update to BIP v0.4 "Allow the output of NonceAgg to be inf" 2023-01-23 09:36:46 +00:00
Jonas Nick
206017d67d
musig: update to BIP v0.3 (NonceGen)
- 0.3.0: Hash i - 1 instead of i in NonceGen
- 0.2.0: Change order of arguments in NonceGen hash function
2023-01-23 09:36:45 +00:00
Jonas Nick
d800dd55db
musig: remove test vectors
These vectors are superseded by test vectors in BIP MuSig2 which will be added
in a later commit.
2023-01-23 09:36:45 +00:00
Jonas Nick
eb6bebaee3
scalar: restrict split_lambda args, improve doc and VERIFY_CHECKs
VERIFY_CHECK(r1 != r2) is added because otherwise the verify_scalar_split fails.
2023-01-19 21:14:38 +00:00
Jonas Nick
620ba3d74b
benchmarks: fix bench_scalar_split
scalar_split_lambda requires that the input pointer is different to both output
pointers. Without this fix, the internal benchmarks crash when compiled with
-DVERIFY.

This was introduced in commit 362bb25608dbcd724a07dd5170c4ebe081c3dd84 (which
requires configuring with --enable-endomorphism to exhibit the crash).
2023-01-19 18:12:31 +00:00
Pieter Wuille
5fbff5d348
Merge bitcoin-core/secp256k1#1170: contexts: Forbid destroying, cloning and randomizing the static context
e39d954f118a29db2c33e9a9a507053fff5573ed tests: Add CHECK_ILLEGAL(_VOID) macros and use in static ctx tests (Tim Ruffing)
61841fc9ee5aa1ffde3ccd512660207034125ebd contexts: Forbid randomizing secp256k1_context_static (Tim Ruffing)
4b6df5e33e197a50fd7d9bc4c14b8ba8526013b9 contexts: Forbid cloning/destroying secp256k1_context_static (Tim Ruffing)

Pull request description:

  As discussed in #1126.

  For randomization, this has a history. Initially, this threw the illegal callback but then we changed it to be a no-op on non-signing contexts: 6198375218 But this was with (non-static) none/verification contexts in mind, not with the static context. If we anyway forbid cloning the static context, you should never a way to randomize a copy of the static context. (You need a copy because the static context itself is not writable. But you cannot obtain a copy except when using memcpy etc.)

ACKs for top commit:
  sipa:
    utACK e39d954f118a29db2c33e9a9a507053fff5573ed
  apoelstra:
    ACK e39d954f118a29db2c33e9a9a507053fff5573ed

Tree-SHA512: dc804b15652d536b5d67db7297ac0e65eab3a64cbb35a9856329cb87e7ea0fe8ea733108104b3bba580077fe03d6ad6b161c797cf866a74722bab7849f0bb60c
2023-01-19 13:04:18 -05:00
Pieter Wuille
233822d849
Merge bitcoin-core/secp256k1#1195: ctime_tests: improve output when CHECKMEM_RUNNING is not defined
8f51229e0348a1524fed541f334cd4f1726d2685 ctime_tests: improve output when CHECKMEM_RUNNING is not defined (Jonas Nick)

Pull request description:

  When seeing the output
  ```
  Unless compiled under msan, this test can only usefully be run inside valgrind.
  ```
  I thought that I would have to go back to the `configure` output to manually check if it was compiled under memsan to determine whether this test can be usefully run outside valgrind. But when we go into this branch then it was definitely not compiled under msan, which means that we can make the output clearer.

ACKs for top commit:
  sipa:
    utACK 8f51229e0348a1524fed541f334cd4f1726d2685
  real-or-random:
    utACK 8f51229e03

Tree-SHA512: a4953a158b1375d8fc3a2ee29e7014c5399becf5f75ffd3765c0141861e092fbc120003e00dfd25ec54b92a466e133377b96d5a9f4017c100aaf64fb9a045df1
2023-01-19 11:00:16 -05:00
Tim Ruffing
e39d954f11 tests: Add CHECK_ILLEGAL(_VOID) macros and use in static ctx tests 2023-01-19 13:36:40 +01:00
Tim Ruffing
61841fc9ee contexts: Forbid randomizing secp256k1_context_static 2023-01-18 16:47:31 +01:00
Tim Ruffing
4b6df5e33e contexts: Forbid cloning/destroying secp256k1_context_static 2023-01-18 16:39:31 +01:00
Jonas Nick
8f51229e03
ctime_tests: improve output when CHECKMEM_RUNNING is not defined 2023-01-18 09:02:47 +00:00
Russell O'Connor
d6ff738d5b Ensure safety of ctz_debruijn implementation.
Adding U to the magic constants ensures that we are not mixing unsigned and signed value during multiplication, and ensures that the multiplication will not be subject to integer promotion.

The (uint32_t)/(uint64_t) casts ensure the values are properly truncated no matter the size of an int.

Prior to this commit, if secp256k1_ctz32_var_debruijn were some how managed to be built on a platform with 64-bit ints, (though this function is specifically only intended to be used on 32-bit platforms) it would perform an out-of-bounds array access.
2023-01-16 22:23:57 -05:00
Tim Ruffing
a01a7d86dc
Merge bitcoin-core/secp256k1#1192: Switch to exhaustive groups with small B coefficient
ce60785b2654e60b43577dd75996b7020afbfec8 Introduce SECP256K1_B macro for curve b coefficient (Pieter Wuille)
4934aa79958b506a6e9cfcfe30a8f685db3f5f5f Switch to exhaustive groups with small B coefficient (Pieter Wuille)

Pull request description:

  This has the advantage that in the future, multiplication with B can be done using `secp256k1_fe_mul_int` rather than the slower `secp256k1_fe_mul`.

ACKs for top commit:
  real-or-random:
    ACK ce60785b2654e60b43577dd75996b7020afbfec8 also ran the exhaustive tests with the group of size 7
  apoelstra:
    ACK ce60785b2654e60b43577dd75996b7020afbfec8

Tree-SHA512: 006041189d18319ddb9c0ed54e479f393b83ab2a368d198bd24860d1d2574c0c1a311aea24fbef2e74bb7859a687dfc803b9e963e6dc5c61cb707e20f52b5a70
2023-01-16 22:36:15 +01:00
Tim Ruffing
a7a7bfaf3d
Merge bitcoin-core/secp256k1#1190: Make all non-API functions (except main) static
e03ef8655933d3e2b4830e7f8fe86deba820a073 Make all non-API functions (except main) static (Pieter Wuille)

Pull request description:

ACKs for top commit:
  real-or-random:
    utACK e03ef8655933d3e2b4830e7f8fe86deba820a073
  hebasto:
    ACK e03ef8655933d3e2b4830e7f8fe86deba820a073.

Tree-SHA512: 36a35d9a8da05411c88644aec81e79883febce3e08c9eb6b0ec95cfc3705fd6abfd66f7ee10dfa081ca20786d26b0a060ead7f5c8109bf02a73dde7ef811144b
2023-01-16 18:46:37 +01:00
Pieter Wuille
ce60785b26 Introduce SECP256K1_B macro for curve b coefficient 2023-01-13 17:05:39 -05:00
Pieter Wuille
4934aa7995 Switch to exhaustive groups with small B coefficient 2023-01-13 17:05:35 -05:00
Pieter Wuille
74b026f05d Add runtime checking for DECLASSIFY flag 2023-01-11 16:07:37 -05:00
Pieter Wuille
5048be17e9 Rename valgrind_ctime_test -> ctime_tests 2023-01-11 16:07:37 -05:00
Pieter Wuille
6eed6c18de Update error messages to suggest msan as well 2023-01-11 16:07:37 -05:00
Pieter Wuille
8e11f89a68 Add support for msan integration to checkmem.h 2023-01-11 16:07:37 -05:00
Pieter Wuille
8dc64079eb Add compile-time error to valgrind_ctime_test 2023-01-11 16:07:37 -05:00
Pieter Wuille
0db05a770e Abstract interactions with valgrind behind new checkmem.h 2023-01-11 16:07:35 -05:00
Tim Ruffing
9a93f48f50 refactor: Rename STTC to STATIC_CTX in tests 2023-01-10 18:43:09 +01:00
Tim Ruffing
3385a2648d refactor: Rename global variables to uppercase in tests 2023-01-10 18:43:09 +01:00