1889 Commits

Author SHA1 Message Date
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
6b6ced9839f2576898ba334e7ed2d550a2062b32 rangeproof: add more max_size tests (Jonas Nick)
34876ecb5facfc274580c0549df14e6664c03d82 rangeproof: add more static test vectors (Jonas Nick)
310e5170619b03977d471e9f7461bbaf5b607ca9 rangeproof: add a bunch more testing (Andrew Poelstra)
f1410cb67a2de45f8b1b1c14862656c0ae09ff87 rangeproof: add secp256k1_rangeproof_max_size function to estimate rangeproof size (Andrew Poelstra)

Pull request description:

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

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
171b294a1c7a736c1b93fa194e3af90b625259fa build: improve error message if --enable-experimental is missed (Jonas Nick)
58ab152bb4b6c8b4ab17061e90d61fcbc1be9e6c build: move all output concerning enabled modules at single place (Jonas Nick)
1493113e61eb593a18b8e2328dbe9bc1b82f68d5 build: automatically enable module dependencies (Jonas Nick)

Pull request description:

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

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
5ac8fb035e8f0ad012d9f54b49e77b5d1f5e713a surjectionproof: make sure that n_used_pubkeys > 0 in generate (Jonas Nick)

Pull request description:

ACKs for top commit:
  apoelstra:
    utACK 5ac8fb035e8f0ad012d9f54b49e77b5d1f5e713a

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
5a40f3d99bbd879391a3fb3c038a6d49ec01bc03 replace memcmp with secp256k1_memcmp_var throughout the codebase (Andrew Poelstra)
92820d944b52d923dad57b7d5bae5fec48f28ddd 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 5a40f3d99bbd879391a3fb3c038a6d49ec01bc03

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
347f96d94a6c2840e045510672549897be743101 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 347f96d94a6c2840e045510672549897be743101

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
d1175d265d514bd0c22faaf262d7df362f33af89 surjectionproof: use secp256k1_memcmp_var rather than bare memcmp (Andrew Poelstra)
bf18ff5a8c6295cb7db6e2989aefd6a78df7720f surjectionproof: fix generation to fail when any input == the output (Andrew Poelstra)
4ff6e4274d49cb95ab246b599b274104baf83f9f 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 d1175d265d514bd0c22faaf262d7df362f33af89

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
db648478c3cc600dbe42c5badb45a1e1fa217f13 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 db648478c3cc600dbe42c5badb45a1e1fa217f13
  jonasnick:
    ACK db648478c3cc600dbe42c5badb45a1e1fa217f13

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
cc07b8f7a9a7aa3a023f04127cb85c1723dd1bf9 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 cc07b8f7a9a7aa3a023f04127cb85c1723dd1bf9

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
c235e5055f5d76e0cd39dcce3addb8cbd525e1bd musig-spec: Add naive Python reference implementation (Elliott Jin)

Pull request description:

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

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
510b61a80304f7e9aabec5f7d9968f94cc0f22e1 musig: add test vectors for applying multiple tweaks (Jonas Nick)

Pull request description:

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

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

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 67247e53afdf32f414a9fbd0fb008b3935b1e6d9

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
bf615193ce673c29598db9bd4c316d76647b83cb musig-spec: minor fixups (Jonas Nick)

Pull request description:

ACKs for top commit:
  robot-dreams:
    ACK bf615193ce673c29598db9bd4c316d76647b83cb, 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
0940575215f282456d689e7ce2c83a1c40a9c86b musig-spec: Clarify negation for signing and verification (Elliott Jin)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 0940575215f282456d689e7ce2c83a1c40a9c86b

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
1b292cdb52844828559a650e9ed70f10160d75ee Improve writing in Signing flow (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 1b292cdb52844828559a650e9ed70f10160d75ee

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
376733b58b282a4985dd78d0125749473f0aeff3 musig-spec: clarify hashing in noncegen by converting ints to bytes (Jonas Nick)

Pull request description:

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

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
b7f8ea2f2a828cb5a6804320a39750a77fffafba 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 b7f8ea2f2a828cb5a6804320a39750a77fffafba

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
Jonas Nick
376733b58b musig-spec: clarify hashing in noncegen by converting ints to bytes 2022-04-04 21:48:38 +00:00
Jonas Nick
510b61a803 musig: add test vectors for applying multiple tweaks 2022-04-04 21:38:46 +00:00
Jonas Nick
ac477d5148
Merge elementsproject/secp256k1-zkp#179: musig-spec: Improve writing in Motivation, Design
d903c09fd2087684281239187346cc8856b4fdca musig-spec: Improve writing in Motivation, Design (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK d903c09fd2087684281239187346cc8856b4fdca

Tree-SHA512: b429e82ba7f5fa1acf3fbb599a019cff5d2531e6b91d8aaf6191c1639e5a32a0e47676714c14af5d0e9bf61a6318654a00b8ea6c75840a82e64935e7a9712c13
2022-04-04 20:15:19 +00:00
Tim Ruffing
d903c09fd2 musig-spec: Improve writing in Motivation, Design 2022-04-04 22:11:58 +02:00
Tim Ruffing
1d0d60d9eb
Merge ElementsProject/secp256k1-zkp#178: musig-spec: expand on signing flow
fd51a6281ec21c9dcb71c13666a2551370e31fd1 musig-spec: add authors (Jonas Nick)
f56e223a7a79aa52748d4f542ecebc2ce6c537b2 musig-spec: explain NonceGen and tweaking in signing flow context (Jonas Nick)
e463ea42bb1fe48e30e6d289461cff4fa0935f77 musig-spec: mention stateless signing in signing flow (Jonas Nick)
a29b961eb75d4bd4c871ee5cc7de861a2b7011aa musig-spec: add acknowledgements and improve abstract (Jonas Nick)
1a086ba9c9143ef572b6f1fa3d7c6b8ca173414e musig-spec: add optional arguments to strengthen nonce function (Jonas Nick)
8d04ac318f2f6f160480faf6aeb843a1cba28db0 musig-spec: remove unnecessary and inconsistent input paragraph (Jonas Nick)

Pull request description:

  Based on #177

  It's likely we're missing people in the acknowledgements. Ping me if you think you are.

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

Tree-SHA512: 5240b783c15f76655b2593422dc7c76de1c5e298bbe2f39858daca4ee1b1877f1ff179b4043e6f1f75f8c804b734f4bb739d38a18a54b094d8640c57fd074ed9
2022-04-04 15:21:37 +02:00
Jonas Nick
fd51a6281e musig-spec: add authors 2022-04-04 11:57:00 +00:00
Jonas Nick
f56e223a7a musig-spec: explain NonceGen and tweaking in signing flow context 2022-04-04 11:57:00 +00:00
Jonas Nick
e463ea42bb musig-spec: mention stateless signing in signing flow 2022-04-04 10:42:09 +00:00
Jonas Nick
a29b961eb7 musig-spec: add acknowledgements and improve abstract 2022-04-04 10:42:09 +00:00