PRCYCoin  2.0.0.7rc1
P2P Digital Currency
secp256k1_bulletproofs.h
Go to the documentation of this file.
1 #ifndef _SECP256K1_BULLETPROOF_
2 # define _SECP256K1_BULLETPROOF_
3 
4 # include "secp256k1_2.h"
5 # include "secp256k1_generator.h"
6 # include "secp256k1_rangeproof.h"
7 
8 # ifdef __cplusplus
9 extern "C" {
10 # endif
11 
14 
17 
20 
22 #define SECP256K1_BULLETPROOF_CIRCUIT_VERSION 1
23 
24 /* Maximum depth of 31 lets us validate an aggregate of 2^25 64-bit proofs */
25 #define SECP256K1_BULLETPROOF_MAX_DEPTH 31
26 
27 /* Maximum size of a circuit that may be parsed */
28 #define SECP256K1_BULLETPROOF_MAX_CIRCUIT (1024*1024*25)
29 
30 /* Size of a hypothetical 31-depth rangeproof, in bytes */
31 #define SECP256K1_BULLETPROOF_MAX_PROOF (160 + 36*32 + 7)
32 
40  const secp256k1_context2* ctx,
41  const secp256k1_generator *blinding_gen,
42  size_t n
44 
46 
52  const secp256k1_context2* ctx,
55 
73  const secp256k1_context2* ctx,
74  secp256k1_scratch_space2* scratch,
76  const unsigned char* proof,
77  size_t plen,
78  const uint64_t* min_value,
79  const secp256k1_pedersen_commitment* commit,
80  size_t n_commits,
81  size_t nbits,
82  const secp256k1_generator* value_gen,
83  const unsigned char* extra_commit,
84  size_t extra_commit_len
86 
105  const secp256k1_context2* ctx,
106  secp256k1_scratch_space2* scratch,
108  const unsigned char* const* proof,
109  size_t n_proofs,
110  size_t plen,
111  const uint64_t* const* min_value,
112  const secp256k1_pedersen_commitment* const* commit,
113  size_t n_commits,
114  size_t nbits,
115  const secp256k1_generator* value_gen,
116  const unsigned char* const* extra_commit,
117  size_t *extra_commit_len
119 
137  const secp256k1_context2* ctx,
139  uint64_t* value,
140  unsigned char* blind,
141  const unsigned char* proof,
142  size_t plen,
143  uint64_t min_value,
144  const secp256k1_pedersen_commitment* commit,
145  const secp256k1_generator* value_gen,
146  const unsigned char* nonce,
147  const unsigned char* extra_commit,
148  size_t extra_commit_len
150 
170  const secp256k1_context2* ctx,
171  secp256k1_scratch_space2* scratch,
173  unsigned char* proof,
174  size_t* plen,
175  const uint64_t *value,
176  const uint64_t *min_value,
177  const unsigned char* const* blind,
178  size_t n_commits,
179  const secp256k1_generator* value_gen,
180  size_t nbits,
181  const unsigned char* nonce,
182  const unsigned char* extra_commit,
183  size_t extra_commit_len
185 
186 
187 /* General ZKP functionality */
188 
195  const secp256k1_context2 *ctx,
196  const char *description
198 
205 
211  const secp256k1_context2 *ctx,
214 
221  const secp256k1_context2 *ctx,
222  const char *fname
224 
230  const secp256k1_context2 *ctx,
233 
250  const secp256k1_context2* ctx,
251  secp256k1_scratch_space2* scratch,
253  const secp256k1_bulletproof_circuit* circ,
254  const unsigned char* proof,
255  size_t plen,
256  const secp256k1_pedersen_commitment* commit,
257  size_t n_commits,
258  const secp256k1_generator* value_gen,
259  const unsigned char* extra_commit,
260  size_t extra_commit_len
262 
280  const secp256k1_context2* ctx,
281  secp256k1_scratch_space2* scratch,
283  const secp256k1_bulletproof_circuit* const* circ,
284  const unsigned char* const* proof,
285  size_t n_proofs,
286  size_t plen,
287  const secp256k1_pedersen_commitment** commit,
288  size_t *n_commits,
289  const secp256k1_generator* value_gen,
290  const unsigned char** extra_commit,
291  size_t *extra_commit_len
293 
312  const secp256k1_context2* ctx,
313  secp256k1_scratch_space2* scratch,
315  const secp256k1_bulletproof_circuit* circ,
316  unsigned char* proof,
317  size_t* plen,
319  const unsigned char** blind,
320  size_t n_commits,
321  const unsigned char* nonce,
322  const secp256k1_generator* value_gen,
323  const unsigned char* extra_commit,
324  size_t extra_commit_len
326 
327 # ifdef __cplusplus
328 }
329 # endif
330 
331 #endif
secp256k1_scratch_space_struct2
Definition: scratch.h:14
secp256k1_bulletproof_rangeproof_rewind
SECP256K1_WARN_UNUSED_RESULT SECP256K1_API int secp256k1_bulletproof_rangeproof_rewind(const secp256k1_context2 *ctx, const secp256k1_bulletproof_generators *gens, uint64_t *value, unsigned char *blind, const unsigned char *proof, size_t plen, uint64_t min_value, const secp256k1_pedersen_commitment *commit, const secp256k1_generator *value_gen, const unsigned char *nonce, const unsigned char *extra_commit, size_t extra_commit_len) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5) SECP256K1_ARG_NONNULL(8) SECP256K1_ARG_NONNULL(9)
Extracts the value and blinding factor from a single-commit rangeproof given a secret nonce Returns: ...
Definition: main_impl.h:561
secp256k1_bulletproof_generators_create
SECP256K1_API secp256k1_bulletproof_generators * secp256k1_bulletproof_generators_create(const secp256k1_context2 *ctx, const secp256k1_generator *blinding_gen, size_t n) SECP256K1_ARG_NONNULL(1)
Allocates and initializes a list of NUMS generators, along with precomputation data Returns a list of...
Definition: main_impl.h:427
SECP256K1_API
#define SECP256K1_API
Definition: secp256k1_2.h:139
secp256k1_generator
Opaque data structure that stores a base point.
Definition: secp256k1_generator.h:20
secp256k1_bulletproof_rangeproof_verify_multi
SECP256K1_WARN_UNUSED_RESULT SECP256K1_API int secp256k1_bulletproof_rangeproof_verify_multi(const secp256k1_context2 *ctx, secp256k1_scratch_space2 *scratch, const secp256k1_bulletproof_generators *gens, const unsigned char *const *proof, size_t n_proofs, size_t plen, const uint64_t *const *min_value, const secp256k1_pedersen_commitment *const *commit, size_t n_commits, size_t nbits, const secp256k1_generator *value_gen, const unsigned char *const *extra_commit, size_t *extra_commit_len) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(8)
Batch-verifies multiple bulletproof (aggregate) rangeproofs of the same size using same generator Ret...
Definition: main_impl.h:516
secp256k1_bulletproof_rangeproof_prove
SECP256K1_WARN_UNUSED_RESULT SECP256K1_API int secp256k1_bulletproof_rangeproof_prove(const secp256k1_context2 *ctx, secp256k1_scratch_space2 *scratch, const secp256k1_bulletproof_generators *gens, unsigned char *proof, size_t *plen, const uint64_t *value, const uint64_t *min_value, const unsigned char *const *blind, size_t n_commits, const secp256k1_generator *value_gen, size_t nbits, const unsigned char *nonce, const unsigned char *extra_commit, size_t extra_commit_len) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5) SECP256K1_ARG_NONNULL(6) SECP256K1_ARG_NONNULL(8) SECP256K1_ARG_NONNULL(10) SECP256K1_ARG_NONNULL(12)
Produces an aggregate Bulletproof rangeproof for a set of Pedersen commitments Returns: 1: rangeproof...
Definition: main_impl.h:582
secp256k1_bulletproof_generators_create_with_pregenerated
SECP256K1_API secp256k1_bulletproof_generators * secp256k1_bulletproof_generators_create_with_pregenerated(const secp256k1_context2 *ctx) SECP256K1_ARG_NONNULL(1)
Definition: main_impl.h:72
secp256k1_bulletproof_rangeproof_verify
SECP256K1_WARN_UNUSED_RESULT SECP256K1_API int secp256k1_bulletproof_rangeproof_verify(const secp256k1_context2 *ctx, secp256k1_scratch_space2 *scratch, const secp256k1_bulletproof_generators *gens, const unsigned char *proof, size_t plen, const uint64_t *min_value, const secp256k1_pedersen_commitment *commit, size_t n_commits, size_t nbits, const secp256k1_generator *value_gen, const unsigned char *extra_commit, size_t extra_commit_len) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(7) SECP256K1_ARG_NONNULL(10)
Verifies a single bulletproof (aggregate) rangeproof Returns: 1: rangeproof was valid 0: rangeproof w...
Definition: main_impl.h:477
secp256k1_rangeproof.h
secp256k1_bulletproof_circuit_verify
SECP256K1_API int secp256k1_bulletproof_circuit_verify(const secp256k1_context2 *ctx, secp256k1_scratch_space2 *scratch, const secp256k1_bulletproof_generators *gens, const secp256k1_bulletproof_circuit *circ, const unsigned char *proof, size_t plen, const secp256k1_pedersen_commitment *commit, size_t n_commits, const secp256k1_generator *value_gen, const unsigned char *extra_commit, size_t extra_commit_len) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5) SECP256K1_ARG_NONNULL(9)
Verifies a single bulletproof zero-knowledge proof (zkp) Returns: 1: zkp accepted 0: zkp did not acce...
Definition: main_impl.h:705
secp256k1_bulletproof_circuit_assignment_decode
SECP256K1_API secp256k1_bulletproof_circuit_assignment * secp256k1_bulletproof_circuit_assignment_decode(const secp256k1_context2 *ctx, const char *fname) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
Decodes an accepting wire assignment which is serialized in an opaque binary format Returns a circuit...
Definition: main_impl.h:877
SECP256K1_WARN_UNUSED_RESULT
#define SECP256K1_WARN_UNUSED_RESULT
Warning attributes NONNULL is not used if SECP256K1_BUILD is set to avoid the compiler optimizing out...
Definition: secp256k1.h:35
secp256k1_bulletproof_circuit_destroy
SECP256K1_API void secp256k1_bulletproof_circuit_destroy(const secp256k1_context2 *ctx, secp256k1_bulletproof_circuit *circ) SECP256K1_ARG_NONNULL(1)
Destroys a circuit Args: ctx: pointer to a context object (cannot be NULL) gen: pointer to the circui...
Definition: main_impl.h:964
secp256k1_bulletproof_circuit_assignment
Definition: main_impl.h:45
secp256k1_context_struct2
Definition: secp256k1_types.h:15
secp256k1_bulletproof_generators_destroy
SECP256K1_API void secp256k1_bulletproof_generators_destroy(const secp256k1_context2 *ctx, secp256k1_bulletproof_generators *gen) SECP256K1_ARG_NONNULL(1)
Destroys a list of NUMS generators, freeing allocated memory Args: ctx: pointer to a context object (...
Definition: main_impl.h:469
secp256k1_pedersen_commitment
Opaque data structure that stores a Pedersen commitment.
Definition: secp256k1_commitment.h:22
secp256k1_bulletproof_circuit_assignment_destroy
SECP256K1_API void secp256k1_bulletproof_circuit_assignment_destroy(const secp256k1_context2 *ctx, secp256k1_bulletproof_circuit_assignment *assn) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
Destroys a circuit assignment Args: ctx: pointer to a context object (cannot be NULL) gen: pointer to...
Definition: main_impl.h:974
secp256k1_bulletproof_circuit_assignment::n_commits
size_t n_commits
Definition: main_impl.h:47
secp256k1_generator.h
secp256k1_2.h
SECP256K1_ARG_NONNULL
#define SECP256K1_ARG_NONNULL(_x)
Definition: secp256k1.h:40
secp256k1_bulletproof_circuit
Definition: main_impl.h:31
secp256k1_bulletproof_circuit_verify_multi
SECP256K1_API int secp256k1_bulletproof_circuit_verify_multi(const secp256k1_context2 *ctx, secp256k1_scratch_space2 *scratch, const secp256k1_bulletproof_generators *gens, const secp256k1_bulletproof_circuit *const *circ, const unsigned char *const *proof, size_t n_proofs, size_t plen, const secp256k1_pedersen_commitment **commit, size_t *n_commits, const secp256k1_generator *value_gen, const unsigned char **extra_commit, size_t *extra_commit_len) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5) SECP256K1_ARG_NONNULL(10)
Batch-verifies multiple bulletproof zero-knowledge proofs of equally-sized circuits (zkp) Returns: 1:...
Definition: main_impl.h:750
secp256k1_bulletproof_circuit_parse
SECP256K1_API secp256k1_bulletproof_circuit * secp256k1_bulletproof_circuit_parse(const secp256k1_context2 *ctx, const char *description) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2)
Parses a circuit from an ad-hoc text string format Returns a circuit, or NULL on failure Args: ctx: p...
Definition: main_impl.h:633
secp256k1_bulletproof_circuit_decode
secp256k1_bulletproof_circuit * secp256k1_bulletproof_circuit_decode(const secp256k1_context2 *ctx, const char *fname)
Decodes a circuit which is serialized in an opaque binary format Returns a circuit,...
Definition: main_impl.h:813
secp256k1_bulletproof_circuit_prove
SECP256K1_API int secp256k1_bulletproof_circuit_prove(const secp256k1_context2 *ctx, secp256k1_scratch_space2 *scratch, const secp256k1_bulletproof_generators *gens, const secp256k1_bulletproof_circuit *circ, unsigned char *proof, size_t *plen, const secp256k1_bulletproof_circuit_assignment *assn, const unsigned char **blind, size_t n_commits, const unsigned char *nonce, const secp256k1_generator *value_gen, const unsigned char *extra_commit, size_t extra_commit_len) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(5) SECP256K1_ARG_NONNULL(6) SECP256K1_ARG_NONNULL(7) SECP256K1_ARG_NONNULL(10) SECP256K1_ARG_NONNULL(11)
Produces a bulletproof zero-knowledge proof (zkp) Returns: 1: proof was successfully created 0: pro...
Definition: main_impl.h:639
secp256k1_bulletproof_generators
Definition: main_impl.h:54