schnorrsig: allow setting MSGLEN != 32 in benchmark
This commit is contained in:
parent
fdd06b7967
commit
5f6ceafcfa
|
@ -28,13 +28,13 @@ typedef struct {
|
||||||
void bench_schnorrsig_sign(void* arg, int iters) {
|
void bench_schnorrsig_sign(void* arg, int iters) {
|
||||||
bench_schnorrsig_data *data = (bench_schnorrsig_data *)arg;
|
bench_schnorrsig_data *data = (bench_schnorrsig_data *)arg;
|
||||||
int i;
|
int i;
|
||||||
unsigned char msg[MSGLEN] = "benchmarkexamplemessagetemplate";
|
unsigned char msg[MSGLEN] = {0};
|
||||||
unsigned char sig[64];
|
unsigned char sig[64];
|
||||||
|
|
||||||
for (i = 0; i < iters; i++) {
|
for (i = 0; i < iters; i++) {
|
||||||
msg[0] = i;
|
msg[0] = i;
|
||||||
msg[1] = i >> 8;
|
msg[1] = i >> 8;
|
||||||
CHECK(secp256k1_schnorrsig_sign(data->ctx, sig, msg, data->keypairs[i], NULL));
|
CHECK(secp256k1_schnorrsig_sign_custom(data->ctx, sig, msg, MSGLEN, data->keypairs[i], NULL));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ int main(void) {
|
||||||
data.msgs = (const unsigned char **)malloc(iters * sizeof(unsigned char *));
|
data.msgs = (const unsigned char **)malloc(iters * sizeof(unsigned char *));
|
||||||
data.sigs = (const unsigned char **)malloc(iters * sizeof(unsigned char *));
|
data.sigs = (const unsigned char **)malloc(iters * sizeof(unsigned char *));
|
||||||
|
|
||||||
|
CHECK(MSGLEN >= 4);
|
||||||
for (i = 0; i < iters; i++) {
|
for (i = 0; i < iters; i++) {
|
||||||
unsigned char sk[32];
|
unsigned char sk[32];
|
||||||
unsigned char *msg = (unsigned char *)malloc(MSGLEN);
|
unsigned char *msg = (unsigned char *)malloc(MSGLEN);
|
||||||
|
@ -71,7 +72,7 @@ int main(void) {
|
||||||
msg[1] = sk[1] = i >> 8;
|
msg[1] = sk[1] = i >> 8;
|
||||||
msg[2] = sk[2] = i >> 16;
|
msg[2] = sk[2] = i >> 16;
|
||||||
msg[3] = sk[3] = i >> 24;
|
msg[3] = sk[3] = i >> 24;
|
||||||
memset(&msg[4], 'm', 28);
|
memset(&msg[4], 'm', MSGLEN - 4);
|
||||||
memset(&sk[4], 's', 28);
|
memset(&sk[4], 's', 28);
|
||||||
|
|
||||||
data.keypairs[i] = keypair;
|
data.keypairs[i] = keypair;
|
||||||
|
@ -80,7 +81,7 @@ int main(void) {
|
||||||
data.sigs[i] = sig;
|
data.sigs[i] = sig;
|
||||||
|
|
||||||
CHECK(secp256k1_keypair_create(data.ctx, keypair, sk));
|
CHECK(secp256k1_keypair_create(data.ctx, keypair, sk));
|
||||||
CHECK(secp256k1_schnorrsig_sign(data.ctx, sig, msg, keypair, NULL));
|
CHECK(secp256k1_schnorrsig_sign_custom(data.ctx, sig, msg, MSGLEN, keypair, NULL));
|
||||||
CHECK(secp256k1_keypair_xonly_pub(data.ctx, &pk, NULL, keypair));
|
CHECK(secp256k1_keypair_xonly_pub(data.ctx, &pk, NULL, keypair));
|
||||||
CHECK(secp256k1_xonly_pubkey_serialize(data.ctx, pk_char, &pk) == 1);
|
CHECK(secp256k1_xonly_pubkey_serialize(data.ctx, pk_char, &pk) == 1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue