Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java/JNI: Add native bindings for Schnorr signatures #47

Closed
wants to merge 60 commits into from

Conversation

guggero
Copy link

@guggero guggero commented Feb 22, 2019

I added the native bindings for secp256k1_schnorrsig_sign and secp256k1_schnorrsig_verify and also wrote a test for them in Java.

gmaxwell and others added 30 commits December 14, 2018 20:25
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.
… cleanup

Switch to secp256k1_pedersen_commitment by Andrew Poelstra.
Switch to quadratic residue based disambiguation by Pieter Wuille.
* add summing function for blinded generators
* drop `excess` and `gen` from `verify_tally`
* add extra_commit to rangeproof sign and verify
Includes fix and tests by Jonas Nick.
Include test_impl.h
jonasnick and others added 23 commits December 14, 2018 20:25
…ace is given and just multiplies and adds the points.
Enable more builds with rest of experimental flags
use proper types for rangeproof min/max in unit test case
Use monospaced font for math expressions
@jonasnick
Copy link
Contributor

jonasnick commented Feb 22, 2019

I don't know anything about the java bindings in this library but this is nice. We should just be aware that the schnorrsig API isn't all that stable at the moment. In particular the sign-to-contract PRs may change it . See PR bitcoin-core/secp256k1#589 and the difference in the schnorrsig_sign arguments bitcoin-core/secp256k1@16a7592#diff-b19c5ee427283d4d82bc5beb4e2f4777R75

@guggero
Copy link
Author

guggero commented Feb 23, 2019

Ok, thanks for the warning.
I will gladly rebase and change the code once the mentioned PR is merged.
Or do you think it would make more sense to wait for the Schnorrsig-PR to be merged to the upstream repository and then open my PR there directly?

@jonasnick
Copy link
Contributor

Not sure what's better but it can take a while until schnorrsig-PR is merged upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants