109 Commits

Author SHA1 Message Date
Andrew Poelstra
1c830b4c9a
Merge pull request #53 from romanz/zkp-trezor
Changes necessary for usage on Trezor
2019-04-12 16:42:45 +00:00
Tim Ruffing
edd941c94b Make randomization of a non-signing context a noop
Before this commit secp256k1_context_randomize called illegal_callback
when called on a context not initialized for signing. This is not
documented. Moreover, it is not desirable because non-signing contexts
may use randomization in the future.

This commit makes secp256k1_context_randomize a noop in this case. This
is safe because the context cannot be used for signing anyway.

This fixes #573 and it fixes rust-bitcoin/rust-secp256k1#82.
2019-04-12 17:36:44 +02:00
Roman Zeyde
383389a0eb Fix a small typo in the generator parameter name 2019-04-11 17:59:58 +03:00
Tim Ruffing
9a949e5f2b Allow usage of external default callbacks 2019-04-01 17:53:26 +02:00
Tim Ruffing
af2569b8a7 Explain caller's obligations for preallocated memory 2019-04-01 17:53:26 +02:00
Tim Ruffing
e4a2f8e500 Move _preallocated functions to separate header 2019-03-05 13:23:13 +01:00
Tim Ruffing
7366ab7f8c Export _preallocated functions 2019-03-05 13:23:13 +01:00
Tim Ruffing
1738dd0eb5 Switch to a single malloc call 2019-03-05 13:22:53 +01:00
Andrew Poelstra
f6a6bca22f musig: remove musig_session API docs about session ID reuse; link to Blockstream blog post 2019-02-21 15:02:13 +00:00
Andrew Poelstra
89b7f5b73b f nits 2019-02-20 15:25:47 +00:00
Jonas Nick
2fc700a943 Add 3-of-3 MuSig example 2019-02-06 11:27:46 +00:00
Jonas Nick
77d5b4ac7d Add MuSig module which allows creating n-of-n multisignatures and adaptor signatures. 2019-02-06 11:27:37 +00:00
Andrew Poelstra
f0e4bb9283 Add schnorrsig module which implements BIP-schnorr [0] compatible signing, verification and batch verification.
[0] https://github.com/sipa/bips/blob/bip-schnorr/bip-schnorr.mediawiki
2019-01-29 11:02:07 +00:00
Jonas Nick
71c5fe0f6e Add comment to explain effect of max_n_iterations in surjectionproof_init 2018-12-14 20:25:51 +00:00
Andrew Poelstra
60c173b640 rangeproof: verify correctness of pedersen commitments when parsing 2018-12-14 20:25:51 +00:00
Andrew Poelstra
32d7526cd5 generator: verify correctness of point when parsing 2018-12-14 20:25:51 +00:00
Frank V. Castellucci
e065d7df9f Expose generator in shared library
Was failing linking to `*.so` library
2018-12-14 20:25:51 +00:00
Gregory Sanders
fb1ba329aa fix spelling in documentation 2018-12-14 20:25:51 +00:00
Andrew Poelstra
a707865bc5 generator: add API tests 2018-12-14 20:25:51 +00:00
Jonas Nick
526c65499f Fix pedersen_blind_generator_blind_sum return value documentation 2018-12-14 20:25:51 +00:00
Jonas Nick
b51886e722 Add n_keys argument to whitelist_verify 2018-12-14 20:25:51 +00:00
Jonas Nick
37c57de083 Fix checks of whitelist serialize/parse arguments 2018-12-14 20:25:51 +00:00
Andrew Poelstra
9b8a9d91eb whitelist: fix serialize/parse API to take serialized length 2018-12-14 20:25:51 +00:00
Jonas Nick
7f17515609 Fix include/secp256k1_rangeproof.h function argument documentation. 2018-12-14 20:25:51 +00:00
Andrew Poelstra
0d817020d9 rangeproof: add API tests 2018-12-14 20:25:51 +00:00
Andrew Poelstra
0c17f7972a add surjection proof module
Includes fix and tests by Jonas Nick.
2018-12-14 20:25:51 +00:00
Andrew Poelstra
c174f0c609 Implement ring-signature based whitelist delegation scheme 2018-12-14 20:25:51 +00:00
Andrew Poelstra
a2bc6604f9 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-12-14 20:25:51 +00:00
Pieter Wuille
21bfb3c91a Expose generator in pedersen/rangeproof API 2018-12-14 20:25:51 +00:00
Pieter Wuille
f4620de040 Constant-time generator module 2018-12-14 20:25:51 +00:00
Andrew Poelstra
d46fc3c191 rangeproof: expose sidechannel message field in the signing API
Including a fix by Jonas Nick.
2018-12-14 20:25:51 +00:00
Andrew Poelstra
cf40b1bed2 [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-12-14 20:25:51 +00:00
Gregory Maxwell
ae1e576f67 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-12-14 20:25:51 +00:00
Pieter Wuille
314a61d724
Merge #553: add static context object which has no capabilities
40fde61 prevent attempts to modify `secp256k1_context_no_precomp` (Andrew Poelstra)
ed7c084 add static context object which has no capabilities (Andrew Poelstra)

Pull request description:

Tree-SHA512: a843ed7ba00a00a46eec3146ce428d4b49eb440af766f44d731b1f51553d08de8cc9a0af5ed114d0dfdca6f4bf4a2ede4dbd6a37d6bd818b81630089424a0ba5
2018-11-05 18:25:56 -08:00
Andrew Poelstra
ed7c08417a add static context object which has no capabilities 2018-10-04 15:16:34 +00:00
Kirill Fomichev
c8fbc3c397 [ECDH API change] Allow pass arbitrary data to hash function 2018-05-17 00:38:58 +03:00
Kirill Fomichev
b00be65056 [ECDH API change] Support custom hash function 2018-05-17 00:05:09 +03:00
Andrew Poelstra
6fe50439ae scratch: add stack frame support 2018-04-05 22:49:29 +00:00
Thomas Kerin
1646ace4d5
secp256k1_ec_privkey_negate - fix documentation 2018-02-28 14:10:07 +01:00
Andrew Poelstra
548de42ecf add resizeable scratch space API
Alignment support by Pieter Wuille.
2017-12-07 20:13:04 +00: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
Pieter Wuille
f532bdc9f7
Merge #459: Add pubkey prefix constants to include/secp256k1.h
bc61b91 add pubkey prefix constants to include/secp256k1.h (Andrew Poelstra)

Pull request description:

  In future multisig implementations we will need to pass nonces around, which are algebraically pubkeys but should not be decodable as pubkeys. The way to do this is to change the prefix byte from the ordinary 0x02/0x03 to something else. However, some forks (notably `secp256k1-zkp`) have started using some bytes for their own encodings, and if we continue to use hardcoded constants the risk of conflict is increased.

  This commit puts the prefixes used by the main library into the `include/secp256k1.h` so that the constants we're using will at least be in a standard easy-to-reference place.

Tree-SHA512: 37fa25be5074b7c519a9c69421320a62f32a3818f144254eb57f96c6657b993fc01962a5c670574275d1c59b095a6c89e60736123f032d6736907284eac526d7
2017-08-10 16:42:01 -07:00
Andrew Poelstra
bc61b91aca
add pubkey prefix constants to include/secp256k1.h 2017-06-27 14:05:26 +00:00
Tim Ruffing
b0452e664b Fix typo in API documentation 2017-06-05 19:17:53 +02: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
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
Andrew Poelstra
8e48aa60dc Add secp256k1_ec_pubkey_negate and secp256k1_ec_privkey_negate 2016-12-20 00:37:37 +00:00
Pieter Wuille
e06e878fd7 Remove Schnorr experiment 2016-11-17 18:55:06 -08:00
Andrew Poelstra
91219a1cc0 Remove guarantees about memcmp-ability 2016-08-26 18:03:48 +00:00