20 if (skip_section(&iter))
continue;
22 const int starting_k = k;
27 unsigned char sk32[32], msg32[32];
31 secp256k1_scalar_set_int(&msg, i);
32 secp256k1_scalar_set_int(&sk,
j);
33 secp256k1_scalar_get_b32(sk32, &sk);
34 secp256k1_scalar_get_b32(msg32, &msg);
39 secp256k1_ecdsa_recoverable_signature_load(ctx, &
r, &
s, &recid, &rsig);
52 r_dot_y_normalized = group[k].
y;
53 secp256k1_fe_normalize(&r_dot_y_normalized);
56 expected_recid |= secp256k1_fe_is_odd(&r_dot_y_normalized);
58 expected_recid |= !secp256k1_fe_is_odd(&r_dot_y_normalized);
60 CHECK(recid == expected_recid);
64 secp256k1_ecdsa_signature_load(ctx, &
r, &
s, &sig);
68 r_from_k(&expected_r, group, k, NULL);
98 unsigned char msg32[32];
100 if (skip_section(&iter))
continue;
102 secp256k1_scalar_set_int(&s_s,
s);
103 secp256k1_scalar_set_int(&r_s,
r);
104 secp256k1_scalar_set_int(&msg_s, msg);
105 secp256k1_scalar_set_int(&sk_s, key);
106 secp256k1_scalar_get_b32(msg32, &msg_s);
114 r_from_k(&check_x_s, group, k, NULL);
115 if (r_s == check_x_s) {
116 secp256k1_scalar_set_int(&s_times_k_s, k);
117 secp256k1_scalar_mul(&s_times_k_s, &s_times_k_s, &s_s);
118 secp256k1_scalar_mul(&msg_plus_r_times_sk_s, &r_s, &sk_s);
119 secp256k1_scalar_add(&msg_plus_r_times_sk_s, &msg_plus_r_times_sk_s, &msg_s);
120 should_verify |= secp256k1_scalar_eq(&s_times_k_s, &msg_plus_r_times_sk_s);
124 should_verify &= !secp256k1_scalar_is_high(&s_s);
132 secp256k1_ecdsa_recoverable_signature_save(&rsig, &r_s, &s_s, recid);
134 memcpy(&nonconst_ge, &group[sk_s],
sizeof(nonconst_ge));
135 secp256k1_pubkey_save(&pk, &nonconst_ge);
136 CHECK(should_verify ==
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdsa_verify(const secp256k1_context *ctx, const secp256k1_ecdsa_signature *sig, const unsigned char *msghash32, const secp256k1_pubkey *pubkey) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
SECP256K1_API int secp256k1_ecdsa_sign_recoverable(const secp256k1_context *ctx, secp256k1_ecdsa_recoverable_signature *sig, const unsigned char *msghash32, const unsigned char *seckey, secp256k1_nonce_function noncefp, const void *ndata) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
int secp256k1_nonce_function_smallint(unsigned char *nonce32, const unsigned char *msg32, const unsigned char *key32, const unsigned char *algo16, void *data, unsigned int attempt)