mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
bitcoin: allow developer override of signature grinding.
Allows us to precisely replicate test vectors. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -94,6 +94,13 @@ static bool sig_has_low_r(const secp256k1_ecdsa_signature* sig)
|
|||||||
return compact_sig[0] < 0x80;
|
return compact_sig[0] < 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if DEVELOPER
|
||||||
|
/* Some of the spec test vectors assume no sig grinding. */
|
||||||
|
extern bool dev_no_grind;
|
||||||
|
|
||||||
|
bool dev_no_grind = false;
|
||||||
|
#endif
|
||||||
|
|
||||||
void sign_hash(const struct privkey *privkey,
|
void sign_hash(const struct privkey *privkey,
|
||||||
const struct sha256_double *h,
|
const struct sha256_double *h,
|
||||||
secp256k1_ecdsa_signature *s)
|
secp256k1_ecdsa_signature *s)
|
||||||
@@ -106,8 +113,13 @@ void sign_hash(const struct privkey *privkey,
|
|||||||
ok = secp256k1_ecdsa_sign(secp256k1_ctx,
|
ok = secp256k1_ecdsa_sign(secp256k1_ctx,
|
||||||
s,
|
s,
|
||||||
h->sha.u.u8,
|
h->sha.u.u8,
|
||||||
privkey->secret.data, NULL, extra_entropy);
|
privkey->secret.data, NULL,
|
||||||
|
IFDEV(dev_no_grind ? NULL
|
||||||
|
: extra_entropy,
|
||||||
|
extra_entropy));
|
||||||
((u32 *)extra_entropy)[0]++;
|
((u32 *)extra_entropy)[0]++;
|
||||||
|
if (IFDEV(dev_no_grind, false))
|
||||||
|
break;
|
||||||
} while (!sig_has_low_r(s));
|
} while (!sig_has_low_r(s));
|
||||||
|
|
||||||
assert(ok);
|
assert(ok);
|
||||||
|
|||||||
Reference in New Issue
Block a user