803 Commits

Author SHA1 Message Date
Jonas Nick
619b8f16dc Fix pedersen_blind_generator_blind_sum return value documentation 2017-07-11 16:35:39 +02:00
Andrew Poelstra
12bd9fd8e5 Merge pull request #8 from jonasnick/whitelist_api_fix
Fix checks of whitelist serialize/parse arguments
2017-06-27 13:59:43 +00:00
Jonas Nick
a809ac484f Fix checks of whitelist serialize/parse arguments 2017-06-27 15:02:40 +02:00
Andrew Poelstra
cb8a394102 Merge pull request #7 from apoelstra/whitelist-api-fix
whitelist: fix serialize/parse API to take serialized length
2017-06-26 17:57:03 +00:00
Andrew Poelstra
0f21e05dfa
whitelist: fix serialize/parse API to take serialized length 2017-06-26 17:08:47 +00:00
Andrew Poelstra
4f7a50e173 Merge pull request #6 from jonasnick/doc-fixes
Fix include/secp256k1_rangeproof.h function argument documentation.
2017-05-09 10:26:47 +00:00
Jonas Nick
5b72133255 Fix include/secp256k1_rangeproof.h function argument documentation. 2017-05-09 02:00:14 +02:00
Andrew Poelstra
7dd7883de6 Merge pull request #5 from apoelstra/test-cleanup
Additional rangeproof and surjection proof tests
2017-05-08 09:45:04 +00:00
Andrew Poelstra
0cfa29f87a rangeproof: add API tests 2017-05-08 09:44:11 +00:00
Andrew Poelstra
d8295970d2 surjectionproof: rename unit test functions to be more consistent with other modules 2017-05-08 09:44:11 +00:00
Andrew Poelstra
5eae1b9793 surjectionproof: add API unit tests 2017-05-08 09:44:11 +00:00
Andrew Poelstra
8454a98521 surjectionproof: tests_impl.h s/assert/CHECK/g 2017-05-08 09:44:08 +00:00
Andrew Poelstra
d702d210b8 rangeproof: fix memory leak in unit tests 2017-05-02 16:55:48 +00:00
Andrew Poelstra
d78f12b04e add surjection proof module
Includes fix and tests by Jonas Nick.
2017-04-03 08:18:52 -07:00
Andrew Poelstra
da035050f8 Implement ring-signature based whitelist delegation scheme 2017-04-03 08:18:52 -07:00
Andrew Poelstra
6eebf82d8a rangeproof: add summing function for blinded generators; drop excess and gen from verify_tally 2017-04-03 08:18:52 -07:00
Pieter Wuille
4577c24234 Expose generator in pedersen/rangeproof API 2017-04-03 07:53:53 -07:00
Pieter Wuille
e7f7b3c941 Constant-time generator module 2017-04-03 07:53:52 -07:00
Andrew Poelstra
9722b11506 rangeproof: expose sidechannel message field in the signing API
Including a fix by Jonas Nick.
2017-04-03 07:46:53 -07:00
Andrew Poelstra
9f21e1b518 [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.
2017-04-03 07:46:53 -07:00
Pieter Wuille
dc05520096 Get rid of precomputed H tables 2017-04-03 07:46:52 -07:00
Gregory Maxwell
8de58308d8 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.
2017-04-03 07:03:48 -07:00
Greg Maxwell
f7b48c577d Add 64-bit integer utilities 2017-04-03 07:03:18 -07:00
Pieter Wuille
119949232a
Merge #408: Add secp256k1_ec_pubkey_negate and secp256k1_ec_privkey_negate
8e48aa6 Add `secp256k1_ec_pubkey_negate` and `secp256k1_ec_privkey_negate` (Andrew Poelstra)

Tree-SHA512: 28eeca0b04001958ad86b3c802e33a13273514e9e9802d5b358fd577dc95421a2cffb5591716bea10300717f742f0941c465b9df71dbb4c66d174c643887e06f
2017-03-21 17:54:06 -07:00
Pieter Wuille
6af0871070
Merge #441: secp256k1_context_randomize: document.
72d952c FIXUP: Missing "is" (Rusty Russell)
70ff29b secp256k1_context_randomize: document. (Rusty Russell)

Tree-SHA512: c1f48431e07a23b572838d63250d5a356ff5b321dd242cf0af5227ee89b9795d49a762b0c7311bb7284ccd487c68b3d1f16cf6824eac30fc3f8becdf2b891dad
2017-03-21 17:36:54 -07:00
Pieter Wuille
ab31a524b4
Merge #444: test: Use checked_alloc
5eb030c test: Use checked_alloc (Wladimir J. van der Laan)

Tree-SHA512: f0fada02664fca3b4f48795ce29a187331f86f80fc1605150fcfc451e7eb4671f7b5dff09105c9927e28af6d1dafd1edad1671dddd412110f4b5950153df499d
2017-03-21 17:34:05 -07:00
Pieter Wuille
eda5c1a062
Merge #449: Remove executable bit from secp256k1.c
51b77ae Remove executable bit from secp256k1.c (Emil Rus)
2017-03-21 17:01:30 -07:00
Emil Rus
51b77ae619 Remove executable bit from secp256k1.c 2017-03-17 17:27:25 +02:00
Wladimir J. van der Laan
5eb030ca41 test: Use checked_alloc 2017-02-26 15:05:42 +01:00
Rusty Russell
72d952c9c4 FIXUP: Missing "is"
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-21 14:43:09 +10:30
Rusty Russell
70ff29b6a7 secp256k1_context_randomize: document.
I think I summarized it correctly after IRC discussion with gmaxwell
and andytoshi; I didn't know it existed :(

It's regrettable to expose this level of detail, but users need to know
this to make a decision about how to use it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-02-14 15:29:33 +10:30
Pieter Wuille
9d560f992d
Merge #428: Exhaustive recovery
2cee5fd exhaustive tests: add recovery module (Andrew Poelstra)
678b0e5 exhaustive tests: remove erroneous comment from ecdsa_sig_sign (Andrew Poelstra)
03ff8c2 group_impl.h: remove unused `secp256k1_ge_set_infinity` function (Andrew Poelstra)
a724d72 configure: add --enable-coverage to set options for coverage analysis (Andrew Poelstra)
b595163 recovery: add tests to cover API misusage (Andrew Poelstra)
6f8ae2f ecdh: test NULL-checking of arguments (Andrew Poelstra)
25e3cfb ecdsa_impl: replace scalar if-checks with VERIFY_CHECKs in ecdsa_sig_sign (Andrew Poelstra)
2016-12-28 04:35:23 -08:00
Andrew Poelstra
8e48aa60dc Add secp256k1_ec_pubkey_negate and secp256k1_ec_privkey_negate 2016-12-20 00:37:37 +00:00
Andrew Poelstra
2cee5fd4c9 exhaustive tests: add recovery module 2016-12-16 21:50:16 +00:00
Pieter Wuille
8225239f49
Merge #433: Make the libcrypto detection fail the newer API.
12de863 Make the libcrypto detection fail the newer API. (Gregory Maxwell)
2016-12-12 11:07:38 -08:00
Gregory Maxwell
12de86387f Make the libcrypto detection fail the newer API.
OpenSSL 1.1 makes ECDSA_SIG opaque and our tests need access
inside this object.

The comparison tests against OpenSSL aren't important for most
users, but the build failing is...
2016-12-12 07:56:01 +00:00
Andrew Poelstra
678b0e5466 exhaustive tests: remove erroneous comment from ecdsa_sig_sign
Mathematically, we always overflow when using the exhaustive tests (because our
scalar order is 13 and our field order is on the order of 2^256), but the
`overflow` variable returned when parsing a b32 as a scalar is always set
to 0, to prevent infinite (or practically infinite) loops searching for
non-overflowing scalars.
2016-11-28 19:46:18 +00:00
Pieter Wuille
2928420c1b
Merge #427: Remove Schnorr from travis as well
8eecc4a Remove Schnorr from travis as well (Pieter Wuille)
2016-11-27 21:12:11 -08:00
Andrew Poelstra
03ff8c2d0a group_impl.h: remove unused secp256k1_ge_set_infinity function
Also remove `secp256k1_fe_verify` from field_*_.impl.h when VERIFY is not defined
2016-11-28 03:29:01 +00:00
Andrew Poelstra
a724d7296d configure: add --enable-coverage to set options for coverage analysis 2016-11-28 03:29:01 +00:00
Andrew Poelstra
b595163992 recovery: add tests to cover API misusage 2016-11-28 03:28:58 +00:00
Pieter Wuille
8eecc4a302 Remove Schnorr from travis as well 2016-11-27 14:31:51 -08: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
Andrew Poelstra
25e3cfbf9b ecdsa_impl: replace scalar if-checks with VERIFY_CHECKs in ecdsa_sig_sign
Whenever ecdsa_sig_sign is called, in the case that r == 0 or r overflows,
we want to retry with a different nonce rather than fail signing entirely.
Because of this, we always check the nonce conditions before calling
sig_sign, so these checks should always pass (and in particular, they
are inaccessible through the API and appear as uncovered code in test
coverage).
2016-11-26 20:14:19 +00:00
Pieter Wuille
a8abae7e5f
Merge #310: Add exhaustive test for group functions on a low-order subgroup
b4ceedf Add exhaustive test for verification (Andrew Poelstra)
83836a9 Add exhaustive tests for group arithmetic, signing, and ecmult on a small group (Andrew Poelstra)
20b8877 Add exhaustive test for group functions on a low-order subgroup (Andrew Poelstra)
2016-11-25 16:48:57 -08:00
Andrew Poelstra
b4ceedf14f Add exhaustive test for verification 2016-11-26 00:35:02 +00:00
Andrew Poelstra
83836a9547 Add exhaustive tests for group arithmetic, signing, and ecmult on a small group
If you compile without ./configure --enable-exhaustive-tests=no,
this will create a binary ./exhaustive_tests which will execute
every function possible on a group of small order obtained by
moving to a twist of our curve and locating a generator of small
order.

Currently defaults to order 13, though by changing some #ifdefs
you can get a couple other ones. (Currently 199, which will take
forever to run, and 14, which won't work because it's composite.)

TODO exhaustive tests for the various modules
2016-11-26 00:35:00 +00:00
Andrew Poelstra
20b8877be1 Add exhaustive test for group functions on a low-order subgroup
We observe that when changing the b-value in the elliptic curve formula
`y^2 = x^3 + ax + b`, the group law is unchanged. Therefore our functions
for secp256k1 will be correct if and only if they are correct when applied
to the curve defined by `y^2 = x^3 + 4` defined over the same field. This
curve has a point P of order 199.

This commit adds a test which computes the subgroup generated by P and
exhaustively checks that addition of every pair of points gives the correct
result.

Unfortunately we cannot test const-time scalar multiplication by the same
mechanism. The reason is that these ecmult functions both compute a wNAF
representation of the scalar, and this representation is tied to the order
of the group.

Testing with the incomplete version of gej_add_ge (found in 5de4c5dff^)
shows that this detects the incompleteness when adding P - 106P, which
is exactly what we expected since 106 is a cube root of 1 mod 199.
2016-11-25 20:45:29 +00:00
Pieter Wuille
80773a6b74
Merge #425: Remove Schnorr experiment
e06e878 Remove Schnorr experiment (Pieter Wuille)
2016-11-25 11:30:28 -08:00
Pieter Wuille
e06e878fd7 Remove Schnorr experiment 2016-11-17 18:55:06 -08:00