From 837a095d680895318d5ed20b32208835c9263bb4 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 8 Apr 2019 16:04:05 +0930 Subject: [PATCH] pubkey: rename PUBKEY_DER_LEN to PUBKEY_CMPR_LEN. Pubkeys are not not actually DER encoding, but Pieter Wuille corrected me: it's SEC 1 documented encoding. Results from 5 runs, min-max(mean +/- stddev): store_load_msec,vsz_kb,store_rewrite_sec,listnodes_sec,listchannels_sec,routing_sec,peer_write_all_sec 38922-39297(39180.6+/-1.3e+02),2880728,41.040000-41.160000(41.106+/-0.05),2.270000-2.530000(2.338+/-0.097),44.570000-53.980000(49.696+/-3),32.840000-33.080000(32.95+/-0.095),43.060000-44.950000(43.696+/-0.72) Signed-off-by: Rusty Russell --- bitcoin/pubkey.c | 16 +++++----- bitcoin/pubkey.h | 4 +-- bitcoin/script.c | 6 ++-- common/bolt11.c | 4 +-- common/initial_commit_tx.c | 4 +-- common/key_derive.c | 44 +++++++++++++-------------- common/sphinx.c | 8 ++--- connectd/connectd.c | 4 +-- connectd/handshake.c | 12 ++++---- hsmd/hsmd.c | 4 +-- lightningd/gossip_control.c | 4 +-- lightningd/json.c | 2 +- lightningd/options.c | 2 +- lightningd/test/run-find_my_abspath.c | 2 +- onchaind/onchaind.c | 2 +- wallet/db.c | 16 +++++----- wallet/txfilter.c | 2 +- wallet/txfilter.h | 2 +- wire/fromwire.c | 2 +- wire/test/run-peer-wire.c | 2 +- wire/towire.c | 2 +- 21 files changed, 72 insertions(+), 72 deletions(-) diff --git a/bitcoin/pubkey.c b/bitcoin/pubkey.c index f84900378..345e50e1a 100644 --- a/bitcoin/pubkey.c +++ b/bitcoin/pubkey.c @@ -8,7 +8,7 @@ bool pubkey_from_der(const u8 *der, size_t len, struct pubkey *key) { - if (len != PUBKEY_DER_LEN) + if (len != PUBKEY_CMPR_LEN) return false; if (!secp256k1_ec_pubkey_parse(secp256k1_ctx, &key->pubkey, @@ -18,14 +18,14 @@ bool pubkey_from_der(const u8 *der, size_t len, struct pubkey *key) return true; } -void pubkey_to_der(u8 der[PUBKEY_DER_LEN], const struct pubkey *key) +void pubkey_to_der(u8 der[PUBKEY_CMPR_LEN], const struct pubkey *key) { - size_t outlen = PUBKEY_DER_LEN; + size_t outlen = PUBKEY_CMPR_LEN; if (!secp256k1_ec_pubkey_serialize(secp256k1_ctx, der, &outlen, &key->pubkey, SECP256K1_EC_COMPRESSED)) abort(); - assert(outlen == PUBKEY_DER_LEN); + assert(outlen == PUBKEY_CMPR_LEN); } bool pubkey_from_secret(const struct secret *secret, struct pubkey *key) @@ -45,7 +45,7 @@ bool pubkey_from_privkey(const struct privkey *privkey, bool pubkey_from_hexstr(const char *derstr, size_t slen, struct pubkey *key) { size_t dlen; - unsigned char der[PUBKEY_DER_LEN]; + unsigned char der[PUBKEY_CMPR_LEN]; dlen = hex_data_size(slen); if (dlen != sizeof(der)) @@ -59,7 +59,7 @@ bool pubkey_from_hexstr(const char *derstr, size_t slen, struct pubkey *key) char *pubkey_to_hexstr(const tal_t *ctx, const struct pubkey *key) { - unsigned char der[PUBKEY_DER_LEN]; + unsigned char der[PUBKEY_CMPR_LEN]; pubkey_to_der(der, key); return tal_hexstr(ctx, der, sizeof(der)); @@ -68,7 +68,7 @@ REGISTER_TYPE_TO_STRING(pubkey, pubkey_to_hexstr); char *secp256k1_pubkey_to_hexstr(const tal_t *ctx, const secp256k1_pubkey *key) { - unsigned char der[PUBKEY_DER_LEN]; + unsigned char der[PUBKEY_CMPR_LEN]; size_t outlen = sizeof(der); if (!secp256k1_ec_pubkey_serialize(secp256k1_ctx, der, &outlen, key, SECP256K1_EC_COMPRESSED)) @@ -88,7 +88,7 @@ int pubkey_cmp(const struct pubkey *a, const struct pubkey *b) void pubkey_to_hash160(const struct pubkey *pk, struct ripemd160 *hash) { - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; struct sha256 h; pubkey_to_der(der, pk); diff --git a/bitcoin/pubkey.h b/bitcoin/pubkey.h index 18a951e77..16f3f6693 100644 --- a/bitcoin/pubkey.h +++ b/bitcoin/pubkey.h @@ -11,7 +11,7 @@ struct privkey; struct secret; -#define PUBKEY_DER_LEN 33 +#define PUBKEY_CMPR_LEN 33 struct pubkey { /* Unpacked pubkey (as used by libsecp256k1 internally) */ @@ -40,7 +40,7 @@ bool pubkey_from_privkey(const struct privkey *privkey, bool pubkey_from_der(const u8 *der, size_t len, struct pubkey *key); /* Pubkey to DER encoding: must be valid pubkey. */ -void pubkey_to_der(u8 der[PUBKEY_DER_LEN], const struct pubkey *key); +void pubkey_to_der(u8 der[PUBKEY_CMPR_LEN], const struct pubkey *key); /* Compare the keys `a` and `b`. Return <0 if `a`<`b`, 0 if equal and >0 otherwise */ int pubkey_cmp(const struct pubkey *a, const struct pubkey *b); diff --git a/bitcoin/script.c b/bitcoin/script.c index 181dbcbb3..33e271469 100644 --- a/bitcoin/script.c +++ b/bitcoin/script.c @@ -104,7 +104,7 @@ static void add_number(u8 **script, u32 num) static void add_push_key(u8 **scriptp, const struct pubkey *key) { - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; pubkey_to_der(der, key); add_push_bytes(scriptp, der, sizeof(der)); @@ -120,7 +120,7 @@ static void add_push_sig(u8 **scriptp, const struct bitcoin_signature *sig) static u8 *stack_key(const tal_t *ctx, const struct pubkey *key) { - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; pubkey_to_der(der, key); return tal_dup_arr(ctx, u8, der, sizeof(der), 0); @@ -305,7 +305,7 @@ u8 *scriptpubkey_p2wpkh_derkey(const tal_t *ctx, const u8 der[33]) struct ripemd160 h; add_op(&script, OP_0); - hash160(&h, der, PUBKEY_DER_LEN); + hash160(&h, der, PUBKEY_CMPR_LEN); add_push_bytes(&script, &h, sizeof(h)); return script; } diff --git a/common/bolt11.c b/common/bolt11.c index ccbaf181c..58f9c63bc 100644 --- a/common/bolt11.c +++ b/common/bolt11.c @@ -279,7 +279,7 @@ static char *decode_n(struct bolt11 *b11, u5 **data, size_t *data_len, size_t data_length, bool *have_n) { - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; if (*have_n) return unknown_field(b11, hu5, data, data_len, 'n', @@ -787,7 +787,7 @@ static void encode_h(u5 **data, const struct sha256 *hash) static void encode_n(u5 **data, const struct pubkey *id) { - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; pubkey_to_der(der, id); push_field(data, 'n', der, sizeof(der) * CHAR_BIT); diff --git a/common/initial_commit_tx.c b/common/initial_commit_tx.c index ac61658a5..3f520145d 100644 --- a/common/initial_commit_tx.c +++ b/common/initial_commit_tx.c @@ -18,12 +18,12 @@ u64 commit_number_obscurer(const struct pubkey *opener_payment_basepoint, const struct pubkey *accepter_payment_basepoint) { - u8 ders[PUBKEY_DER_LEN * 2]; + u8 ders[PUBKEY_CMPR_LEN * 2]; struct sha256 sha; be64 obscurer = 0; pubkey_to_der(ders, opener_payment_basepoint); - pubkey_to_der(ders + PUBKEY_DER_LEN, accepter_payment_basepoint); + pubkey_to_der(ders + PUBKEY_CMPR_LEN, accepter_payment_basepoint); sha256(&sha, ders, sizeof(ders)); /* Lower 48 bits */ diff --git a/common/key_derive.c b/common/key_derive.c index a1e3b6248..dc5ae4ad4 100644 --- a/common/key_derive.c +++ b/common/key_derive.c @@ -25,16 +25,16 @@ bool derive_simple_key(const struct pubkey *basepoint, struct pubkey *key) { struct sha256 sha; - unsigned char der_keys[PUBKEY_DER_LEN * 2]; + unsigned char der_keys[PUBKEY_CMPR_LEN * 2]; pubkey_to_der(der_keys, per_commitment_point); - pubkey_to_der(der_keys + PUBKEY_DER_LEN, basepoint); + pubkey_to_der(der_keys + PUBKEY_CMPR_LEN, basepoint); sha256(&sha, der_keys, sizeof(der_keys)); #ifdef SUPERVERBOSE printf("# SHA256(per_commitment_point || basepoint)\n"); printf("# => SHA256(0x%s || 0x%s)\n", - tal_hexstr(tmpctx, der_keys, PUBKEY_DER_LEN), - tal_hexstr(tmpctx, der_keys + PUBKEY_DER_LEN, PUBKEY_DER_LEN)); + tal_hexstr(tmpctx, der_keys, PUBKEY_CMPR_LEN), + tal_hexstr(tmpctx, der_keys + PUBKEY_CMPR_LEN, PUBKEY_CMPR_LEN)); printf("# = 0x%s\n", tal_hexstr(tmpctx, &sha, sizeof(sha))); #endif @@ -66,16 +66,16 @@ bool derive_simple_privkey(const struct secret *base_secret, struct privkey *key) { struct sha256 sha; - unsigned char der_keys[PUBKEY_DER_LEN * 2]; + unsigned char der_keys[PUBKEY_CMPR_LEN * 2]; pubkey_to_der(der_keys, per_commitment_point); - pubkey_to_der(der_keys + PUBKEY_DER_LEN, basepoint); + pubkey_to_der(der_keys + PUBKEY_CMPR_LEN, basepoint); sha256(&sha, der_keys, sizeof(der_keys)); #ifdef SUPERVERBOSE printf("# SHA256(per_commitment_point || basepoint)\n"); printf("# => SHA256(0x%s || 0x%s)\n", - tal_hexstr(tmpctx, der_keys, PUBKEY_DER_LEN), - tal_hexstr(tmpctx, der_keys + PUBKEY_DER_LEN, PUBKEY_DER_LEN)); + tal_hexstr(tmpctx, der_keys, PUBKEY_CMPR_LEN), + tal_hexstr(tmpctx, der_keys + PUBKEY_CMPR_LEN, PUBKEY_CMPR_LEN)); printf("# = 0x%s\n", tal_hexstr(tmpctx, &sha, sizeof(sha))); #endif @@ -117,18 +117,18 @@ bool derive_revocation_key(const struct pubkey *basepoint, struct pubkey *key) { struct sha256 sha; - unsigned char der_keys[PUBKEY_DER_LEN * 2]; + unsigned char der_keys[PUBKEY_CMPR_LEN * 2]; secp256k1_pubkey add[2]; const secp256k1_pubkey *args[2]; pubkey_to_der(der_keys, basepoint); - pubkey_to_der(der_keys + PUBKEY_DER_LEN, per_commitment_point); + pubkey_to_der(der_keys + PUBKEY_CMPR_LEN, per_commitment_point); sha256(&sha, der_keys, sizeof(der_keys)); #ifdef SUPERVERBOSE printf("# SHA256(revocation_basepoint || per_commitment_point)\n"); printf("# => SHA256(0x%s || 0x%s)\n", - tal_hexstr(tmpctx, der_keys, PUBKEY_DER_LEN), - tal_hexstr(tmpctx, der_keys + PUBKEY_DER_LEN, PUBKEY_DER_LEN)); + tal_hexstr(tmpctx, der_keys, PUBKEY_CMPR_LEN), + tal_hexstr(tmpctx, der_keys + PUBKEY_CMPR_LEN, PUBKEY_CMPR_LEN)); printf("# = 0x%s\n", tal_hexstr(tmpctx, sha.u.u8, sizeof(sha.u.u8))), #endif @@ -141,13 +141,13 @@ bool derive_revocation_key(const struct pubkey *basepoint, #endif pubkey_to_der(der_keys, per_commitment_point); - pubkey_to_der(der_keys + PUBKEY_DER_LEN, basepoint); + pubkey_to_der(der_keys + PUBKEY_CMPR_LEN, basepoint); sha256(&sha, der_keys, sizeof(der_keys)); #ifdef SUPERVERBOSE printf("# SHA256(per_commitment_point || revocation_basepoint)\n"); printf("# => SHA256(0x%s || 0x%s)\n", - tal_hexstr(tmpctx, der_keys, PUBKEY_DER_LEN), - tal_hexstr(tmpctx, der_keys + PUBKEY_DER_LEN, PUBKEY_DER_LEN)); + tal_hexstr(tmpctx, der_keys, PUBKEY_CMPR_LEN), + tal_hexstr(tmpctx, der_keys + PUBKEY_CMPR_LEN, PUBKEY_CMPR_LEN)); printf("# = 0x%s\n", tal_hexstr(tmpctx, sha.u.u8, sizeof(sha.u.u8))), #endif @@ -188,17 +188,17 @@ bool derive_revocation_privkey(const struct secret *base_secret, struct privkey *key) { struct sha256 sha; - unsigned char der_keys[PUBKEY_DER_LEN * 2]; + unsigned char der_keys[PUBKEY_CMPR_LEN * 2]; struct secret part2; pubkey_to_der(der_keys, basepoint); - pubkey_to_der(der_keys + PUBKEY_DER_LEN, per_commitment_point); + pubkey_to_der(der_keys + PUBKEY_CMPR_LEN, per_commitment_point); sha256(&sha, der_keys, sizeof(der_keys)); #ifdef SUPERVERBOSE printf("# SHA256(revocation_basepoint || per_commitment_point)\n"); printf("# => SHA256(0x%s || 0x%s)\n", - tal_hexstr(tmpctx, der_keys, PUBKEY_DER_LEN), - tal_hexstr(tmpctx, der_keys + PUBKEY_DER_LEN, PUBKEY_DER_LEN)); + tal_hexstr(tmpctx, der_keys, PUBKEY_CMPR_LEN), + tal_hexstr(tmpctx, der_keys + PUBKEY_CMPR_LEN, PUBKEY_CMPR_LEN)); printf("# = 0x%s\n", tal_hexstr(tmpctx, sha.u.u8, sizeof(sha.u.u8))), #endif @@ -214,13 +214,13 @@ bool derive_revocation_privkey(const struct secret *base_secret, #endif pubkey_to_der(der_keys, per_commitment_point); - pubkey_to_der(der_keys + PUBKEY_DER_LEN, basepoint); + pubkey_to_der(der_keys + PUBKEY_CMPR_LEN, basepoint); sha256(&sha, der_keys, sizeof(der_keys)); #ifdef SUPERVERBOSE printf("# SHA256(per_commitment_point || revocation_basepoint)\n"); printf("# => SHA256(0x%s || 0x%s)\n", - tal_hexstr(tmpctx, der_keys, PUBKEY_DER_LEN), - tal_hexstr(tmpctx, der_keys + PUBKEY_DER_LEN, PUBKEY_DER_LEN)); + tal_hexstr(tmpctx, der_keys, PUBKEY_CMPR_LEN), + tal_hexstr(tmpctx, der_keys + PUBKEY_CMPR_LEN, PUBKEY_CMPR_LEN)); printf("# = 0x%s\n", tal_hexstr(tmpctx, sha.u.u8, sizeof(sha.u.u8))), #endif diff --git a/common/sphinx.c b/common/sphinx.c index 61288809d..03b226340 100644 --- a/common/sphinx.c +++ b/common/sphinx.c @@ -59,7 +59,7 @@ u8 *serialize_onionpacket( { u8 *dst = tal_arr(ctx, u8, TOTAL_PACKET_SIZE); - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; int p = 0; pubkey_to_der(der, &m->ephemeralkey); @@ -77,7 +77,7 @@ struct onionpacket *parse_onionpacket(const tal_t *ctx, { struct onionpacket *m; int p = 0; - u8 rawEphemeralkey[PUBKEY_DER_LEN]; + u8 rawEphemeralkey[PUBKEY_CMPR_LEN]; assert(srclen == TOTAL_PACKET_SIZE); @@ -186,7 +186,7 @@ static void compute_blinding_factor(const struct pubkey *key, u8 res[BLINDING_FACTOR_SIZE]) { struct sha256_ctx ctx; - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; struct sha256 temp; pubkey_to_der(der, key); @@ -289,7 +289,7 @@ static struct hop_params *generate_hop_params( /* Now hash temp and store it. This requires us to * DER-serialize first and then skip the sign byte. */ - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; pubkey_to_der(der, &temp); struct sha256 h; sha256(&h, der, sizeof(der)); diff --git a/connectd/connectd.c b/connectd/connectd.c index ab1a9d9a1..9b45ab2df 100644 --- a/connectd/connectd.c +++ b/connectd/connectd.c @@ -1191,11 +1191,11 @@ static struct io_plan *connect_activate(struct io_conn *conn, static const char *seedname(const tal_t *ctx, const struct pubkey *id) { char bech32[100]; - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; u5 *data = tal_arr(ctx, u5, 0); pubkey_to_der(der, id); - bech32_push_bits(&data, der, PUBKEY_DER_LEN*8); + bech32_push_bits(&data, der, PUBKEY_CMPR_LEN*8); bech32_encode(bech32, "ln", data, tal_count(data), sizeof(bech32)); return tal_fmt(ctx, "%s.lseed.bitcoinstats.com", bech32); } diff --git a/connectd/handshake.c b/connectd/handshake.c index 1040af9c2..63788de84 100644 --- a/connectd/handshake.c +++ b/connectd/handshake.c @@ -39,7 +39,7 @@ enum bolt8_side { */ struct act_one { u8 v; - u8 pubkey[PUBKEY_DER_LEN]; + u8 pubkey[PUBKEY_CMPR_LEN]; u8 tag[crypto_aead_chacha20poly1305_ietf_ABYTES]; }; @@ -68,7 +68,7 @@ static inline void check_act_one(const struct act_one *act1) */ struct act_two { u8 v; - u8 pubkey[PUBKEY_DER_LEN]; + u8 pubkey[PUBKEY_CMPR_LEN]; u8 tag[crypto_aead_chacha20poly1305_ietf_ABYTES]; }; @@ -98,7 +98,7 @@ static inline void check_act_two(const struct act_two *act2) */ struct act_three { u8 v; - u8 ciphertext[PUBKEY_DER_LEN + crypto_aead_chacha20poly1305_ietf_ABYTES]; + u8 ciphertext[PUBKEY_CMPR_LEN + crypto_aead_chacha20poly1305_ietf_ABYTES]; u8 tag[crypto_aead_chacha20poly1305_ietf_ABYTES]; }; @@ -211,7 +211,7 @@ static void sha_mix_in(struct sha256 *h, const void *data, size_t len) /* h = SHA-256(h || pub.serializeCompressed()) */ static void sha_mix_in_key(struct sha256 *h, const struct pubkey *key) { - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; size_t len = sizeof(der); secp256k1_ec_pubkey_serialize(secp256k1_ctx, der, &len, &key->pubkey, @@ -442,7 +442,7 @@ static struct handshake *new_handshake(const tal_t *ctx, static struct io_plan *act_three_initiator(struct io_conn *conn, struct handshake *h) { - u8 spub[PUBKEY_DER_LEN]; + u8 spub[PUBKEY_CMPR_LEN]; size_t len = sizeof(spub); SUPERVERBOSE("Initiator: Act 3"); @@ -689,7 +689,7 @@ static struct io_plan *act_one_initiator(struct io_conn *conn, static struct io_plan *act_three_responder2(struct io_conn *conn, struct handshake *h) { - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; SUPERVERBOSE("input: 0x%s", tal_hexstr(tmpctx, &h->act3, ACT_THREE_SIZE)); diff --git a/hsmd/hsmd.c b/hsmd/hsmd.c index 417a7387d..2f3062589 100644 --- a/hsmd/hsmd.c +++ b/hsmd/hsmd.c @@ -327,7 +327,7 @@ static void get_channel_seed(const struct pubkey *peer_id, u64 dbid, struct secret *channel_seed) { struct secret channel_base; - u8 input[PUBKEY_DER_LEN + sizeof(dbid)]; + u8 input[PUBKEY_CMPR_LEN + sizeof(dbid)]; /*~ Again, "per-peer" should be "per-channel", but Hysterical Raisins */ const char *info = "per-peer seed"; @@ -341,7 +341,7 @@ static void get_channel_seed(const struct pubkey *peer_id, u64 dbid, /*~ For all that talk about platform-independence, note that this * field is endian-dependent! But let's face it, little-endian won. * In related news, we don't support EBCDIC or middle-endian. */ - memcpy(input + PUBKEY_DER_LEN, &dbid, sizeof(dbid)); + memcpy(input + PUBKEY_CMPR_LEN, &dbid, sizeof(dbid)); hkdf_sha256(channel_seed, sizeof(*channel_seed), input, sizeof(input), diff --git a/lightningd/gossip_control.c b/lightningd/gossip_control.c index e316d6a34..129123502 100644 --- a/lightningd/gossip_control.c +++ b/lightningd/gossip_control.c @@ -191,8 +191,8 @@ static void json_add_raw_pubkey(struct json_stream *response, const u8 raw_pubkey[sizeof(struct pubkey)]) { secp256k1_pubkey pubkey; - u8 der[PUBKEY_DER_LEN]; - size_t outlen = PUBKEY_DER_LEN; + u8 der[PUBKEY_CMPR_LEN]; + size_t outlen = PUBKEY_CMPR_LEN; memcpy(&pubkey, raw_pubkey, sizeof(pubkey)); if (!secp256k1_ec_pubkey_serialize(secp256k1_ctx, der, &outlen, diff --git a/lightningd/json.c b/lightningd/json.c index 70fdbaf21..34f71e24e 100644 --- a/lightningd/json.c +++ b/lightningd/json.c @@ -54,7 +54,7 @@ void json_add_pubkey(struct json_stream *response, const char *fieldname, const struct pubkey *key) { - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; pubkey_to_der(der, key); json_add_hex(response, fieldname, der, sizeof(der)); diff --git a/lightningd/options.c b/lightningd/options.c index 4f6441f60..486c6ffa1 100644 --- a/lightningd/options.c +++ b/lightningd/options.c @@ -845,7 +845,7 @@ static const char *codename_noun[] void setup_color_and_alias(struct lightningd *ld) { - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; pubkey_to_der(der, &ld->id); if (!ld->rgb) diff --git a/lightningd/test/run-find_my_abspath.c b/lightningd/test/run-find_my_abspath.c index 0a09c6452..f8b8e3cda 100644 --- a/lightningd/test/run-find_my_abspath.c +++ b/lightningd/test/run-find_my_abspath.c @@ -155,7 +155,7 @@ void timer_expired(tal_t *ctx UNNEEDED, struct timer *timer UNNEEDED) { fprintf(stderr, "timer_expired called!\n"); abort(); } /* Generated stub for txfilter_add_derkey */ void txfilter_add_derkey(struct txfilter *filter UNNEEDED, - const u8 derkey[PUBKEY_DER_LEN]) + const u8 derkey[PUBKEY_CMPR_LEN]) { fprintf(stderr, "txfilter_add_derkey called!\n"); abort(); } /* Generated stub for txfilter_new */ struct txfilter *txfilter_new(const tal_t *ctx UNNEEDED) diff --git a/onchaind/onchaind.c b/onchaind/onchaind.c index 3ce2648de..868e645fe 100644 --- a/onchaind/onchaind.c +++ b/onchaind/onchaind.c @@ -1872,7 +1872,7 @@ static void steal_htlc(struct tracked_output *out) { struct bitcoin_tx *tx; enum tx_type tx_type = OUR_PENALTY_TX; - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; /* BOLT #3: * diff --git a/wallet/db.c b/wallet/db.c index 859b556fc..98cae3b06 100644 --- a/wallet/db.c +++ b/wallet/db.c @@ -939,13 +939,13 @@ bool sqlite3_column_signature(sqlite3_stmt *stmt, int col, bool sqlite3_column_pubkey(sqlite3_stmt *stmt, int col, struct pubkey *dest) { - assert(sqlite3_column_bytes(stmt, col) == PUBKEY_DER_LEN); - return pubkey_from_der(sqlite3_column_blob(stmt, col), PUBKEY_DER_LEN, dest); + assert(sqlite3_column_bytes(stmt, col) == PUBKEY_CMPR_LEN); + return pubkey_from_der(sqlite3_column_blob(stmt, col), PUBKEY_CMPR_LEN, dest); } bool sqlite3_bind_pubkey(sqlite3_stmt *stmt, int col, const struct pubkey *pk) { - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; pubkey_to_der(der, pk); int err = sqlite3_bind_blob(stmt, col, der, sizeof(der), SQLITE_TRANSIENT); return err == SQLITE_OK; @@ -964,10 +964,10 @@ bool sqlite3_bind_pubkey_array(sqlite3_stmt *stmt, int col, } n = tal_count(pks); - ders = tal_arr(NULL, u8, n * PUBKEY_DER_LEN); + ders = tal_arr(NULL, u8, n * PUBKEY_CMPR_LEN); for (i = 0; i < n; ++i) - pubkey_to_der(&ders[i * PUBKEY_DER_LEN], &pks[i]); + pubkey_to_der(&ders[i * PUBKEY_CMPR_LEN], &pks[i]); int err = sqlite3_bind_blob(stmt, col, ders, tal_count(ders), SQLITE_TRANSIENT); tal_free(ders); @@ -984,13 +984,13 @@ struct pubkey *sqlite3_column_pubkey_array(const tal_t *ctx, if (sqlite3_column_type(stmt, col) == SQLITE_NULL) return NULL; - n = sqlite3_column_bytes(stmt, col) / PUBKEY_DER_LEN; - assert(n * PUBKEY_DER_LEN == (size_t)sqlite3_column_bytes(stmt, col)); + n = sqlite3_column_bytes(stmt, col) / PUBKEY_CMPR_LEN; + assert(n * PUBKEY_CMPR_LEN == (size_t)sqlite3_column_bytes(stmt, col)); ret = tal_arr(ctx, struct pubkey, n); ders = sqlite3_column_blob(stmt, col); for (i = 0; i < n; ++i) { - if (!pubkey_from_der(&ders[i * PUBKEY_DER_LEN], PUBKEY_DER_LEN, &ret[i])) + if (!pubkey_from_der(&ders[i * PUBKEY_CMPR_LEN], PUBKEY_CMPR_LEN, &ret[i])) return tal_free(ret); } diff --git a/wallet/txfilter.c b/wallet/txfilter.c index 801866b9c..2e2fb6a31 100644 --- a/wallet/txfilter.c +++ b/wallet/txfilter.c @@ -59,7 +59,7 @@ void txfilter_add_scriptpubkey(struct txfilter *filter, const u8 *script TAKES) } void txfilter_add_derkey(struct txfilter *filter, - const u8 derkey[PUBKEY_DER_LEN]) + const u8 derkey[PUBKEY_CMPR_LEN]) { u8 *skp, *p2sh; diff --git a/wallet/txfilter.h b/wallet/txfilter.h index c46df56c8..16471e086 100644 --- a/wallet/txfilter.h +++ b/wallet/txfilter.h @@ -27,7 +27,7 @@ struct txfilter *txfilter_new(const tal_t *ctx); * scriptpubkey for both raw p2wpkh and p2wpkh wrapped in p2sh. */ void txfilter_add_derkey(struct txfilter *filter, - const u8 derkey[PUBKEY_DER_LEN]); + const u8 derkey[PUBKEY_CMPR_LEN]); /** * txfilter_match -- Check whether the tx matches the filter diff --git a/wire/fromwire.c b/wire/fromwire.c index abba9478d..3c993cb8d 100644 --- a/wire/fromwire.c +++ b/wire/fromwire.c @@ -119,7 +119,7 @@ u64 fromwire_var_int(const u8 **cursor, size_t *max) void fromwire_pubkey(const u8 **cursor, size_t *max, struct pubkey *pubkey) { - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; if (!fromwire(cursor, max, der, sizeof(der))) return; diff --git a/wire/test/run-peer-wire.c b/wire/test/run-peer-wire.c index c55506fb8..a26115be3 100644 --- a/wire/test/run-peer-wire.c +++ b/wire/test/run-peer-wire.c @@ -37,7 +37,7 @@ void fromwire_pad(const u8 **cursor, size_t *max, size_t num) /* memsetting pubkeys doesn't work */ static void set_pubkey(struct pubkey *key) { - u8 der[PUBKEY_DER_LEN]; + u8 der[PUBKEY_CMPR_LEN]; memset(der, 2, sizeof(der)); assert(pubkey_from_der(der, sizeof(der), key)); } diff --git a/wire/towire.c b/wire/towire.c index 2f36d5f5c..f6d21e949 100644 --- a/wire/towire.c +++ b/wire/towire.c @@ -72,7 +72,7 @@ void towire_var_int(u8 **pptr, const u64 val) void towire_pubkey(u8 **pptr, const struct pubkey *pubkey) { - u8 output[PUBKEY_DER_LEN]; + u8 output[PUBKEY_CMPR_LEN]; size_t outputlen = sizeof(output); secp256k1_ec_pubkey_serialize(secp256k1_ctx, output, &outputlen,