| 102 | #endif |
| 103 | |
| 104 | void sign_hash(const struct privkey *privkey, |
| 105 | const struct sha256_double *h, |
| 106 | secp256k1_ecdsa_signature *s) |
| 107 | { |
| 108 | bool ok; |
| 109 | unsigned char extra_entropy[32] = {0}; |
| 110 | |
| 111 | /* Grind for low R */ |
| 112 | do { |
| 113 | ok = secp256k1_ecdsa_sign(secp256k1_ctx, |
| 114 | s, |
| 115 | h->sha.u.u8, |
| 116 | privkey->secret.data, NULL, |
| 117 | IFDEV(dev_no_grind ? NULL |
| 118 | : extra_entropy, |
| 119 | extra_entropy)); |
| 120 | ((u32 *)extra_entropy)[0]++; |
| 121 | if (IFDEV(dev_no_grind, false)) |
| 122 | break; |
| 123 | } while (!sig_has_low_r(s)); |
| 124 | |
| 125 | assert(ok); |
| 126 | } |
| 127 | |
| 128 | void bitcoin_tx_hash_for_sig(const struct bitcoin_tx *tx, unsigned int in, |
| 129 | const u8 *script, |