55 Commits

Author SHA1 Message Date
Tim Ruffing
95c31389fc Test for rejection of trailing bytes in range proofs 2018-05-24 13:29:36 +02:00
Tim Ruffing
5fd8271f03 Test for rejection of trailing bytes in surjection proofs 2018-05-23 15:59:01 +02:00
Tim Ruffing
af7d4b0744 Reject surjection proofs with trailing garbage 2018-05-23 14:56:14 +02:00
datavetaren
6e7db6fd3b Minor bugfix. Wrong length due to NUL character. 2018-05-16 05:02:21 +02:00
Jonas Nick
410326df67 Add whitelisting benchmark 2018-04-17 22:06:06 +00:00
Gregory Sanders
7b05707c8f add whitelist_impl.h to include for dist 2018-04-05 16:39:34 -07:00
Andrew Poelstra
bad5b3dc92 generator: add API tests 2018-04-05 16:39:34 -07:00
Andrew Poelstra
1c966a2989 generator: remove unnecessary ARG_CHECK from generate() 2018-04-05 16:39:34 -07:00
Gregory Sanders
dd13b2b439 Fix generator makefile
Include test_impl.h
2018-04-05 16:39:34 -07:00
Jonas Nick
3d6ac31103 Add n_keys argument to whitelist_verify 2018-04-05 16:39:34 -07:00
Jonas Nick
ee1e30de90 Fix checks of whitelist serialize/parse arguments 2018-04-05 16:39:34 -07:00
Andrew Poelstra
c28edd75fc whitelist: fix serialize/parse API to take serialized length 2018-04-05 16:39:34 -07:00
Andrew Poelstra
0ba915f214 rangeproof: add API tests 2018-04-05 16:39:34 -07:00
Andrew Poelstra
1bb1723d4e surjectionproof: rename unit test functions to be more consistent with other modules 2018-04-05 16:39:34 -07:00
Andrew Poelstra
01a8848609 surjectionproof: add API unit tests 2018-04-05 16:39:34 -07:00
Andrew Poelstra
0ca14dcca0 surjectionproof: tests_impl.h s/assert/CHECK/g 2018-04-05 16:39:34 -07:00
Andrew Poelstra
995e5b709f rangeproof: fix memory leak in unit tests 2018-04-05 16:39:34 -07:00
Andrew Poelstra
88e52d6eec add surjection proof module
Includes fix and tests by Jonas Nick.
2018-04-05 16:39:34 -07:00
Andrew Poelstra
1a0ae1b0af Implement ring-signature based whitelist delegation scheme 2018-04-05 16:39:34 -07:00
Andrew Poelstra
f948ca216d 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
2018-04-05 16:39:34 -07:00
Pieter Wuille
c3db107c44 Expose generator in pedersen/rangeproof API 2018-04-05 16:39:34 -07:00
Pieter Wuille
c2f471f11d Constant-time generator module 2018-04-05 16:39:34 -07:00
Andrew Poelstra
5912d2665f rangeproof: expose sidechannel message field in the signing API
Including a fix by Jonas Nick.
2018-04-05 16:39:33 -07:00
Andrew Poelstra
e28302cbd7 [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.
2018-04-05 16:39:33 -07:00
Andrew Poelstra
e596d3a389 Get rid of precomputed H tables (Pieter Wuille) 2018-04-05 16:39:33 -07:00
Gregory Maxwell
a6dd429dc7 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.
2018-04-05 16:39:33 -07:00
Andrew Poelstra
7c1b91ba4b parameterize ecmult_const over input size 2018-04-05 21:05:13 +00:00
Pieter Wuille
d1dc9dfc0a Get rid of reserved _t in type names 2017-09-27 15:03:20 -07:00
Dan Raviv
abe2d3e84b Fix header guards using reserved identifiers
Identifiers starting with an underscore and followed immediately by a capital letter are reserved by the C++ standard.

The only header guards not fixed are those in the headers auto-generated from java.
2017-08-26 18:44:21 +03:00
Andrew Poelstra
b595163992 recovery: add tests to cover API misusage 2016-11-28 03:28:58 +00:00
Andrew Poelstra
6f8ae2f3c0 ecdh: test NULL-checking of arguments
Boosts the ECDH module to 100% coverage
2016-11-26 20:17:14 +00:00
Pieter Wuille
e06e878fd7 Remove Schnorr experiment 2016-11-17 18:55:06 -08:00
bgorlick
37697832d6 Restructure nonce clearing
Make sure we clear the nonce data even if the nonce function fails (it may have written partial data), and call memset only once in the case we iterate to produce a valid signature.
2016-10-21 04:59:32 -07:00
bgorlick
0f9e69db55 Restructure nonce clearing
Make sure we clear the nonce data even if the nonce function fails (it may have written partial data), and call memset only once in the case we iterate to produce a valid signature.
2016-10-21 03:50:10 -07:00
Wladimir J. van der Laan
001f1763c7 ARM assembly implementation of field_10x26 inner
Rebased-by: Pieter Wuille <pieter.wuille@gmail.com>
2016-05-25 18:27:47 +02:00
Gregory Maxwell
8e48787d97 Change secp256k1_ec_pubkey_combine's count argument to size_t. 2015-10-31 19:04:34 +00:00
Gregory Maxwell
1b3efc1147 Move secp256k1_ecdsa_sig_recover into the recovery module. 2015-10-22 22:57:33 +00:00
Pieter Wuille
3bb9c44719 Rewrite ECDSA signature parsing code
There are now 2 encoding formats supported: 64-byte "compact" and DER.
The latter is strict: the data has to be exact DER, though the values
inside don't need to be valid.
2015-10-21 16:13:37 +02:00
Pieter Wuille
fa57f1bdf1 Use secp256k1_rand_int and secp256k1_rand_bits more
Update the unit tests to make use of the new RNG functions.
2015-10-21 16:13:37 +02:00
Pieter Wuille
f79aa88373 Bugfix: swap arguments to noncefp 2015-10-21 03:40:37 +02:00
Gregory Maxwell
213aa67397 Do not force benchmarks to be statically linked.
Libtool will do the right thing and use whatever is available
 based on --enable-shared/--enable-static.

This also means that some of the things we build actually
 test the dynamic library.
2015-09-29 19:03:51 +00:00
Gregory Maxwell
4e64608082 Include public module headers when compiling modules.
Also fix the nullness requirements for schnorr nonce-pair generation.
2015-09-24 21:50:06 +00:00
Pieter Wuille
1f414378b8
Merge pull request #316
2b199de Use the explicit NULL macro for pointer comparisons. (Gregory Maxwell)
2015-09-24 19:36:54 +02:00
Gregory Maxwell
cfe0ed916a Fix miscellaneous style nits that irritate overactive static analysis.
Also increase consistency with how overflow && zero is tested, and
 avoid some mixed declarations and code that GCC wasn't detecting.
2015-09-24 08:42:37 +00:00
Gregory Maxwell
2b199de888 Use the explicit NULL macro for pointer comparisons.
This makes it more clear that a null check is intended. Avoiding the
 use of a pointer as a test condition alse increases the type-safety
 of the comparisons.

(This is also MISRA C 2012 rules 14.4 and 11.9)
2015-09-23 22:00:43 +00:00
Pieter Wuille
dd891e0ed5 Get rid of _t as it is POSIX reserved 2015-09-21 21:03:37 +02:00
Luke Dashjr
486b9bb8ce Use a flags bitfield for compressed option to secp256k1_ec_pubkey_serialize and secp256k1_ec_privkey_export 2015-09-19 19:33:30 +00:00
Luke Dashjr
05732c5a5f Callback data: Accept pointers to either const or non-const data 2015-09-19 19:33:28 +00:00
Luke Dashjr
788038d323 Use size_t for lengths (at least in external API) 2015-09-19 19:33:21 +00:00
Pieter Wuille
dc0ce9fc41 [API BREAK] Change argument order to out/outin/in 2015-09-04 17:45:57 +02:00