Commit Graph

1898 Commits

Author SHA1 Message Date
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
Andrew Poelstra
0a6006989f Revert "Remove unused scalar_sqr"
This reverts commit 5437e7bdfb.
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
b1f1675375 Merge elementsproject/secp256k1-zkp#214: sync-upstream: Fix $REPRODUCE_COMMAND for "select"
e04c660b11 sync-upstream: Fix $REPRODUCE_COMMAND for "select" (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    utACK e04c660b11

Tree-SHA512: 898b56f5931ef3a8e84546e5d2c0bd1a644cb7492aac4ecf80090edc250663b79b1bf4295a516868960c3a13113272f6fc50744b5daf0c90d5b9d9f561913c0b
2023-01-23 09:40:20 +00:00
Jonas Nick
a58c7d29bd Merge elementsproject/secp256k1-zkp#213: Update macOS image for CI
3b2c675955 Update macOS image for CI (Pieter Wuille)

Pull request description:

ACKs for top commit:
  real-or-random:
    utACK 3b2c675955
  jonasnick:
    ACK 3b2c675955

Tree-SHA512: 21987ea64929f7b43ea9a6f7eaa98bf47345aa03af10c45c0aa7a6e19b3a21c4a5d2aef0f6b99d6ddb4bf97752c8e2cdaeec619d4ef105e5d931790479de8ef5
2023-01-23 09:35:36 +00:00
Tim Ruffing
e04c660b11 sync-upstream: Fix $REPRODUCE_COMMAND for "select" 2023-01-20 17:09:18 +01:00
Pieter Wuille
3b2c675955 Update macOS image for CI 2023-01-20 07:08:50 -08:00
Jonas Nick
d22774e248 Merge elementsproject/secp256k1-zkp#203: MuSig doc fixes
dd83e72d52 Add ordinary tweak info (Jesse Posner)
d26100cab2 Exclude nonce_process from pre-processing steps (Jesse Posner)
b7607f93f2 Fix reference to xonly_tweak_add (Jesse Posner)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK dd83e72d52

Tree-SHA512: b5b94e94625e235557d4a0d9973b14ef74be153b6bdd9a0701add9aa8af4a54411344030db2e65aaac701e3e6a0c1f46190f0d760f7314d426d077959271b615
2022-09-02 12:20:12 +00:00
Jesse Posner
dd83e72d52 Add ordinary tweak info 2022-09-01 22:39:34 -07:00
Jesse Posner
d26100cab2 Exclude nonce_process from pre-processing steps 2022-09-01 22:39:22 -07:00
Jesse Posner
b7607f93f2 Fix reference to xonly_tweak_add 2022-09-01 22:38:03 -07:00
Jonas Nick
f7e9a8544f Merge elementsproject/secp256k1-zkp#201: rangeproof: add secp256k1_rangeproof_max_size function to estimate rangeproof size
6b6ced9839 rangeproof: add more max_size tests (Jonas Nick)
34876ecb5f rangeproof: add more static test vectors (Jonas Nick)
310e517061 rangeproof: add a bunch more testing (Andrew Poelstra)
f1410cb67a rangeproof: add secp256k1_rangeproof_max_size function to estimate rangeproof size (Andrew Poelstra)

Pull request description:

ACKs for top commit:
  real-or-random:
    tACK 6b6ced9839
  jonasnick:
    ACK 6b6ced9839

Tree-SHA512: 421dfb0824f67f3822be729dc7f11e4654a21e32e3a6c5565e09b191ec57710b33a73c3d09c08f1d767d769f0957006ac257eabe00a2f37f88b99377644e8741
2022-08-25 20:21:47 +00:00
Jonas Nick
6b6ced9839 rangeproof: add more max_size tests 2022-08-25 14:26:02 +00:00
Jonas Nick
34876ecb5f rangeproof: add more static test vectors
Fixes #42
2022-08-25 14:26:02 +00:00
Andrew Poelstra
310e517061 rangeproof: add a bunch more testing
Add two new fixed rangeproof vectors; check that various extracted
values are correct; add a test for creating and verifying single-value
proofs.
2022-08-25 14:26:02 +00:00
Andrew Poelstra
f1410cb67a rangeproof: add secp256k1_rangeproof_max_size function to estimate rangeproof size
Provides a method that will give an upper bound on the size of a rangeproof,
given an upper bound on the value to be passed in and an upper bound on the
min_bits parameter.

There is a lot of design freedom here since the actual size of the rangeproof
depends on every parameter passed to rangeproof_sign, including the value to
be proven, often in quite intricate ways. For the sake of simplicity we assume
a nonzero `min_value` and that `exp` will be 0 (the default, and size-maximizing,
choice), and provide an exact value for a proof of the given value and min_bits.
2022-08-25 14:26:00 +00:00
Jonas Nick
c137ddbdff Merge elementsproject/secp256k1-zkp#200: build: automatically enable module dependencies
171b294a1c build: improve error message if --enable-experimental is missed (Jonas Nick)
58ab152bb4 build: move all output concerning enabled modules at single place (Jonas Nick)
1493113e61 build: automatically enable module dependencies (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    utACK 171b294a1c

Tree-SHA512: 644e7d96b02c1f4f0751cf84b268f313cc0bd955ea6eacdeddb932b9ba7990be8e8aca9db8c050fd91a35d0a0173061e40fe8c1bf8bfd03107b86aa1bf85e871
2022-08-22 14:45:42 +00:00
Jonas Nick
0202d839fb Merge elementsproject/secp256k1-zkp#199: surjectionproof: make sure that n_used_pubkeys > 0 in generate
5ac8fb035e surjectionproof: make sure that n_used_pubkeys > 0 in generate (Jonas Nick)

Pull request description:

ACKs for top commit:
  apoelstra:
    utACK 5ac8fb035e

Tree-SHA512: 915f7181e69e2c4e1f830d6c2620a2d9b0af4d2ae8a63709b489b01ed9e13ccfeeaedebd4680cf2d927cd473a6ae88602cf29e2fdd116cb597fba6c0ab77720d
2022-08-18 19:54:00 +00:00
Jonas Nick
5ac8fb035e surjectionproof: make sure that n_used_pubkeys > 0 in generate
If the proof was generated with surjectionproof_initialize (as mandated by the
API docs), then n_used_pubkeys can never be 0. Without this commit, compilers
will (rightfully) warn that borromean_s[ring_input_index] is not initialized in
surjectionproof_generate. Therefore, this commit makes sure that n_used_pubkeys
is greater than 0 which ensures that the array is initialized at
ring_input_index.
2022-08-15 20:01:39 +00:00
Andrew Poelstra
7ff446df8b Merge ElementsProject/secp256k1-zkp#198: rangeproof: add a test for all-zero blinding factors
5a40f3d99b replace memcmp with secp256k1_memcmp_var throughout the codebase (Andrew Poelstra)
92820d944b rangeproof: add a test for all-zero blinding factors (Andrew Poelstra)

Pull request description:

  I was curious about under what conditions you can create a rangeproof on an "unblinded" commitment which has a zero blinding factor. Apparently the answer is "when you are proving at least 3-bits". In this case rewinding words and you can encode 32 bytes of data. (In fact I believe you can encode up to 128 but I haven't tested that.)

ACKs for top commit:
  real-or-random:
    utACK 5a40f3d99b

Tree-SHA512: bed7f9362d082d2b56668809077d5ddde52280109c992a290d87b55cb70138a08799fcca18cafbb3b3e9efed4349418bf9bb2c0ccedacdce0567e841e6d21e13
2022-08-12 23:55:46 +00:00
Andrew Poelstra
5a40f3d99b replace memcmp with secp256k1_memcmp_var throughout the codebase
memcmp only appears in -zkp-specific modules. Fix those.
2022-08-10 22:14:31 +00:00
Andrew Poelstra
92820d944b rangeproof: add a test for all-zero blinding factors 2022-08-10 22:10:33 +00:00
Jonas Nick
171b294a1c build: improve error message if --enable-experimental is missed 2022-08-10 09:20:26 +00:00
Jonas Nick
58ab152bb4 build: move all output concerning enabled modules at single place 2022-08-10 09:04:47 +00:00
Jonas Nick
1493113e61 build: automatically enable module dependencies 2022-08-10 08:58:29 +00:00
Tim Ruffing
4fd7e1eabd Merge ElementsProject/secp256k1-zkp#197: fix include paths in all the -zkp modules
347f96d94a fix include paths in all the -zkp modules (Andrew Poelstra)

Pull request description:

  This is causing out-of-tree build failures in Elements.

ACKs for top commit:
  real-or-random:
    utACK 347f96d94a

Tree-SHA512: 7d6211f3b8d5612f95bcb3085c22458e7ceaa79f1ee74e37404cc6d1fdf0fbc02b4443b02623b9b6c1225437c1a1954b6d36a953d52b020ac7913326404894e0
2022-08-05 23:42:10 +02:00
Andrew Poelstra
347f96d94a fix include paths in all the -zkp modules
This is causing out-of-tree build failures in Elements.
2022-08-05 14:56:10 +00:00
Tim Ruffing
d1d6e47c17 Merge ElementsProject/secp256k1-zkp#196: surjectionproof: fail to generate proofs when an input equals the output
d1175d265d surjectionproof: use secp256k1_memcmp_var rather than bare memcmp (Andrew Poelstra)
bf18ff5a8c surjectionproof: fix generation to fail when any input == the output (Andrew Poelstra)
4ff6e4274d surjectionproof: add test for existing behavior on input=output proofs (Andrew Poelstra)

Pull request description:

  If any ephemeral input tag equals the ephemeral output tag (i.e. an input asset is exactly equal to the output asset), verification will fail due to an unexpected interaction between our surjectionproof logic and the underlying borromean ring siganture logic. However, our generation code still allows creating proofs like this, "succeeding" in creating bad proofs.

  Since we cannot fix the verification side without hardforking Liquid, fix the generation side to fail in this situation.

ACKs for top commit:
  real-or-random:
    utACK d1175d265d

Tree-SHA512: c15e130de028d6c1f705543fe2774ec23016c71f9d6b38ef0708820a517d156e2126f8369e94f16f9fd1855c29cd907d406f6ea26c95499a9ae1ce0dd92f77b2
2022-08-01 13:25:31 +02:00
Andrew Poelstra
d1175d265d surjectionproof: use secp256k1_memcmp_var rather than bare memcmp
Co-authored-by: Tim Ruffing <crypto@timruffing.de>
2022-07-29 21:04:04 +00:00
Andrew Poelstra
bf18ff5a8c surjectionproof: fix generation to fail when any input == the output
Verification will fail in this case, so don't "succeed" in generating a bad proof.
2022-07-26 17:14:49 +00:00
Andrew Poelstra
4ff6e4274d surjectionproof: add test for existing behavior on input=output proofs 2022-07-26 17:09:36 +00:00
Tim Ruffing
71a206fa5b Merge ElementsProject/secp256k1-zkp#194: extrakeys: rename swap/swap64 to fix OpenBSD 7.1 compilation
db648478c3 extrakeys: rename swap/swap64 to fix OpenBSD 7.1 compilation (Jon Griffiths)

Pull request description:

  OpenBSD defines swap64 in <endian.h>.

ACKs for top commit:
  real-or-random:
    ACK db648478c3
  jonasnick:
    ACK db648478c3

Tree-SHA512: a3bf4175918c06457ec941eb029fded98d367c82a352024a9f96919219cc494e40f96e090dc03b73d0d22b99374f0656f27b755a56caebcd5df27efbd978fd56
2022-07-20 21:07:32 +02:00
Jon Griffiths
db648478c3 extrakeys: rename swap/swap64 to fix OpenBSD 7.1 compilation
OpenBSD defines swap64 in <endian.h>.
2022-07-18 12:29:54 +12:00
Tim Ruffing
7a30cb0c9d Merge ElementsProject/secp256k1-zkp#187: musig-spec: remove it from this repo
cc07b8f7a9 musig-spec: remove it (Jonas Nick)

Pull request description:

  Moved to https://github.com/jonasnick/bips/blob/musig2/bip-musig2.mediawiki.

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

Tree-SHA512: 67aebe6afbacd83153c465fcea794d36f07d067e21f767d9f82d7429458d91fe1df8a7289c10d9fa5b5458b1b6603b51a3349528dc8af6b0293f34f0b25c311f
2022-04-06 00:50:33 +02:00
Jonas Nick
cc07b8f7a9 musig-spec: remove it 2022-04-05 22:47:17 +00:00
Jonas Nick
c1640b7049 Merge elementsproject/secp256k1-zkp#166: musig-spec: Add naive Python reference implementation
c235e5055f musig-spec: Add naive Python reference implementation (Elliott Jin)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK c235e5055f
  real-or-random:
    utACK c235e5055f

Tree-SHA512: f0ff8b84730a82d8eab15ac5c46b190af125a87c0c8b3eef88fa5f67c4b7cd88e3d981cae857a99456b72a0edb56ef7f0593e7ed488914f2f4cd070efb579de8
2022-04-05 22:28:18 +00:00
Elliott Jin
c235e5055f musig-spec: Add naive Python reference implementation 2022-04-05 18:18:18 -04:00
Tim Ruffing
d45fbdcfad Merge ElementsProject/secp256k1-zkp#180: musig: add test vectors for applying multiple tweaks
510b61a803 musig: add test vectors for applying multiple tweaks (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    utACK 510b61a803
  robot-dreams:
    utACK 510b61a803

Tree-SHA512: 5fed7e01f23c0c7d1526bd9f89c5f385ad95ab1f0331df6e5bc7710e4d9f4f3860a5fd63adb7adda0a57e5fcf6204ccb941232ceb26eae44cb74f0916963d674
2022-04-05 23:19:34 +02:00
Jonas Nick
9a814bea32 Merge elementsproject/secp256k1-zkp#186: musig-spec: Minor cleanup
67247e53af musig-spec: More minor cleanup (Elliott Jin)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 67247e53af

Tree-SHA512: 8ea2880aef0bd69e2faf10a5eb44d5ba3839867565bd735a4582189f04ea54ab73ec23f04d08aed1d10bc5aaa55bab688ff4cb4e733dc73e2a5946f9a187c7ac
2022-04-05 19:38:43 +00:00
Elliott Jin
67247e53af musig-spec: More minor cleanup 2022-04-05 15:30:28 -04:00
Jonas Nick
9a1645f0ef Merge elementsproject/secp256k1-zkp#184: musig-spec: minor fixups
bf615193ce musig-spec: minor fixups (Jonas Nick)

Pull request description:

ACKs for top commit:
  robot-dreams:
    ACK bf615193ce, thanks!

Tree-SHA512: dff21e4f68640de6087426af934d882146f53392166fb9826bc15fc13490bbb20b4ae94410604567df451ac5875fa3cf17be5f2cc7f7d2ae135aff91b17f3754
2022-04-05 18:47:11 +00:00
Jonas Nick
bf615193ce musig-spec: minor fixups 2022-04-05 18:39:27 +00:00
Jonas Nick
ebd10f210b Merge elementsproject/secp256k1-zkp#185: musig-spec: Clarify negation for signing and verification
0940575215 musig-spec: Clarify negation for signing and verification (Elliott Jin)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 0940575215

Tree-SHA512: 907f55f633a397d99d7a0243e4175bce0e647c634dee452996622a22e29c37e78eafcc4f4c90ad44b8571e469b8a1ab882be3231e0e4c6e1ff0ca44fbfac9dcd
2022-04-05 16:50:53 +00:00
Elliott Jin
0940575215 musig-spec: Clarify negation for signing and verification 2022-04-05 12:47:36 -04:00
Jonas Nick
18a35ec1af Merge elementsproject/secp256k1-zkp#183: Improve writing in Signing flow
1b292cdb52 Improve writing in Signing flow (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 1b292cdb52

Tree-SHA512: 08ab5480afb53ffdfd660713aabe5f21529e2f3a450c99e74f5b5f14135bf735454c845ca9e574197098a68dbb97fb1601a5bc68f8095bc74262b1677f4275a4
2022-04-05 14:58:08 +00:00
Tim Ruffing
1b292cdb52 Improve writing in Signing flow 2022-04-05 15:01:09 +02:00
Tim Ruffing
a86bfa991a Merge ElementsProject/secp256k1-zkp#181: musig-spec: clarify hashing in noncegen by converting ints to bytes
376733b58b musig-spec: clarify hashing in noncegen by converting ints to bytes (Jonas Nick)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK 376733b58b

Tree-SHA512: c4708c476094d242fe7312177e345932bd40b52549007b43d2e5e4efc094101624d8583647f305bcbd042692a9d0117eda38f71e22fee0e0f49d677d9f512a8e
2022-04-05 10:42:02 +02:00
Tim Ruffing
4469cad42f Merge ElementsProject/secp256k1-zkp#182: musig-spec: address robot-dreams' comments
b7f8ea2f2a musig-spec: address robot-dreams' comments (Jonas Nick)

Pull request description:

  - KeyAggCoeff' -> KeyAggCoeffInternal for consistency
  - In Sign, add mod n when calculating d
  - In Tweak, reorder the parameters to (Q, gacc, tacc, tweak, is_xonly) because
    the first three are "state" arguments
  - Rename Tweak function to ApplyTweak to avoid confusion with tweak (the
    vector). This becomes apparent in the python reference code.

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

Tree-SHA512: 6f9066af2f67b6d2769f38ebb2537769568e77bab18d487590a0095a695eab5c34a7177e4d299f27e3e30628dd07aff831f3f08db256cf2ae13ea0d92f3e18b8
2022-04-05 10:41:08 +02:00
Jonas Nick
b7f8ea2f2a musig-spec: address robot-dreams' comments
- KeyAggCoeff' -> KeyAggCoeffInternal for consistency
- In Sign, add mod n when calculating d
- In Tweak, reorder the parameters to (Q, gacc, tacc, tweak, is_xonly) because
  the first three are "state" arguments
- Rename Tweak function to ApplyTweak to avoid confusion with tweak (the
  vector). This becomes apparent in the python reference code.
2022-04-04 22:39:38 +00:00