![]() |
Dash Core
0.12.2.1
P2P Digital Currency
|
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "secp256k1.c"
#include "include/secp256k1.h"
#include "testrand_impl.h"
#include "contrib/lax_der_parsing.c"
#include "contrib/lax_der_privatekey_parsing.c"
Go to the source code of this file.
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) |
Functions | |
static void | counting_illegal_callback_fn (const char *str, void *data) |
static void | uncounting_illegal_callback_fn (const char *str, void *data) |
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_context_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 | run_num_smalltests (void) |
void | scalar_test (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_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 | 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) |
static int | precomputed_nonce_function (unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) |
static int | nonce_function_test_fail (unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) |
static int | nonce_function_test_retry (unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int counter) |
int | is_empty_signature (const secp256k1_ecdsa_signature *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) |
static void | assign_big_endian (unsigned char *ptr, size_t ptrlen, uint32_t val) |
static void | damage_array (unsigned char *sig, size_t *len) |
static void | random_ber_signature (unsigned char *sig, size_t *len, 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) |
Variables | |
static int | count = 64 |
static secp256k1_context * | ctx = NULL |
#define SECP256K1_EC_PARSE_TEST_NINVALID (7) |
Referenced by run_ec_pubkey_parse_test().
#define SECP256K1_EC_PARSE_TEST_NVALID (12) |
Referenced by run_ec_pubkey_parse_test().
#define SECP256K1_EC_PARSE_TEST_NXVALID (4) |
Referenced by run_ec_pubkey_parse_test().
#define VG_CHECK | ( | x, | |
y | |||
) |
Definition at line 37 of file tests.c.
Referenced by ec_pubkey_parse_pointtest(), run_context_tests(), run_ec_pubkey_parse_test(), run_eckey_edge_case_test(), and test_ecdsa_edge_cases().
#define VG_UNDEF | ( | x, | |
y | |||
) |
Definition at line 36 of file tests.c.
Referenced by ec_pubkey_parse_pointtest(), run_context_tests(), run_ec_pubkey_parse_test(), run_eckey_edge_case_test(), and test_ecdsa_edge_cases().
|
static |
Definition at line 3595 of file tests.c.
Referenced by random_ber_signature().
int check_fe_equal | ( | const secp256k1_fe * | a, |
const secp256k1_fe * | b | ||
) |
Definition at line 1454 of file tests.c.
Referenced by check_fe_inverse(), run_field_inv(), run_field_inv_all_var(), run_field_inv_var(), and run_field_misc().
int check_fe_inverse | ( | const secp256k1_fe * | a, |
const secp256k1_fe * | ai | ||
) |
Definition at line 1462 of file tests.c.
Referenced by run_field_inv(), run_field_inv_all_var(), and run_field_inv_var().
|
static |
Definition at line 44 of file tests.c.
Referenced by ec_pubkey_parse_pointtest(), run_context_tests(), run_ec_pubkey_parse_test(), run_eckey_edge_case_test(), and test_ecdsa_edge_cases().
|
static |
Definition at line 3607 of file tests.c.
Referenced by run_ecdsa_der_parse().
void ec_pubkey_parse_pointtest | ( | const unsigned char * | input, |
int | xvalid, | ||
int | yvalid | ||
) |
Definition at line 2561 of file tests.c.
Referenced by run_ec_pubkey_parse_test().
void ecmult_const_chain_multiply | ( | void | ) |
Definition at line 2300 of file tests.c.
Referenced by run_ecmult_const_tests().
void ecmult_const_commutativity | ( | void | ) |
Definition at line 2257 of file tests.c.
Referenced by run_ecmult_const_tests().
void ecmult_const_mult_zero_one | ( | void | ) |
Definition at line 2278 of file tests.c.
Referenced by run_ecmult_const_tests().
void ecmult_const_random_mult | ( | void | ) |
Definition at line 2230 of file tests.c.
Referenced by run_ecmult_const_tests().
int fe_memcmp | ( | const secp256k1_fe * | a, |
const secp256k1_fe * | b | ||
) |
Definition at line 1499 of file tests.c.
Referenced by run_field_misc().
void ge_equals_ge | ( | const secp256k1_ge * | a, |
const secp256k1_ge * | b | ||
) |
Definition at line 1692 of file tests.c.
Referenced by ecmult_const_commutativity(), ecmult_const_mult_zero_one(), run_ec_pubkey_parse_test(), test_point_times_order(), and test_random_pubkeys().
void ge_equals_gej | ( | const secp256k1_ge * | a, |
const secp256k1_gej * | b | ||
) |
Definition at line 1723 of file tests.c.
Referenced by ecmult_const_chain_multiply(), ecmult_const_random_mult(), test_add_neg_y_diff_x(), test_ecmult_constants(), test_ecmult_gen_blind(), test_ge(), and test_point_times_order().
int gej_xyz_equals_gej | ( | const secp256k1_gej * | a, |
const secp256k1_gej * | b | ||
) |
Definition at line 1702 of file tests.c.
Referenced by test_ecmult_gen_blind(), and test_ecmult_gen_blind_reset().
int is_empty_signature | ( | const secp256k1_ecdsa_signature * | sig | ) |
Definition at line 3283 of file tests.c.
Referenced by test_ecdsa_edge_cases().
|
static |
Definition at line 3245 of file tests.c.
Referenced by test_ecdsa_edge_cases().
|
static |
Definition at line 3253 of file tests.c.
Referenced by test_ecdsa_edge_cases().
|
static |
Dummy nonce generation function that just uses a precomputed nonce, and fails if it is not accepted. Use only for testing.
Definition at line 3237 of file tests.c.
Referenced by test_ecdsa_edge_cases().
|
static |
Definition at line 3634 of file tests.c.
Referenced by run_ecdsa_der_parse().
void random_fe | ( | secp256k1_fe * | x | ) |
Definition at line 1413 of file tests.c.
Referenced by random_fe_non_zero(), run_field_misc(), and run_sqrt().
void random_fe_non_square | ( | secp256k1_fe * | ns | ) |
Definition at line 1446 of file tests.c.
Referenced by run_sqrt().
void random_fe_non_zero | ( | secp256k1_fe * | nz | ) |
Definition at line 1433 of file tests.c.
Referenced by random_fe_non_square(), run_field_inv(), run_field_inv_all_var(), run_field_inv_var(), run_field_misc(), and test_ge().
void random_fe_test | ( | secp256k1_fe * | x | ) |
Definition at line 1423 of file tests.c.
Referenced by run_group_decompress().
void random_field_element_magnitude | ( | secp256k1_fe * | fe | ) |
void random_field_element_test | ( | secp256k1_fe * | fe | ) |
Definition at line 60 of file tests.c.
Referenced by random_group_element_jacobian_test(), random_group_element_test(), and test_ge().
void random_group_element_jacobian_test | ( | secp256k1_gej * | gej, |
const secp256k1_ge * | ge | ||
) |
void random_group_element_test | ( | secp256k1_ge * | ge | ) |
Definition at line 84 of file tests.c.
Referenced by ecmult_const_mult_zero_one(), and test_ge().
void random_num_negate | ( | secp256k1_num * | num | ) |
Definition at line 437 of file tests.c.
Referenced by test_num_add_sub(), and test_num_negate().
void random_num_order | ( | secp256k1_num * | num | ) |
void random_num_order_test | ( | secp256k1_num * | num | ) |
Definition at line 443 of file tests.c.
Referenced by test_num_add_sub(), and test_num_negate().
void random_scalar_order | ( | secp256k1_scalar * | num | ) |
Definition at line 123 of file tests.c.
Referenced by random_num_order(), run_wnaf(), test_bad_scalar(), and test_ecdh_generator_basepoint().
void random_scalar_order_test | ( | secp256k1_scalar * | num | ) |
Definition at line 110 of file tests.c.
Referenced by ecmult_const_commutativity(), random_num_order_test(), random_sign(), run_context_tests(), scalar_test(), test_ec_combine(), test_ecdsa_end_to_end(), test_ecdsa_recovery_end_to_end(), test_ecdsa_sign_verify(), test_ecmult_gen_blind(), test_point_times_order(), test_schnorr_end_to_end(), and test_schnorr_sign_verify().
void random_sign | ( | secp256k1_scalar * | sigr, |
secp256k1_scalar * | sigs, | ||
const secp256k1_scalar * | key, | ||
const secp256k1_scalar * | msg, | ||
int * | recid | ||
) |
Definition at line 3199 of file tests.c.
Referenced by test_ecdsa_sign_verify().
void run_ec_pubkey_parse_test | ( | void | ) |
void run_eckey_edge_case_test | ( | void | ) |
void run_rfc6979_hmac_sha256_tests | ( | void | ) |
void scalar_test | ( | void | ) |
Definition at line 514 of file tests.c.
Referenced by run_scalar_tests().
void test_add_neg_y_diff_x | ( | void | ) |
void test_constant_wnaf | ( | const secp256k1_scalar * | number, |
int | w | ||
) |
Definition at line 2382 of file tests.c.
Referenced by run_wnaf().
void test_constant_wnaf_negate | ( | const secp256k1_scalar * | number | ) |
Definition at line 2367 of file tests.c.
Referenced by run_wnaf().
void test_ec_combine | ( | void | ) |
Definition at line 2019 of file tests.c.
Referenced by run_ec_combine().
int test_ecdsa_der_parse | ( | const unsigned char * | sig, |
size_t | siglen, | ||
int | certainly_der, | ||
int | certainly_not_der | ||
) |
Definition at line 3485 of file tests.c.
Referenced by run_ecdsa_der_parse().
void test_ecdsa_edge_cases | ( | void | ) |
Definition at line 3811 of file tests.c.
Referenced by run_ecdsa_edge_cases().
void test_ecdsa_end_to_end | ( | void | ) |
Definition at line 3288 of file tests.c.
Referenced by run_ecdsa_end_to_end().
void test_ecdsa_sign_verify | ( | void | ) |
Definition at line 3206 of file tests.c.
Referenced by run_ecdsa_sign_verify().
void test_ecmult_constants | ( | void | ) |
Definition at line 2451 of file tests.c.
Referenced by run_ecmult_constants().
void test_ecmult_gen_blind | ( | void | ) |
Definition at line 2488 of file tests.c.
Referenced by run_ecmult_gen_blind().
void test_ecmult_gen_blind_reset | ( | void | ) |
Definition at line 2511 of file tests.c.
Referenced by run_ecmult_gen_blind().
void test_group_decompress | ( | const secp256k1_fe * | x | ) |
Definition at line 2051 of file tests.c.
Referenced by run_group_decompress().
void test_num_add_sub | ( | void | ) |
Definition at line 475 of file tests.c.
Referenced by run_num_smalltests().
void test_num_negate | ( | void | ) |
Definition at line 455 of file tests.c.
Referenced by run_num_smalltests().
void test_point_times_order | ( | const secp256k1_gej * | point | ) |
Definition at line 2173 of file tests.c.
Referenced by run_point_times_order().
void test_rand_bits | ( | int | rand32, |
int | bits | ||
) |
Definition at line 364 of file tests.c.
Referenced by run_rand_bits().
void test_rand_int | ( | uint32_t | range, |
uint32_t | subrange | ||
) |
Definition at line 399 of file tests.c.
Referenced by run_rand_int().
void test_random_pubkeys | ( | void | ) |
Definition at line 3411 of file tests.c.
Referenced by run_random_pubkeys().
void test_sqrt | ( | const secp256k1_fe * | a, |
const secp256k1_fe * | k | ||
) |
Definition at line 1642 of file tests.c.
Referenced by run_sqrt().
void test_wnaf | ( | const secp256k1_scalar * | number, |
int | w | ||
) |
Definition at line 2333 of file tests.c.
Referenced by run_wnaf().
|
static |
Definition at line 52 of file tests.c.
Referenced by run_ec_pubkey_parse_test().
|
static |
Definition at line 41 of file tests.c.
Referenced by CCoinsViewDB::BatchWrite(), EvalScript(), FindFilesToPrune(), AbstractThresholdConditionChecker::GetStateFor(), groestl_big_close(), groestl_small_close(), prevector< N, T, Size, Diff >::insert(), main(), MerkleComputation(), TrafficGraphWidget::paintEvent(), CGovernanceManager::ProcessMessage(), AddressTableModel::removeRows(), RecentRequestsTableModel::removeRows(), CGovernanceManager::RequestGovernanceObjectVotes(), rest_headers(), WorkQueue< WorkItem >::Run(), run_benchmark(), run_ec_combine(), run_ecdsa_der_parse(), run_ecdsa_end_to_end(), run_ecdsa_sign_verify(), run_ecmult_chain(), run_field_inv(), run_field_inv_all_var(), run_field_inv_var(), run_field_misc(), run_ge(), run_group_decompress(), run_num_smalltests(), run_random_pubkeys(), run_recovery_tests(), run_scalar_tests(), run_schnorr_tests(), run_sqrt(), run_wnaf(), secp256k1_ecdsa_sign(), secp256k1_ecdsa_sign_recoverable(), secp256k1_ge_set_all_gej_var(), secp256k1_scalar_get_bits(), secp256k1_scalar_get_bits_var(), secp256k1_schnorr_generate_nonce_pair(), secp256k1_schnorr_sign(), ModalOverlay::setKnownBestHeight(), RPCConsole::setNumBlocks(), BitcoinGUI::setNumBlocks(), CZMQAbstractPublishNotifier::Shutdown(), ModalOverlay::tipUpdate(), and BitcoinGUI::updateNetworkState().
|
static |
Definition at line 42 of file tests.c.
Referenced by AddressTableModel::addRow(), CCrypter::Decrypt(), DecryptAES256(), ec_privkey_export_der(), ec_privkey_import_der(), ec_pubkey_parse_pointtest(), ECC_Start(), ECC_Stop(), ecdsa_signature_parse_der_lax(), CCrypter::Encrypt(), EncryptAES256(), TorControlConnection::eventcb(), PaymentRequestPlus::getMerchant(), http_request_done(), main(), SendCoinsDialog::on_sendButton_clicked(), SignVerifyMessageDialog::on_signMessageButton_SM_clicked(), MasternodeList::on_startAllButton_clicked(), MasternodeList::on_startButton_clicked(), MasternodeList::on_startMissingButton_clicked(), random_sign(), TorControlConnection::readcb(), run_ec_pubkey_parse_test(), run_eckey_edge_case_test(), run_ecmult_chain(), secp256k1_context_clone(), secp256k1_context_destroy(), secp256k1_context_randomize(), secp256k1_context_set_error_callback(), secp256k1_context_set_illegal_callback(), secp256k1_ec_privkey_tweak_add(), secp256k1_ec_privkey_tweak_mul(), secp256k1_ec_pubkey_combine(), secp256k1_ec_pubkey_create(), secp256k1_ec_pubkey_parse(), secp256k1_ec_pubkey_serialize(), secp256k1_ec_pubkey_tweak_add(), secp256k1_ec_pubkey_tweak_mul(), secp256k1_ec_seckey_verify(), secp256k1_ecdh(), secp256k1_ecdsa_recover(), secp256k1_ecdsa_recoverable_signature_convert(), secp256k1_ecdsa_recoverable_signature_load(), secp256k1_ecdsa_recoverable_signature_parse_compact(), secp256k1_ecdsa_recoverable_signature_serialize_compact(), secp256k1_ecdsa_sig_recover(), secp256k1_ecdsa_sig_sign(), secp256k1_ecdsa_sig_verify(), secp256k1_ecdsa_sign(), secp256k1_ecdsa_sign_recoverable(), secp256k1_ecdsa_signature_load(), secp256k1_ecdsa_signature_normalize(), secp256k1_ecdsa_signature_parse_compact(), secp256k1_ecdsa_signature_parse_der(), secp256k1_ecdsa_signature_serialize_compact(), secp256k1_ecdsa_signature_serialize_der(), secp256k1_ecdsa_verify(), secp256k1_eckey_pubkey_tweak_add(), secp256k1_eckey_pubkey_tweak_mul(), secp256k1_ecmult(), secp256k1_ecmult_context_build(), secp256k1_ecmult_context_clear(), secp256k1_ecmult_context_init(), secp256k1_ecmult_context_is_built(), secp256k1_ecmult_gen(), secp256k1_ecmult_gen_blind(), secp256k1_ecmult_gen_context_build(), secp256k1_ecmult_gen_context_clear(), secp256k1_ecmult_gen_context_init(), secp256k1_ecmult_gen_context_is_built(), secp256k1_schnorr_generate_nonce_pair(), secp256k1_schnorr_partial_sign(), secp256k1_schnorr_recover(), secp256k1_schnorr_sig_recover(), secp256k1_schnorr_sig_sign(), secp256k1_schnorr_sig_verify(), secp256k1_schnorr_sign(), secp256k1_schnorr_verify(), test_bad_scalar(), test_ec_combine(), test_ecdh_generator_basepoint(), test_ecdsa_der_parse(), test_ecdsa_edge_cases(), test_ecdsa_end_to_end(), test_ecdsa_recovery_edge_cases(), test_ecdsa_recovery_end_to_end(), test_ecdsa_sign_verify(), test_ecmult_constants(), test_ecmult_gen_blind(), test_ecmult_gen_blind_reset(), test_ge(), test_point_times_order(), test_schnorr_end_to_end(), test_schnorr_recovery(), test_schnorr_sign_verify(), test_schnorr_threshold(), and OverviewPage::togglePrivateSend().