1128 Commits

Author SHA1 Message Date
Gregory Sanders
dbc49df80c fix spelling in documentation 2020-07-24 14:50:48 +02:00
Tim Ruffing
47be098bac Test for rejection of trailing bytes in range proofs 2020-07-24 14:50:48 +02:00
Tim Ruffing
16aaa4a02c Test for rejection of trailing bytes in surjection proofs 2020-07-24 14:50:48 +02:00
Tim Ruffing
949e994cb3 Reject surjection proofs with trailing garbage 2020-07-24 14:50:48 +02:00
datavetaren
c87618157e Minor bugfix. Wrong length due to NUL character. 2020-07-24 14:50:48 +02:00
Jonas Nick
fc3dc94049 Add whitelisting benchmark 2020-07-24 14:50:48 +02:00
Gregory Sanders
edc7cb6cdd add whitelist_impl.h to include for dist 2020-07-24 14:49:33 +02:00
Andrew Poelstra
4320490e88 generator: add API tests 2020-07-24 14:49:33 +02:00
Andrew Poelstra
126493ef01 generator: remove unnecessary ARG_CHECK from generate() 2020-07-24 14:49:33 +02:00
Gregory Sanders
253f131310 Fix generator makefile
Include test_impl.h
2020-07-24 14:49:33 +02:00
Jonas Nick
3997128ad9 Fix pedersen_blind_generator_blind_sum return value documentation 2020-07-24 14:49:33 +02:00
Jonas Nick
04f4c09111 Add n_keys argument to whitelist_verify 2020-07-24 14:49:33 +02:00
Jonas Nick
dbf3d752a8 Fix checks of whitelist serialize/parse arguments 2020-07-24 14:49:33 +02:00
Andrew Poelstra
29d0d562dc whitelist: fix serialize/parse API to take serialized length 2020-07-24 14:49:33 +02:00
Jonas Nick
660ad39fb3 Fix include/secp256k1_rangeproof.h function argument documentation. 2020-07-24 14:49:33 +02:00
Andrew Poelstra
e13bdf2f23 rangeproof: add API tests 2020-07-24 14:49:33 +02:00
Andrew Poelstra
18c5c62b45 surjectionproof: rename unit test functions to be more consistent with other modules 2020-07-24 14:49:33 +02:00
Andrew Poelstra
5f1ad03d00 surjectionproof: add API unit tests 2020-07-24 14:49:33 +02:00
Andrew Poelstra
f858a4e3d5 surjectionproof: tests_impl.h s/assert/CHECK/g 2020-07-24 14:49:33 +02:00
Andrew Poelstra
002002e735 rangeproof: fix memory leak in unit tests 2020-07-24 14:49:33 +02:00
Andrew Poelstra
ba8b4f53ef add surjection proof module
Includes fix and tests by Jonas Nick.
2020-07-24 14:49:33 +02:00
Andrew Poelstra
8c77fe1590 Implement ring-signature based whitelist delegation scheme 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
Pieter Wuille
360e218043 Constant-time generator module 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
Greg Maxwell
3cf8f70ba1 Add 64-bit integer utilities 2020-07-24 14:44:53 +02:00
Jonas Nick
2309c7dd4a
Merge #769: Undef HAVE___INT128 in basic-config.h to fix gen_context compilation
22e578bb11fe62d3e8ac05b5278a076bf7f2fa2e Undef HAVE___INT128 in basic-config.h to fix gen_context compilation (Tim Ruffing)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 22e578bb11fe62d3e8ac05b5278a076bf7f2fa2e

Tree-SHA512: 91e11c3feade13923a01c30025b7f01d0cb6d7d88cd7a19d490373d2fb4552f2ca1ab0d9138096268999bcbfd51ef3c9af64ec8ab0dc8ee2fa60be16d2b5af64
2020-07-21 19:12:49 +00:00
Tim Ruffing
22e578bb11 Undef HAVE___INT128 in basic-config.h to fix gen_context compilation
Fixes #768.
2020-07-21 11:09:23 +02:00
Jonas Nick
3f4a5a10e4
Merge #765: remove dead store in ecdsa_signature_parse_der_lax
f00d6575ca0dcca11e085b20afa4d73dc8742ddc remove dead store in ecdsa_signature_parse_der_lax (fanquake)

