PRCYCoin  2.0.0.7rc1
P2P Digital Currency
Classes | Functions
main_impl.h File Reference
#include <assert.h>
#include <string.h>
#include "modules/rangeproof/borromean.h"
#include "modules/surjection/surjection_impl.h"
#include "hash.h"
#include "include/secp256k1_rangeproof.h"
#include "include/secp256k1_surjectionproof.h"
Include dependency graph for main_impl.h:

Go to the source code of this file.

Classes

struct  secp256k1_surjectionproof_csprng
 

Functions

int secp256k1_surjectionproof_parse (const secp256k1_context2 *ctx, secp256k1_surjectionproof *proof, const unsigned char *input, size_t inputlen)
 Parse a surjection proof. More...
 
int secp256k1_surjectionproof_serialize (const secp256k1_context2 *ctx, unsigned char *output, size_t *outputlen, const secp256k1_surjectionproof *proof)
 Serialize a surjection proof. More...
 
size_t secp256k1_surjectionproof_n_total_inputs (const secp256k1_context2 *ctx, const secp256k1_surjectionproof *proof)
 Returns the total number of inputs a proof expects to be over. More...
 
size_t secp256k1_surjectionproof_n_used_inputs (const secp256k1_context2 *ctx, const secp256k1_surjectionproof *proof)
 Returns the actual number of inputs that a proof uses. More...
 
size_t secp256k1_surjectionproof_serialized_size (const secp256k1_context2 *ctx, const secp256k1_surjectionproof *proof)
 Returns the total size this proof would take, in bytes, when serialized. More...
 
int secp256k1_surjectionproof_initialize (const secp256k1_context2 *ctx, secp256k1_surjectionproof *proof, size_t *input_index, const secp256k1_fixed_asset_tag *fixed_input_tags, const size_t n_input_tags, const size_t n_input_tags_to_use, const secp256k1_fixed_asset_tag *fixed_output_tag, const size_t n_max_iterations, const unsigned char *random_seed32)
 Surjection proof initialization function; decides on inputs to use Returns 0: inputs could not be selected n: inputs were selected after n iterations of random selection. More...
 
int secp256k1_surjectionproof_generate (const secp256k1_context2 *ctx, secp256k1_surjectionproof *proof, const secp256k1_generator *ephemeral_input_tags, size_t n_ephemeral_input_tags, const secp256k1_generator *ephemeral_output_tag, size_t input_index, const unsigned char *input_blinding_key, const unsigned char *output_blinding_key)
 Surjection proof generation function Returns 0: proof could not be created 1: proof was successfully created. More...
 
int secp256k1_surjectionproof_verify (const secp256k1_context2 *ctx, const secp256k1_surjectionproof *proof, const secp256k1_generator *ephemeral_input_tags, size_t n_ephemeral_input_tags, const secp256k1_generator *ephemeral_output_tag)
 Surjection proof verification function Returns 0: proof was invalid 1: proof was valid. More...
 

Function Documentation

◆ secp256k1_surjectionproof_generate()

int secp256k1_surjectionproof_generate ( const secp256k1_context2 ctx,
secp256k1_surjectionproof proof,
const secp256k1_generator ephemeral_input_tags,
size_t  n_ephemeral_input_tags,
const secp256k1_generator ephemeral_output_tag,
size_t  input_index,
const unsigned char *  input_blinding_key,
const unsigned char *  output_blinding_key 
)

Surjection proof generation function Returns 0: proof could not be created 1: proof was successfully created.

In: ctx: pointer to a context object, initialized for signing and verification ephemeral_input_tags: the ephemeral asset tag of all inputs n_ephemeral_input_tags: the number of entries in the ephemeral_input_tags array ephemeral_output_tag: the ephemeral asset tag of the output input_index: the index of the input that actually maps to the output input_blinding_key: the blinding key of the input output_blinding_key: the blinding key of the output In/Out: proof: The produced surjection proof. Must have already gone through secp256k1_surjectionproof_initialize

Definition at line 211 of file main_impl.h.

◆ secp256k1_surjectionproof_initialize()

int secp256k1_surjectionproof_initialize ( const secp256k1_context2 ctx,
secp256k1_surjectionproof proof,
size_t *  input_index,
const secp256k1_fixed_asset_tag fixed_input_tags,
const size_t  n_input_tags,
const size_t  n_input_tags_to_use,
const secp256k1_fixed_asset_tag fixed_output_tag,
const size_t  n_max_iterations,
const unsigned char *  random_seed32 
)

