PRCYCoin  2.0.0.7rc1
P2P Digital Currency
Classes | Macros | Functions
tests.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "secp256k1_2.c"
#include "include/secp256k1_2.h"
#include "testrand_impl.h"
#include "contrib/lax_der_parsing.c"
#include "contrib/lax_der_privatekey_parsing.c"
#include "modules/bulletproofs/tests_impl.h"
Include dependency graph for tests.c:

Go to the source code of this file.

Classes

struct  ecmult_multi_data
 

Macros

#define VG_UNDEF(x, y)
 
#define VG_CHECK(x, y)
 
#define SECP256K1_EC_PARSE_TEST_NVALID   (12)
 
#define SECP256K1_EC_PARSE_TEST_NXVALID   (4)
 
#define SECP256K1_EC_PARSE_TEST_NINVALID   (7)
 
#define ENABLE_MODULE_BULLETPROOF   1
 

Functions

void random_field_element_test (secp256k1_fe *fe)
 
void random_field_element_magnitude (secp256k1_fe *fe)
 
void random_group_element_test (secp256k1_ge *ge)
 
void random_group_element_jacobian_test (secp256k1_gej *gej, const secp256k1_ge *ge)
 
void random_scalar_order_test (secp256k1_scalar *num)
 
void random_scalar_order (secp256k1_scalar *num)
 
void run_util_tests (void)
 
void run_context_tests (void)
 
void run_scratch_tests (void)
 
void run_sha256_tests (void)
 
void run_hmac_sha256_tests (void)
 
void run_rfc6979_hmac_sha256_tests (void)
 
void test_rand_bits (int rand32, int bits)
 
void test_rand_int (uint32_t range, uint32_t subrange)
 
void run_rand_bits (void)
 
void run_rand_int (void)
 
void random_num_negate (secp256k1_num *num)
 
void random_num_order_test (secp256k1_num *num)
 
void random_num_order (secp256k1_num *num)
 
void test_num_negate (void)
 
void test_num_add_sub (void)
 
void test_num_mod (void)
 
void test_num_jacobi (void)
 
void run_num_smalltests (void)
 
void scalar_test (void)
 
void scalar_chacha_tests (void)
 
void run_scalar_tests (void)
 
void random_fe (secp256k1_fe *x)
 
void random_fe_test (secp256k1_fe *x)
 
void random_fe_non_zero (secp256k1_fe *nz)
 
void random_fe_non_square (secp256k1_fe *ns)
 
int check_fe_equal (const secp256k1_fe *a, const secp256k1_fe *b)
 
int check_fe_inverse (const secp256k1_fe *a, const secp256k1_fe *ai)
 
void run_field_convert (void)
 
int fe_memcmp (const secp256k1_fe *a, const secp256k1_fe *b)
 
void run_field_misc (void)
 
void run_field_inv (void)
 
void run_field_inv_var (void)
 
void run_field_inv_all_var (void)
 
void run_sqr (void)
 
void test_sqrt (const secp256k1_fe *a, const secp256k1_fe *k)
 
void run_sqrt (void)
 
void ge_equals_ge (const secp256k1_ge *a, const secp256k1_ge *b)
 
int gej_xyz_equals_gej (const secp256k1_gej *a, const secp256k1_gej *b)
 
void ge_equals_gej (const secp256k1_ge *a, const secp256k1_gej *b)
 
void test_ge (void)
 
void test_add_neg_y_diff_x (void)
 
void run_ge (void)
 
void test_ec_combine (void)
 
void run_ec_combine (void)
 
void test_group_decompress (const secp256k1_fe *x)
 
void run_group_decompress (void)
 
void run_ecmult_chain (void)
 
void test_point_times_order (const secp256k1_gej *point)
 
void run_point_times_order (void)
 
void ecmult_const_random_mult (void)
 
void ecmult_const_commutativity (void)
 
void ecmult_const_mult_zero_one (void)
 
void ecmult_const_chain_multiply (void)
 
void run_ecmult_const_tests (void)
 
void test_ecmult_multi (secp256k1_scratch *scratch, secp256k1_ecmult_multi_func ecmult_multi)
 
void test_secp256k1_pippenger_bucket_window_inv (void)
 
