PRCYCoin  2.0.0.7rc1
P2P Digital Currency
Functions | Variables
main_impl.h File Reference
#include <stdio.h>
#include "field.h"
#include "group.h"
#include "hash.h"
#include "scalar.h"
Include dependency graph for main_impl.h:

Go to the source code of this file.

Functions

int secp256k1_generator_parse (const secp256k1_context2 *ctx, secp256k1_generator *gen, const unsigned char *input)
 Parse a 33-byte generator byte sequence into a generator object. More...
 
int secp256k1_generator_serialize (const secp256k1_context2 *ctx, unsigned char *output, const secp256k1_generator *gen)
 Serialize a 33-byte generator into a serialized byte sequence. More...
 
int secp256k1_generator_generate (const secp256k1_context2 *ctx, secp256k1_generator *gen, const unsigned char *key32)
 Generate a generator for the curve. More...
 
int secp256k1_generator_generate_blinded (const secp256k1_context2 *ctx, secp256k1_generator *gen, const unsigned char *key32, const unsigned char *blind32)
 Generate a blinded generator for the curve. More...
 

Variables

const secp256k1_generator secp256k1_generator_const_g
 Standard secp256k1 generator. More...
 
const secp256k1_generator secp256k1_generator_const_h
 Alternate secp256k1 generator, used in Elements Alpha. More...
 

Function Documentation

◆ secp256k1_generator_generate()

int secp256k1_generator_generate ( const secp256k1_context2 ctx,
secp256k1_generator gen,
const unsigned char *  seed32 
)

Generate a generator for the curve.

Returns: 0 in the highly unlikely case the seed is not acceptable, 1 otherwise. Args: ctx: a secp256k1 context object Out: gen: a generator object In: seed32: a 32-byte seed

If successful a valid generator will be placed in gen. The produced generators are distributed uniformly over the curve, and will not have a known discrete logarithm with respect to any other generator produced, or to the base generator G.

Definition at line 231 of file main_impl.h.

◆ secp256k1_generator_generate_blinded()

int secp256k1_generator_generate_blinded ( const secp256k1_context2 ctx,
secp256k1_generator gen,
const unsigned char *  key32,
const unsigned char *  blind32 
)

Generate a blinded generator for the curve.

Returns: 0 in the highly unlikely case the seed is not acceptable or when blind is out of range. 1 otherwise. Args: ctx: a secp256k1 context object, initialized for signing Out: gen: a generator object In: seed32: a 32-byte seed blind32: a 32-byte secret value to blind the generator with.

The result is equivalent to first calling secp256k1_generator_generate, converting the result to a public key, calling secp256k1_ec_pubkey_tweak_add2, and then converting back to generator form.

Definition at line 238 of file main_impl.h.

◆ secp256k1_generator_parse()

int secp256k1_generator_parse ( const secp256k1_context2 ctx,
secp256k1_generator commit,
const unsigned char *  input 
)

Parse a 33-byte generator byte sequence into a generator object.

Returns: 1 if input contains a valid generator. Args: ctx: a secp256k1 context object. Out: commit: pointer to the output generator object In: input: pointer to a 33-byte serialized generator

Definition at line 57 of file main_impl.h.

Here is the caller graph for this function:

◆ secp256k1_generator_serialize()

int secp256k1_generator_serialize ( const secp256k1_context2 ctx,
unsigned char *  output,
const secp256k1_generator commit 
)

Serialize a 33-byte generator into a serialized byte sequence.

Returns: 1 always. Args: ctx: a secp256k1 context object. Out: output: a pointer to a 33-byte byte array In: commit: a pointer to a generator

Definition at line 77 of file main_impl.h.

Variable Documentation

◆ secp256k1_generator_const_g

const secp256k1_generator secp256k1_generator_const_g
Initial value:
= {{
0x79, 0xbe, 0x66, 0x7e, 0xf9, 0xdc, 0xbb, 0xac, 0x55, 0xa0, 0x62, 0x95, 0xce, 0x87, 0x0b, 0x07,
0x02, 0x9b, 0xfc, 0xdb, 0x2d, 0xce, 0x28, 0xd9, 0x59, 0xf2, 0x81, 0x5b, 0x16, 0xf8, 0x17, 0x98,
0x48, 0x3a, 0xda, 0x77, 0x26, 0xa3, 0xc4, 0x65, 0x5d, 0xa4, 0xfb, 0xfc, 0x0e, 0x11, 0x08, 0xa8,
0xfd, 0x17, 0xb4, 0x48, 0xa6, 0x85, 0x54, 0x19, 0x9c, 0x47, 0xd0, 0x8f, 0xfb, 0x10, 0xd4, 0xb8
}}

Standard secp256k1 generator.

Standard secp256k1 generator G.

Definition at line 18 of file main_impl.h.

◆ secp256k1_generator_const_h

const secp256k1_generator secp256k1_generator_const_h
Initial value:
= {{
0x50, 0x92, 0x9b, 0x74, 0xc1, 0xa0, 0x49, 0x54, 0xb7, 0x8b, 0x4b, 0x60, 0x35, 0xe9, 0x7a, 0x5e,
0x07, 0x8a, 0x5a, 0x0f, 0x28, 0xec, 0x96, 0xd5, 0x47, 0xbf, 0xee, 0x9a, 0xce, 0x80, 0x3a, 0xc0,
0x31, 0xd3, 0xc6, 0x86, 0x39, 0x73, 0x92, 0x6e, 0x04, 0x9e, 0x63, 0x7c, 0xb1, 0xb5, 0xf4, 0x0a,
0x36, 0xda, 0xc2, 0x8a, 0xf1, 0x76, 0x69, 0x68, 0xc3, 0x0c, 0x23, 0x13, 0xf3, 0xa3, 0x89, 0x04
}}

Alternate secp256k1 generator, used in Elements Alpha.

Alternate secp256k1 generator from Elements Alpha.

Computed as the hash of the above G, DER-encoded with 0x04 (uncompressed pubkey) as its flag byte. import hashlib C = EllipticCurve ([F (0), F (7)]) G_bytes = '0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8'.decode('hex') H = C.lift_x(int(hashlib.sha256(G_bytes).hexdigest(),16))

Definition at line 32 of file main_impl.h.