Skip to content

Commit

Permalink
Merge bitcoin#479: Get rid of reserved _t in type names
Browse files Browse the repository at this point in the history
d1dc9df Get rid of reserved _t in type names (Pieter Wuille)

Pull request description:

Tree-SHA512: 5da4a2cb15106c47fbe14346562444eff322a5e4e2386af8b0b879b72e22f08d704ac09746d6a22ff76e8892fc20208932b2a45d01de0e2e089686dabe45e633
  • Loading branch information
sipa committed Nov 8, 2017
2 parents 0b70241 + d1dc9df commit 6ad5cdb
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 79 deletions.
8 changes: 4 additions & 4 deletions src/bench_ecdh.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ typedef struct {
secp256k1_context *ctx;
secp256k1_pubkey point;
unsigned char scalar[32];
} bench_ecdh_t;
} bench_ecdh;

static void bench_ecdh_setup(void* arg) {
int i;
bench_ecdh_t *data = (bench_ecdh_t*)arg;
bench_ecdh *data = (bench_ecdh*)arg;
const unsigned char point[] = {
0x03,
0x54, 0x94, 0xc1, 0x5d, 0x32, 0x09, 0x97, 0x06,
Expand All @@ -39,15 +39,15 @@ static void bench_ecdh_setup(void* arg) {
static void bench_ecdh(void* arg) {
int i;
unsigned char res[32];
bench_ecdh_t *data = (bench_ecdh_t*)arg;
bench_ecdh *data = (bench_ecdh*)arg;

for (i = 0; i < 20000; i++) {
CHECK(secp256k1_ecdh(data->ctx, res, &data->point, data->scalar) == 1);
}
}

int main(void) {
bench_ecdh_t data;
bench_ecdh data;

run_benchmark("ecdh", bench_ecdh, bench_ecdh_setup, NULL, &data, 10, 20000);
return 0;
Expand Down
62 changes: 31 additions & 31 deletions src/bench_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ typedef struct {
secp256k1_gej gej_x, gej_y;
unsigned char data[64];
int wnaf[256];
} bench_inv_t;
} bench_inv;

void bench_setup(void* arg) {
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

static const unsigned char init_x[32] = {
0x02, 0x03, 0x05, 0x07, 0x0b, 0x0d, 0x11, 0x13,
Expand Down Expand Up @@ -58,7 +58,7 @@ void bench_setup(void* arg) {

void bench_scalar_add(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 2000000; i++) {
secp256k1_scalar_add(&data->scalar_x, &data->scalar_x, &data->scalar_y);
Expand All @@ -67,7 +67,7 @@ void bench_scalar_add(void* arg) {

void bench_scalar_negate(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 2000000; i++) {
secp256k1_scalar_negate(&data->scalar_x, &data->scalar_x);
Expand All @@ -76,7 +76,7 @@ void bench_scalar_negate(void* arg) {

void bench_scalar_sqr(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 200000; i++) {
secp256k1_scalar_sqr(&data->scalar_x, &data->scalar_x);
Expand All @@ -85,7 +85,7 @@ void bench_scalar_sqr(void* arg) {

void bench_scalar_mul(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 200000; i++) {
secp256k1_scalar_mul(&data->scalar_x, &data->scalar_x, &data->scalar_y);
Expand All @@ -95,7 +95,7 @@ void bench_scalar_mul(void* arg) {
#ifdef USE_ENDOMORPHISM
void bench_scalar_split(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 20000; i++) {
secp256k1_scalar l, r;
Expand All @@ -107,7 +107,7 @@ void bench_scalar_split(void* arg) {

void bench_scalar_inverse(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 2000; i++) {
secp256k1_scalar_inverse(&data->scalar_x, &data->scalar_x);
Expand All @@ -117,7 +117,7 @@ void bench_scalar_inverse(void* arg) {

void bench_scalar_inverse_var(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 2000; i++) {
secp256k1_scalar_inverse_var(&data->scalar_x, &data->scalar_x);
Expand All @@ -127,7 +127,7 @@ void bench_scalar_inverse_var(void* arg) {

void bench_field_normalize(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 2000000; i++) {
secp256k1_fe_normalize(&data->fe_x);
Expand All @@ -136,7 +136,7 @@ void bench_field_normalize(void* arg) {

void bench_field_normalize_weak(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 2000000; i++) {
secp256k1_fe_normalize_weak(&data->fe_x);
Expand All @@ -145,7 +145,7 @@ void bench_field_normalize_weak(void* arg) {

void bench_field_mul(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 200000; i++) {
secp256k1_fe_mul(&data->fe_x, &data->fe_x, &data->fe_y);
Expand All @@ -154,7 +154,7 @@ void bench_field_mul(void* arg) {

void bench_field_sqr(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 200000; i++) {
secp256k1_fe_sqr(&data->fe_x, &data->fe_x);
Expand All @@ -163,7 +163,7 @@ void bench_field_sqr(void* arg) {

void bench_field_inverse(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 20000; i++) {
secp256k1_fe_inv(&data->fe_x, &data->fe_x);
Expand All @@ -173,7 +173,7 @@ void bench_field_inverse(void* arg) {

void bench_field_inverse_var(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 20000; i++) {
secp256k1_fe_inv_var(&data->fe_x, &data->fe_x);
Expand All @@ -183,7 +183,7 @@ void bench_field_inverse_var(void* arg) {

void bench_field_sqrt(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 20000; i++) {
secp256k1_fe_sqrt(&data->fe_x, &data->fe_x);
Expand All @@ -193,7 +193,7 @@ void bench_field_sqrt(void* arg) {

void bench_group_double_var(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 200000; i++) {
secp256k1_gej_double_var(&data->gej_x, &data->gej_x, NULL);
Expand All @@ -202,7 +202,7 @@ void bench_group_double_var(void* arg) {

void bench_group_add_var(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 200000; i++) {
secp256k1_gej_add_var(&data->gej_x, &data->gej_x, &data->gej_y, NULL);
Expand All @@ -211,7 +211,7 @@ void bench_group_add_var(void* arg) {

void bench_group_add_affine(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 200000; i++) {
secp256k1_gej_add_ge(&data->gej_x, &data->gej_x, &data->ge_y);
Expand All @@ -220,7 +220,7 @@ void bench_group_add_affine(void* arg) {

void bench_group_add_affine_var(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 200000; i++) {
secp256k1_gej_add_ge_var(&data->gej_x, &data->gej_x, &data->ge_y, NULL);
Expand All @@ -229,7 +229,7 @@ void bench_group_add_affine_var(void* arg) {

void bench_group_jacobi_var(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 20000; i++) {
secp256k1_gej_has_quad_y_var(&data->gej_x);
Expand All @@ -238,7 +238,7 @@ void bench_group_jacobi_var(void* arg) {

void bench_ecmult_wnaf(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 20000; i++) {
secp256k1_ecmult_wnaf(data->wnaf, 256, &data->scalar_x, WINDOW_A);
Expand All @@ -248,7 +248,7 @@ void bench_ecmult_wnaf(void* arg) {

void bench_wnaf_const(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;

for (i = 0; i < 20000; i++) {
secp256k1_wnaf_const(data->wnaf, data->scalar_x, WINDOW_A);
Expand All @@ -259,8 +259,8 @@ void bench_wnaf_const(void* arg) {

void bench_sha256(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
secp256k1_sha256_t sha;
bench_inv *data = (bench_inv*)arg;
secp256k1_sha256 sha;

for (i = 0; i < 20000; i++) {
secp256k1_sha256_initialize(&sha);
Expand All @@ -271,8 +271,8 @@ void bench_sha256(void* arg) {

void bench_hmac_sha256(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
secp256k1_hmac_sha256_t hmac;
bench_inv *data = (bench_inv*)arg;
secp256k1_hmac_sha256 hmac;

for (i = 0; i < 20000; i++) {
secp256k1_hmac_sha256_initialize(&hmac, data->data, 32);
Expand All @@ -283,8 +283,8 @@ void bench_hmac_sha256(void* arg) {

void bench_rfc6979_hmac_sha256(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
secp256k1_rfc6979_hmac_sha256_t rng;
bench_inv *data = (bench_inv*)arg;
secp256k1_rfc6979_hmac_sha256 rng;

for (i = 0; i < 20000; i++) {
secp256k1_rfc6979_hmac_sha256_initialize(&rng, data->data, 64);
Expand All @@ -311,7 +311,7 @@ void bench_context_sign(void* arg) {
#ifndef USE_NUM_NONE
void bench_num_jacobi(void* arg) {
int i;
bench_inv_t *data = (bench_inv_t*)arg;
bench_inv *data = (bench_inv*)arg;
secp256k1_num nx, norder;

secp256k1_scalar_get_num(&nx, &data->scalar_x);
Expand Down Expand Up @@ -340,7 +340,7 @@ int have_flag(int argc, char** argv, char *flag) {
}

int main(int argc, char **argv) {
bench_inv_t data;
bench_inv data;
if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "add")) run_benchmark("scalar_add", bench_scalar_add, bench_setup, NULL, &data, 10, 2000000);
if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "negate")) run_benchmark("scalar_negate", bench_scalar_negate, bench_setup, NULL, &data, 10, 2000000);
if (have_flag(argc, argv, "scalar") || have_flag(argc, argv, "sqr")) run_benchmark("scalar_sqr", bench_scalar_sqr, bench_setup, NULL, &data, 10, 200000);
Expand Down
8 changes: 4 additions & 4 deletions src/bench_recover.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ typedef struct {
secp256k1_context *ctx;
unsigned char msg[32];
unsigned char sig[64];
} bench_recover_t;
} bench_recover;

void bench_recover(void* arg) {
int i;
bench_recover_t *data = (bench_recover_t*)arg;
bench_recover *data = (bench_recover*)arg;
secp256k1_pubkey pubkey;
unsigned char pubkeyc[33];

Expand All @@ -38,7 +38,7 @@ void bench_recover(void* arg) {

void bench_recover_setup(void* arg) {
int i;
bench_recover_t *data = (bench_recover_t*)arg;
bench_recover *data = (bench_recover*)arg;

for (i = 0; i < 32; i++) {
data->msg[i] = 1 + i;
Expand All @@ -49,7 +49,7 @@ void bench_recover_setup(void* arg) {
}

int main(void) {
bench_recover_t data;
bench_recover data;

data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY);

Expand Down
12 changes: 6 additions & 6 deletions src/bench_sign.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ typedef struct {
secp256k1_context* ctx;
unsigned char msg[32];
unsigned char key[32];
} bench_sign_t;
} bench_sign;

static void bench_sign_setup(void* arg) {
int i;
bench_sign_t *data = (bench_sign_t*)arg;
bench_sign *data = (bench_sign*)arg;

for (i = 0; i < 32; i++) {
data->msg[i] = i + 1;
Expand All @@ -26,9 +26,9 @@ static void bench_sign_setup(void* arg) {
}
}

static void bench_sign(void* arg) {
static void bench_sign_run(void* arg) {
int i;
bench_sign_t *data = (bench_sign_t*)arg;
bench_sign *data = (bench_sign*)arg;

unsigned char sig[74];
for (i = 0; i < 20000; i++) {
Expand All @@ -45,11 +45,11 @@ static void bench_sign(void* arg) {
}

int main(void) {
bench_sign_t data;
bench_sign data;

data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN);

run_benchmark("ecdsa_sign", bench_sign, bench_sign_setup, NULL, &data, 10, 20000);
run_benchmark("ecdsa_sign", bench_sign_run, bench_sign_setup, NULL, &data, 10, 20000);

secp256k1_context_destroy(data.ctx);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/ecmult_gen_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static void secp256k1_ecmult_gen_blind(secp256k1_ecmult_gen_context *ctx, const
secp256k1_gej gb;
secp256k1_fe s;
unsigned char nonce32[32];
secp256k1_rfc6979_hmac_sha256_t rng;
secp256k1_rfc6979_hmac_sha256 rng;
int retry;
unsigned char keydata[64] = {0};
if (seed32 == NULL) {
Expand Down
Loading

0 comments on commit 6ad5cdb

Please sign in to comment.