19 Commits

Author SHA1 Message Date
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
4eca406f4c Use relative #include paths in library (as in upstream) 2023-04-21 11:50:24 +02: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
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
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
Jonas Nick
938725c1c9 Merge commits 'd7ec49a6 9a5a87e0 aa5d34a8 2a3a97c6 ' into temp-merge-976
Also remove remaining uses of ecmult context in secp-zkp and update API tests
accordingly.
2021-09-16 15:21:11 +00:00
Tim Ruffing
cc0b279568 Eliminate a wrong -Wmaybe-uninitialized warning in GCC 2021-07-13 17:30:05 +02:00
Jonas Nick
b74f2dc478 Remove mentions of DER in H derivation. 2020-07-24 14:59:36 +02:00
Jonas Nick
9957307c3f Fix explanation of H derivation. It doesn't use DER encoding. 2020-07-24 14:59:36 +02:00
Jonas Nick
2a1750dedd Clarify how to derive alternative generator H 2020-07-24 14:59:36 +02:00
Andrew Poelstra
e06540de8c rangeproof: fix serialization of pedersen commintments 2020-07-24 14:50:48 +02:00
Andrew Poelstra
edb879f578 rangeproof: verify correctness of pedersen commitments when parsing 2020-07-24 14:50:48 +02:00
Andrew Poelstra
fca4c3b62f generator: verify correctness of point when parsing 2020-07-24 14:50:48 +02:00
Andrew Poelstra
e13bdf2f23 rangeproof: add API tests 2020-07-24 14:49:33 +02:00
Andrew Poelstra
94425d4a67 rangeproof: several API changes
* add summing function for blinded generators
* drop `excess` and `gen` from `verify_tally`
* add extra_commit to rangeproof sign and verify
2020-07-24 14:49:33 +02:00
Pieter Wuille
f6c84a02f3 Expose generator in pedersen/rangeproof API 2020-07-24 14:49:33 +02:00
Andrew Poelstra
e7a8a5f638 rangeproof: expose sidechannel message field in the signing API
Including a fix by Jonas Nick.
2020-07-24 14:49:33 +02:00
Andrew Poelstra
a88db4a744 [RANGEPROOF BREAK] Use quadratic residue for tie break and modularity cleanup
Switch to secp256k1_pedersen_commitment by Andrew Poelstra.
Switch to quadratic residue based disambiguation by Pieter Wuille.
2020-07-24 14:49:33 +02:00
Gregory Maxwell
16618fcd8d Pedersen commitments, borromean ring signatures, and ZK range proofs.
This commit adds three new cryptosystems to libsecp256k1:

Pedersen commitments are a system for making blinded commitments
 to a value.  Functionally they work like:
  commit_b,v = H(blind_b || value_v),
 except they are additively homorphic, e.g.
  C(b1, v1) - C(b2, v2) = C(b1 - b2, v1 - v2) and
  C(b1, v1) - C(b1, v1) = 0, etc.
 The commitments themselves are EC points, serialized as 33 bytes.
 In addition to the commit function this implementation includes
 utility functions for verifying that a set of commitments sums
 to zero, and for picking blinding factors that sum to zero.
 If the blinding factors are uniformly random, pedersen commitments
 have information theoretic privacy.

Borromean ring signatures are a novel efficient ring signature
 construction for AND/OR admissions policies (the code here implements
 an AND of ORs, each of any size).  This construction requires
 32 bytes of signature per pubkey used plus 32 bytes of constant
 overhead. With these you can construct signatures like "Given pubkeys
 A B C D E F G, the signer knows the discrete logs
 satisifying (A || B) & (C || D || E) & (F || G)".

ZK range proofs allow someone to prove a pedersen commitment is in
 a particular range (e.g. [0..2^64)) without revealing the specific
 value.  The construction here is based on the above borromean
 ring signature and uses a radix-4 encoding and other optimizations
 to maximize efficiency.  It also supports encoding proofs with a
 non-private base-10 exponent and minimum-value to allow trading
 off secrecy for size and speed (or just avoiding wasting space
 keeping data private that was already public due to external
 constraints).

A proof for a 32-bit mantissa takes 2564 bytes, but 2048 bytes of
 this can be used to communicate a private message to a receiver
 who shares a secret random seed with the prover.

Also: get rid of precomputed H tables (Pieter Wuille)
2020-07-24 14:49:33 +02:00