void test_ecmult_multi_pippenger_max_points (void)
 Probabilistically test the function returning the maximum number of possible points for a given scratch space. More...
 
void test_ecmult_multi_batching (void)
 Run secp256k1_ecmult_multi_var with num points and a scratch space restricted to 1 <= i <= num points. More...
 
void run_ecmult_multi_tests (void)
 
void test_wnaf (const secp256k1_scalar *number, int w)
 
void test_constant_wnaf_negate (const secp256k1_scalar *number)
 
void test_constant_wnaf (const secp256k1_scalar *number, int w)
 
void test_fixed_wnaf (const secp256k1_scalar *number, int w)
 
void test_fixed_wnaf_small_helper (int *wnaf, int *wnaf_expected, int w)
 
void test_fixed_wnaf_small (void)
 
void run_wnaf (void)
 
void test_ecmult_constants (void)
 
void run_ecmult_constants (void)
 
void test_ecmult_gen_blind (void)
 
void test_ecmult_gen_blind_reset (void)
 
void run_ecmult_gen_blind (void)
 
void ec_pubkey_parse_pointtest (const unsigned char *input, int xvalid, int yvalid)
 
void run_ec_pubkey_parse_test (void)
 
void run_eckey_edge_case_test (void)
 
void random_sign (secp256k1_scalar *sigr, secp256k1_scalar *sigs, const secp256k1_scalar *key, const secp256k1_scalar *msg, int *recid)
 
void test_ecdsa_sign_verify (void)
 
void run_ecdsa_sign_verify (void)
 
int is_empty_signature (const secp256k1_ecdsa_sign2ature2 *sig)
 
void test_ecdsa_end_to_end (void)
 
void test_random_pubkeys (void)
 
void run_random_pubkeys (void)
 
void run_ecdsa_end_to_end (void)
 
int test_ecdsa_der_parse (const unsigned char *sig, size_t siglen, int certainly_der, int certainly_not_der)
 
void run_ecdsa_der_parse (void)
 
void test_ecdsa_edge_cases (void)
 
void run_ecdsa_edge_cases (void)
 
int main (int argc, char **argv)
 

Macro Definition Documentation

◆ ENABLE_MODULE_BULLETPROOF

#define ENABLE_MODULE_BULLETPROOF   1

Definition at line 5047 of file tests.c.

◆ SECP256K1_EC_PARSE_TEST_NINVALID

#define SECP256K1_EC_PARSE_TEST_NINVALID   (7)

◆ SECP256K1_EC_PARSE_TEST_NVALID

#define SECP256K1_EC_PARSE_TEST_NVALID   (12)

◆ SECP256K1_EC_PARSE_TEST_NXVALID

#define SECP256K1_EC_PARSE_TEST_NXVALID   (4)

◆ VG_CHECK

#define VG_CHECK (   x,
 
)

Definition at line 41 of file tests.c.

◆ VG_UNDEF

#define VG_UNDEF (   x,
 
)

Definition at line 40 of file tests.c.

Function Documentation

◆ check_fe_equal()

int check_fe_equal ( const secp256k1_fe a,
const secp256k1_fe b 
)

Definition at line 1739 of file tests.c.

◆ check_fe_inverse()

int check_fe_inverse ( const secp256k1_fe a,
const secp256k1_fe ai 
)

Definition at line 1747 of file tests.c.

◆ ec_pubkey_parse_pointtest()

void ec_pubkey_parse_pointtest ( const unsigned char *  input,
int  xvalid,
int  yvalid 
)

Definition at line 3355 of file tests.c.

Here is the call graph for this function:

◆ ecmult_const_chain_multiply()

void ecmult_const_chain_multiply ( void  )

Definition at line 2602 of file tests.c.

Here is the caller graph for this function:

◆ ecmult_const_commutativity()

void ecmult_const_commutativity ( void  )

Definition at line 2559 of file tests.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ecmult_const_mult_zero_one()

void ecmult_const_mult_zero_one ( void  )

Definition at line 2580 of file tests.c.

Here is the caller graph for this function:

◆ ecmult_const_random_mult()

void ecmult_const_random_mult ( void  )

Definition at line 2532 of file tests.c.