Pull request description:

ACKs for top commit:
  elichai:
    utACK f00d6575ca0dcca11e085b20afa4d73dc8742ddc, it does look like we don't use that assignment
  jonasnick:
    ACK f00d6575ca0dcca11e085b20afa4d73dc8742ddc

Tree-SHA512: 9aa54c901f299341c309411b0247720f5152a131dd346c19be7ee21865e3a822e8cf91b869e28ef6288adaf31660bc2e18874e304052468a9be6b7027674af30
2020-06-29 08:38:35 +00:00
fanquake
f00d6575ca
remove dead store in ecdsa_signature_parse_der_lax
This change was made in bitcoin/bitcoin without upstreaming. So this is
a followup to the comment here:
https://github.com/bitcoin/bitcoin/pull/19228#issuecomment-641795558.

See also: https://github.com/bitcoin/bitcoin/pull/11073.
2020-06-29 13:23:26 +08:00
Tim Ruffing
dbd41db16a
Merge #759: Fix uninitialized variables in ecmult_multi test
2e7fc5b5372067ecd33b2304e8c88ed6de98ff13 Fix uninitialized variables in ecmult_multi test (Jonas Nick)

Pull request description:

  Fixes #756

ACKs for top commit:
  real-or-random:
    ACK 2e7fc5b5372067ecd33b2304e8c88ed6de98ff13 I inspected the diff. I did not test it and I did not check whether if makes the warning go away
  elichai:
    tACK 2e7fc5b5372067ecd33b2304e8c88ed6de98ff13

Tree-SHA512: 674400134f5487236f5b6e8b3020b346d43662511628cdf6dd1bd7ba1de985bf93f5be11f5650f250ff37b5f87eb4b01d90ed53d41193c05a420d3f5a2d63470
2020-06-15 16:07:12 +02:00
Jonas Nick
2e7fc5b537 Fix uninitialized variables in ecmult_multi test 2020-06-15 09:02:54 +00:00
Tim Ruffing
2ed54da18a
Merge #755: Recovery signing: add to constant time test, and eliminate non ct operators
28609507e70a172dd8f39de4aa55f851452fc0b4 Add tests for the cmov implementations (Elichai Turkel)
73596a85a2ab9c885e58a7a2a8876355a6ae68e4 Add ecdsa_sign_recoverable to the ctime tests (Elichai Turkel)
2876af4f8da952e39c06bc229d68cd4892ea2c85 Split ecdsa_sign logic into a new function and use it from ecdsa_sign and recovery (Elichai Turkel)

Pull request description:

  Hi,
  The recovery module was overlooked in #708 and #710, so this adds it to the `valgrind_ctime_test` and replaces the secret dependent branching with the cmovs,
  I created a new function `secp256k1_ecdsa_sign_inner` (feel free to bikeshed) which does the logic both for ecdsa_sign and for ecdsa_sign_recoverable, such that next time when things get changed/improved in ecdsa it will affect the recoverable signing too.

ACKs for top commit:
  jonasnick:
    ACK 28609507e70a172dd8f39de4aa55f851452fc0b4
  real-or-random:
    ACK 28609507e70a172dd8f39de4aa55f851452fc0b4 read the diff, tested with valgrind including ctime tests

Tree-SHA512: 4730301dcb62241d79f18eb8fed7e9ab0e20d1663a788832cb6cf4126baa7075807dc31896764b6f82d52742fdb636abc6b75e4344c6f117305904c628a5ad59
2020-06-08 15:45:58 +02:00
Elichai Turkel
28609507e7
Add tests for the cmov implementations 2020-06-03 13:19:12 +03:00
Elichai Turkel
73596a85a2
Add ecdsa_sign_recoverable to the ctime tests 2020-06-03 13:19:11 +03:00
Elichai Turkel
2876af4f8d
Split ecdsa_sign logic into a new function and use it from ecdsa_sign and recovery 2020-06-03 13:19:09 +03:00
Tim Ruffing
5e1c885efb
Merge #754: Fix uninit values passed into cmov
f79a7adcf555ccc78b591850ea15c64fbfbca152 Add valgrind uninit check to cmovs output (Elichai Turkel)
a39c2b09de304b8f24716b59219ae37c2538c242 Fixed UB(arithmetics on uninit values) in cmovs (Elichai Turkel)