Surjection proof initialization function; decides on inputs to use Returns 0: inputs could not be selected n: inputs were selected after n iterations of random selection.

In: ctx: pointer to a context object fixed_input_tags: fixed input tags A_i for all inputs. (If the fixed tag is not known, e.g. in a coinjoin with others' inputs, an ephemeral tag can be given; this won't match the output tag but might be used in the anonymity set.) n_input_tags: the number of entries in the fixed_input_tags array n_input_tags_to_use: the number of inputs to select randomly to put in the anonymity set fixed_output_tag: fixed output tag max_n_iterations: the maximum number of iterations to do before giving up. Because the maximum number of inputs (SECP256K1_SURJECTIONPROOF_MAX_N_INPUTS) is limited to 256 the probability of giving up is smaller than (255/256)^(n_input_tags_to_use*max_n_iterations).

random_seed32: a random seed to be used for input selection Out: proof: The proof whose bitvector will be initialized. In case of failure, the state of the proof is undefined. input_index: The index of the actual input that is secretly mapped to the output

Definition at line 154 of file main_impl.h.

◆ secp256k1_surjectionproof_n_total_inputs()

size_t secp256k1_surjectionproof_n_total_inputs ( const secp256k1_context2 ctx,
const secp256k1_surjectionproof proof 
)

Returns the total number of inputs a proof expects to be over.

Returns: the number of inputs for the given proof In: ctx: pointer to a context object proof: a pointer to a proof object

Definition at line 94 of file main_impl.h.

◆ secp256k1_surjectionproof_n_used_inputs()

size_t secp256k1_surjectionproof_n_used_inputs ( const secp256k1_context2 ctx,
const secp256k1_surjectionproof proof 
)

Returns the actual number of inputs that a proof uses.

Returns: the number of inputs for the given proof In: ctx: pointer to a context object proof: a pointer to a proof object

Definition at line 101 of file main_impl.h.

◆ secp256k1_surjectionproof_parse()

int secp256k1_surjectionproof_parse ( const secp256k1_context2 ctx,
secp256k1_surjectionproof proof,
const unsigned char *  input,
size_t  inputlen 
)

Parse a surjection proof.

Returns: 1 when the proof could be parsed, 0 otherwise. Args: ctx: a secp256k1 context object Out: proof: a pointer to a proof object In: input: a pointer to the array to parse inputlen: length of the array pointed to by input

The proof must consist of:

  • A 2-byte little-endian total input count n
  • A ceil(n/8)-byte bitmap indicating which inputs are used.
  • A big-endian 32-byte borromean signature e0 value
  • m big-endian 32-byte borromean signature s values, where m is the number of set bits in the bitmap

Definition at line 38 of file main_impl.h.

Here is the caller graph for this function:

◆ secp256k1_surjectionproof_serialize()

int secp256k1_surjectionproof_serialize ( const secp256k1_context2 ctx,
unsigned char *  output,
size_t *  outputlen,
const secp256k1_surjectionproof proof 
)

Serialize a surjection proof.

Returns: 1 if enough space was available to serialize, 0 otherwise Args: ctx: a secp256k1 context object Out: output: a pointer to an array to store the serialization In/Out: outputlen: a pointer to an integer which is initially set to the size of output, and is overwritten with the written size. In: proof: a pointer to an initialized proof object

See secp256k1_surjectionproof_parse for details about the encoding.

Definition at line 69 of file main_impl.h.

Here is the caller graph for this function:

◆ secp256k1_surjectionproof_serialized_size()

size_t secp256k1_surjectionproof_serialized_size ( const secp256k1_context2 ctx,
const secp256k1_surjectionproof proof 
)

Returns the total size this proof would take, in bytes, when serialized.

Returns: the total size In: ctx: pointer to a context object proof: a pointer to a proof object

Definition at line 108 of file main_impl.h.

◆ secp256k1_surjectionproof_verify()

int secp256k1_surjectionproof_verify ( const secp256k1_context2 ctx,
const secp256k1_surjectionproof proof,
const secp256k1_generator ephemeral_input_tags,
size_t  n_ephemeral_input_tags,
const secp256k1_generator ephemeral_output_tag 
)

Surjection proof verification function Returns 0: proof was invalid 1: proof was valid.

In: ctx: pointer to a context object, initialized for signing and verification proof: proof to be verified ephemeral_input_tags: the ephemeral asset tag of all inputs n_ephemeral_input_tags: the number of entries in the ephemeral_input_tags array ephemeral_output_tag: the ephemeral asset tag of the output

Definition at line 292 of file main_impl.h.