Here is the caller graph for this function:

◆ fe_memcmp()

int fe_memcmp ( const secp256k1_fe a,
const secp256k1_fe b 
)

Definition at line 1784 of file tests.c.

◆ ge_equals_ge()

void ge_equals_ge ( const secp256k1_ge a,
const secp256k1_ge b 
)

Definition at line 1977 of file tests.c.

◆ ge_equals_gej()

void ge_equals_gej ( const secp256k1_ge a,
const secp256k1_gej b 
)

Definition at line 2008 of file tests.c.

◆ gej_xyz_equals_gej()

int gej_xyz_equals_gej ( const secp256k1_gej a,
const secp256k1_gej b 
)

Definition at line 1987 of file tests.c.

◆ is_empty_signature()

int is_empty_signature ( const secp256k1_ecdsa_sign2ature2 sig)

Definition at line 4077 of file tests.c.

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 5081 of file tests.c.

◆ random_fe()

void random_fe ( secp256k1_fe x)

Definition at line 1698 of file tests.c.

◆ random_fe_non_square()

void random_fe_non_square ( secp256k1_fe ns)

Definition at line 1731 of file tests.c.

Here is the call graph for this function:

◆ random_fe_non_zero()

void random_fe_non_zero ( secp256k1_fe nz)

Definition at line 1718 of file tests.c.

Here is the call graph for this function:

◆ random_fe_test()

void random_fe_test ( secp256k1_fe x)

Definition at line 1708 of file tests.c.

◆ random_field_element_magnitude()

void random_field_element_magnitude ( secp256k1_fe fe)

Definition at line 74 of file tests.c.

◆ random_field_element_test()

void random_field_element_test ( secp256k1_fe fe)

Definition at line 64 of file tests.c.

◆ random_group_element_jacobian_test()

void random_group_element_jacobian_test ( secp256k1_gej gej,
const secp256k1_ge ge 
)

Definition at line 99 of file tests.c.

Here is the call graph for this function:

◆ random_group_element_test()

void random_group_element_test ( secp256k1_ge ge)

Definition at line 88 of file tests.c.

Here is the call graph for this function:

◆ random_num_negate()

void random_num_negate ( secp256k1_num num)

Definition at line 536 of file tests.c.

◆ random_num_order()

void random_num_order ( secp256k1_num num)

Definition at line 548 of file tests.c.

Here is the call graph for this function:

◆ random_num_order_test()

void random_num_order_test ( secp256k1_num num)

Definition at line 542 of file tests.c.

Here is the call graph for this function:

◆ random_scalar_order()

void random_scalar_order ( secp256k1_scalar num)

Definition at line 127 of file tests.c.

◆ random_scalar_order_test()

void random_scalar_order_test ( secp256k1_scalar num)

Definition at line 114 of file tests.c.

◆ random_sign()

void random_sign ( secp256k1_scalar sigr,
secp256k1_scalar sigs,
const secp256k1_scalar key,
const secp256k1_scalar msg,
int *  recid 
)

Definition at line 3993 of file tests.c.

Here is the call graph for this function:

◆ run_context_tests()

void run_context_tests ( void  )

Definition at line 186 of file tests.c.

Here is the call graph for this function:

◆ run_ec_combine()

void run_ec_combine ( void  )

Definition at line 2329 of file tests.c.

◆ run_ec_pubkey_parse_test()

void run_ec_pubkey_parse_test ( void  )

Definition at line 3430 of file tests.c.

Here is the call graph for this function:

◆ run_ecdsa_der_parse()

void run_ecdsa_der_parse ( void  )

Definition at line 4586 of file tests.c.

◆ run_ecdsa_edge_cases()

void run_ecdsa_edge_cases ( void  )

Definition at line 4987 of file tests.c.

Here is the call graph for this function:

◆ run_ecdsa_end_to_end()

void run_ecdsa_end_to_end ( void  )

Definition at line 4280 of file tests.c.

◆ run_ecdsa_sign_verify()

void run_ecdsa_sign_verify ( void  )

Definition at line 4023 of file tests.c.

◆ run_eckey_edge_case_test()

void run_eckey_edge_case_test ( void  )

Definition at line 3757 of file tests.c.

