Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/secp256k1.c
Show First 20 Lines • Show All 360 Lines • ▼ Show 20 Lines | int secp256k1_ecdsa_sign(const secp256k1_context* ctx, secp256k1_ecdsa_signature *signature, const unsigned char *msg32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void* noncedata) { | ||||
secp256k1_scalar_set_b32(&sec, seckey, &overflow); | secp256k1_scalar_set_b32(&sec, seckey, &overflow); | ||||
/* Fail if the secret key is invalid. */ | /* Fail if the secret key is invalid. */ | ||||
if (!overflow && !secp256k1_scalar_is_zero(&sec)) { | if (!overflow && !secp256k1_scalar_is_zero(&sec)) { | ||||
unsigned char nonce32[32]; | unsigned char nonce32[32]; | ||||
unsigned int count = 0; | unsigned int count = 0; | ||||
secp256k1_scalar_set_b32(&msg, msg32, NULL); | secp256k1_scalar_set_b32(&msg, msg32, NULL); | ||||
while (1) { | while (1) { | ||||
ret = noncefp(nonce32, msg32, seckey, NULL, (void*)noncedata, count); | ret = noncefp(nonce32, msg32, seckey, secp256k1_ecdsa_algo16, (void*)noncedata, count); | ||||
deadalnixUnsubmitted Not Done Inline Actionsdeadalnix: ECDSA+Recovery | |||||
if (!ret) { | if (!ret) { | ||||
break; | break; | ||||
} | } | ||||
secp256k1_scalar_set_b32(&non, nonce32, &overflow); | secp256k1_scalar_set_b32(&non, nonce32, &overflow); | ||||
if (!overflow && !secp256k1_scalar_is_zero(&non)) { | if (!overflow && !secp256k1_scalar_is_zero(&non)) { | ||||
if (secp256k1_ecdsa_sig_sign(&ctx->ecmult_gen_ctx, &r, &s, &sec, &msg, &non, NULL)) { | if (secp256k1_ecdsa_sig_sign(&ctx->ecmult_gen_ctx, &r, &s, &sec, &msg, &non, NULL)) { | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 214 Lines • Show Last 20 Lines |