Add scalar_set_b32_seckey which does the same as scalar_set_b32 and also returns whether it's a valid secret key

This commit is contained in:
Jonas Nick
2019-12-17 15:32:00 +00:00
parent 4f27e344c6
commit 9ab2cbe0eb
3 changed files with 36 additions and 0 deletions

View File

@@ -55,6 +55,12 @@ static void secp256k1_scalar_order_get_num(secp256k1_num *r) {
}
#endif
static int secp256k1_scalar_set_b32_seckey(secp256k1_scalar *r, const unsigned char *bin) {
int overflow;
secp256k1_scalar_set_b32(r, bin, &overflow);
return (!overflow) & (!secp256k1_scalar_is_zero(r));
}
static void secp256k1_scalar_inverse(secp256k1_scalar *r, const secp256k1_scalar *x) {
#if defined(EXHAUSTIVE_TEST_ORDER)
int i;