Here is the call graph for this function:

◆ run_ecmult_chain()

void run_ecmult_chain ( void  )

Definition at line 2411 of file tests.c.

◆ run_ecmult_const_tests()

void run_ecmult_const_tests ( void  )

Definition at line 2628 of file tests.c.

Here is the call graph for this function:

◆ run_ecmult_constants()

void run_ecmult_constants ( void  )

Definition at line 3278 of file tests.c.

Here is the call graph for this function:

◆ run_ecmult_gen_blind()

void run_ecmult_gen_blind ( void  )

Definition at line 3317 of file tests.c.

Here is the call graph for this function:

◆ run_ecmult_multi_tests()

void run_ecmult_multi_tests ( void  )

Definition at line 3005 of file tests.c.

Here is the call graph for this function:

◆ run_field_convert()

void run_field_convert ( void  )

Definition at line 1754 of file tests.c.

◆ run_field_inv()

void run_field_inv ( void  )

Definition at line 1865 of file tests.c.

◆ run_field_inv_all_var()

void run_field_inv_all_var ( void  )

Definition at line 1889 of file tests.c.

◆ run_field_inv_var()

void run_field_inv_var ( void  )

Definition at line 1877 of file tests.c.

◆ run_field_misc()

void run_field_misc ( void  )

Definition at line 1793 of file tests.c.

◆ run_ge()

void run_ge ( void  )

Definition at line 2296 of file tests.c.

◆ run_group_decompress()

void run_group_decompress ( void  )

Definition at line 2400 of file tests.c.

◆ run_hmac_sha256_tests()

void run_hmac_sha256_tests ( void  )

Definition at line 376 of file tests.c.

◆ run_num_smalltests()

void run_num_smalltests ( void  )

Definition at line 708 of file tests.c.

◆ run_point_times_order()

void run_point_times_order ( void  )

Definition at line 2510 of file tests.c.

◆ run_rand_bits()

void run_rand_bits ( void  )

Definition at line 514 of file tests.c.

Here is the call graph for this function:

◆ run_rand_int()

void run_rand_int ( void  )

Definition at line 522 of file tests.c.

Here is the call graph for this function:

◆ run_random_pubkeys()

void run_random_pubkeys ( void  )

Definition at line 4273 of file tests.c.

◆ run_rfc6979_hmac_sha256_tests()

void run_rfc6979_hmac_sha256_tests ( void  )

Definition at line 420 of file tests.c.

◆ run_scalar_tests()

void run_scalar_tests ( void  )

Definition at line 1066 of file tests.c.

◆ run_scratch_tests()

void run_scratch_tests ( void  )

Definition at line 300 of file tests.c.

Here is the call graph for this function:

◆ run_sha256_tests()

void run_sha256_tests ( void  )

Definition at line 340 of file tests.c.

◆ run_sqr()

void run_sqr ( void  )

Definition at line 1911 of file tests.c.

◆ run_sqrt()

void run_sqrt ( void  )

Definition at line 1941 of file tests.c.

◆ run_util_tests()

void run_util_tests ( void  )

Definition at line 140 of file tests.c.

◆ run_wnaf()

void run_wnaf ( void  )

Definition at line 3218 of file tests.c.

Here is the call graph for this function:

◆ scalar_chacha_tests()

void scalar_chacha_tests ( void  )

Definition at line 1010 of file tests.c.

◆ scalar_test()

void scalar_test ( void  )

Definition at line 721 of file tests.c.

Here is the call graph for this function:

◆ test_add_neg_y_diff_x()

void test_add_neg_y_diff_x ( void  )

Definition at line 2229 of file tests.c.

◆ test_constant_wnaf()

void test_constant_wnaf ( const secp256k1_scalar number,
int  w 
)

Definition at line 3073 of file tests.c.

Here is the caller graph for this function:

◆ test_constant_wnaf_negate()

void test_constant_wnaf_negate ( const secp256k1_scalar number)

Definition at line 3058 of file tests.c.

◆ test_ec_combine()

void test_ec_combine ( void  )

Definition at line 2304 of file tests.c.

◆ test_ecdsa_der_parse()

int test_ecdsa_der_parse ( const unsigned char *  sig,
size_t  siglen,
int  certainly_der,
int  certainly_not_der 
)