Pull request description:

  This should fix #753.
  Used @peterdettman's solution here for the `ECMULT_CONST_TABLE_GET_GE` https://github.com/bitcoin-core/secp256k1/issues/753#issuecomment-631316091
  and in ecdsa_sign I initialize `s` and `r` to a zero scalar.

  The second commit adds a valgrind check to the cmovs that could've caught this (in ecdsa_sign, not in ecmult_const because there's a scalar clear there under `VERIFY_SETUP`)

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

Tree-SHA512: 6fd7b7c84f392bda733a973f4dcfc12bf1478aac2591e2c87b69e637847d3b063c4243cc8feccaffc3a5824c18183a5e66bd4251c2322abaf63bb6439b38defe
2020-06-02 18:06:44 +02:00
Elichai Turkel
f79a7adcf5
Add valgrind uninit check to cmovs output 2020-05-26 23:30:56 +03:00
Tim Ruffing
05d315affe
Merge #752: autoconf: Use ":" instead of "dnl" as a noop
5e8747ae2a0c915d079837d238f8b84841a4ce5c autoconf: Use ":" instead of "dnl" as a noop (Tim Ruffing)

Pull request description:

  Fixes #424.

Top commit has no ACKs.

Tree-SHA512: a83664afbc6ca1254c4767161bfbec82f3489a8a248ba7a5a46ed9ec2a39232cf92f504accadd4dbb1a6ea4791dbf7f0e1f030e51f02f49eb9a38a2e509ee6c2
2020-05-22 13:31:45 +02:00
Elichai Turkel
a39c2b09de
Fixed UB(arithmetics on uninit values) in cmovs 2020-05-22 13:25:26 +03:00
Jonas Nick
3a6fd7f636
Merge #750: Add macOS to the CI
71757da5ccece100b1eca6c70b4d87e2542cff97 Explictly pass SECP256K1_BENCH_ITERS to the benchmarks in travis.sh (Elichai Turkel)
99bd661d71fe17be7b3de4707a0264c41a63ebe8 Replace travis_wait with a loop printing "\a" to stdout every minute (Elichai Turkel)
bc818b160cdaaccff2162206cc15915fa5f0cca8 Bump travis Ubuntu from xenial(16.04) to bionic(18.04) (Elichai Turkel)
0c5ff9066e6fa41b1fbd5d0b8c2f02e8a04e96ea Add macOS support to travis (Elichai Turkel)
b6807d91d83e9597ffecec999eb761b8571a1f26 Move travis script into a standalone sh file (Elichai Turkel)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK 71757da5ccece100b1eca6c70b4d87e2542cff97 I inspected the diff
  jonasnick:
    ACK 71757da5ccece100b1eca6c70b4d87e2542cff97

Tree-SHA512: e8fab725ef5ed98c795f39d7f26b5d967a6bd730d40eb7d9793986858bf34770b0350c1b7b1d14ae608dfff9375a0750ec67c8e6d0d4b562ab917f5e645aa67b
2020-05-18 19:38:47 +00:00
Tim Ruffing
5e8747ae2a autoconf: Use ":" instead of "dnl" as a noop
Fixes #424.
2020-05-18 12:30:01 +02:00
Elichai Turkel
71757da5cc
Explictly pass SECP256K1_BENCH_ITERS to the benchmarks in travis.sh 2020-05-18 12:01:07 +03:00
Elichai Turkel
99bd661d71
Replace travis_wait with a loop printing "\a" to stdout every minute 2020-05-11 16:02:25 +03:00
Elichai Turkel
bc818b160c
Bump travis Ubuntu from xenial(16.04) to bionic(18.04) 2020-05-11 16:01:20 +03:00
Elichai Turkel
0c5ff9066e
Add macOS support to travis 2020-05-11 16:01:20 +03:00
Elichai Turkel
b6807d91d8
Move travis script into a standalone sh file 2020-05-11 16:01:16 +03:00