Definition at line 4287 of file tests.c.

Here is the call graph for this function:

◆ test_ecdsa_edge_cases()

void test_ecdsa_edge_cases ( void  )

Definition at line 4618 of file tests.c.

◆ test_ecdsa_end_to_end()

void test_ecdsa_end_to_end ( void  )

Definition at line 4082 of file tests.c.

Here is the call graph for this function:

◆ test_ecdsa_sign_verify()

void test_ecdsa_sign_verify ( void  )

Definition at line 4000 of file tests.c.

◆ test_ecmult_constants()

void test_ecmult_constants ( void  )

Definition at line 3245 of file tests.c.

Here is the caller graph for this function:

◆ test_ecmult_gen_blind()

void test_ecmult_gen_blind ( void  )

Definition at line 3282 of file tests.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_ecmult_gen_blind_reset()

void test_ecmult_gen_blind_reset ( void  )

Definition at line 3305 of file tests.c.

Here is the caller graph for this function:

◆ test_ecmult_multi()

void test_ecmult_multi ( secp256k1_scratch scratch,
secp256k1_ecmult_multi_func  ecmult_multi 
)

Definition at line 2655 of file tests.c.

◆ test_ecmult_multi_batching()

void test_ecmult_multi_batching ( void  )

Run secp256k1_ecmult_multi_var with num points and a scratch space restricted to 1 <= i <= num points.

Definition at line 2944 of file tests.c.

◆ test_ecmult_multi_pippenger_max_points()

void test_ecmult_multi_pippenger_max_points ( void  )

Probabilistically test the function returning the maximum number of possible points for a given scratch space.

Definition at line 2917 of file tests.c.

Here is the caller graph for this function:

◆ test_fixed_wnaf()

void test_fixed_wnaf ( const secp256k1_scalar number,
int  w 
)

Definition at line 3114 of file tests.c.

◆ test_fixed_wnaf_small()

void test_fixed_wnaf_small ( void  )

Definition at line 3164 of file tests.c.

Here is the caller graph for this function:

◆ test_fixed_wnaf_small_helper()

void test_fixed_wnaf_small_helper ( int *  wnaf,
int *  wnaf_expected,
int  w 
)

Definition at line 3154 of file tests.c.

◆ test_ge()

void test_ge ( void  )

Definition at line 2025 of file tests.c.

◆ test_group_decompress()

void test_group_decompress ( const secp256k1_fe x)

Definition at line 2336 of file tests.c.

◆ test_num_add_sub()

void test_num_add_sub ( void  )

Definition at line 574 of file tests.c.

Here is the call graph for this function:

◆ test_num_jacobi()

void test_num_jacobi ( void  )

test large values with 5 as group order

test with secp group order as order

Definition at line 647 of file tests.c.

◆ test_num_mod()

void test_num_mod ( void  )

Definition at line 616 of file tests.c.

Here is the call graph for this function:

◆ test_num_negate()

void test_num_negate ( void  )

Definition at line 554 of file tests.c.

Here is the call graph for this function:

◆ test_point_times_order()

void test_point_times_order ( const secp256k1_gej point)

Definition at line 2475 of file tests.c.

◆ test_rand_bits()

void test_rand_bits ( int  rand32,
int  bits 
)

Definition at line 463 of file tests.c.

Here is the caller graph for this function:

◆ test_rand_int()

void test_rand_int ( uint32_t  range,
uint32_t  subrange 
)

Definition at line 498 of file tests.c.

Here is the caller graph for this function:

◆ test_random_pubkeys()

void test_random_pubkeys ( void  )

Definition at line 4213 of file tests.c.

◆ test_secp256k1_pippenger_bucket_window_inv()

void test_secp256k1_pippenger_bucket_window_inv ( void  )

Definition at line 2895 of file tests.c.

Here is the caller graph for this function:

◆ test_sqrt()

void test_sqrt ( const secp256k1_fe a,
const secp256k1_fe k 
)

Definition at line 1927 of file tests.c.

◆ test_wnaf()

void test_wnaf ( const secp256k1_scalar number,
int  w 
)

Definition at line 3024 of file tests.c.