Skip to content

Commit

Permalink
Remove point32.
Browse files Browse the repository at this point in the history
The x-only dream is dead.  Remove all trace.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Oct 3, 2022
1 parent 398ad64 commit bd75295
Show file tree
Hide file tree
Showing 20 changed files with 8 additions and 226 deletions.
37 changes: 0 additions & 37 deletions bitcoin/pubkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,40 +125,3 @@ void towire_pubkey(u8 **pptr, const struct pubkey *pubkey)

towire(pptr, output, outputlen);
}

void fromwire_point32(const u8 **cursor, size_t *max, struct point32 *point32)
{
u8 raw[33];
struct pubkey pk;

raw[0] = SECP256K1_TAG_PUBKEY_EVEN;
if (!fromwire(cursor, max, raw + 1, sizeof(raw) - 1))
return;

if (!pubkey_from_der(raw, sizeof(raw), &pk)) {
SUPERVERBOSE("not a valid point");
fromwire_fail(cursor, max);
} else
point32->pubkey = pk.pubkey;
}

void towire_point32(u8 **pptr, const struct point32 *point32)
{
u8 output[33];
struct pubkey pk;

pk.pubkey = point32->pubkey;
pubkey_to_der(output, &pk);
towire(pptr, output + 1, sizeof(output) - 1);
}

static char *point32_to_hexstr(const tal_t *ctx, const struct point32 *point32)
{
u8 output[33];
struct pubkey pk;

pk.pubkey = point32->pubkey;
pubkey_to_der(output, &pk);
return tal_hexstr(ctx, output + 1, sizeof(output) - 1);
}
REGISTER_TYPE_TO_STRING(point32, point32_to_hexstr);
17 changes: 0 additions & 17 deletions bitcoin/pubkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ struct pubkey {
/* Define pubkey_eq (no padding) */
STRUCTEQ_DEF(pubkey, 0, pubkey.data);

/* FIXME: This is for the deprecated offers: it's represented x-only there */
struct point32 {
/* Unpacked pubkey (as used by libsecp256k1 internally) */
secp256k1_pubkey pubkey;
};
/* Define point32_eq (no padding) */
STRUCTEQ_DEF(point32, 0, pubkey.data);

/* Convert from hex string of DER (scriptPubKey from validateaddress) */
bool pubkey_from_hexstr(const char *derstr, size_t derlen, struct pubkey *key);

Expand Down Expand Up @@ -64,13 +56,4 @@ void pubkey_to_hash160(const struct pubkey *pk, struct ripemd160 *hash);
void towire_pubkey(u8 **pptr, const struct pubkey *pubkey);
void fromwire_pubkey(const u8 **cursor, size_t *max, struct pubkey *pubkey);

/* FIXME: Old spec uses pubkey32 */
#define pubkey32 point32
#define towire_pubkey32 towire_point32
#define fromwire_pubkey32 fromwire_point32

/* marshal/unmarshal functions */
void towire_point32(u8 **pptr, const struct point32 *pubkey);
void fromwire_point32(const u8 **cursor, size_t *max, struct point32 *pubkey);

#endif /* LIGHTNING_BITCOIN_PUBKEY_H */
1 change: 0 additions & 1 deletion common/gossmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <common/fp16.h>

struct node_id;
struct point32;

struct gossmap_node {
/* Offset in memory map for node_announce, or 0. */
Expand Down
12 changes: 0 additions & 12 deletions common/json_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,18 +415,6 @@ void json_add_pubkey(struct json_stream *response,
json_add_hex(response, fieldname, der, sizeof(der));
}

void json_add_point32(struct json_stream *response,
const char *fieldname,
const struct point32 *key)
{
struct pubkey pk;
u8 der[PUBKEY_CMPR_LEN];

pk.pubkey = key->pubkey;
pubkey_to_der(der, &pk);
json_add_hex(response, fieldname, der + 1, sizeof(der) - 1);
}

void json_add_bip340sig(struct json_stream *response,
const char *fieldname,
const struct bip340sig *sig)
Expand Down
6 changes: 0 additions & 6 deletions common/json_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ struct io_conn;
struct log;
struct json_escape;
struct pubkey;
struct point32;
struct bip340sig;
struct secret;
struct node_id;
Expand Down Expand Up @@ -271,11 +270,6 @@ void json_add_pubkey(struct json_stream *response,
const char *fieldname,
const struct pubkey *key);

/* '"fieldname" : "89abcdef..."' or "89abcdef..." if fieldname is NULL */
void json_add_point32(struct json_stream *response,
const char *fieldname,
const struct point32 *key);

/* '"fieldname" : "89abcdef..."' or "89abcdef..." if fieldname is NULL */
void json_add_bip340sig(struct json_stream *response,
const char *fieldname,
Expand Down
10 changes: 0 additions & 10 deletions common/node_id.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ bool pubkey_from_node_id(struct pubkey *key, const struct node_id *id)
sizeof(id->k));
}

WARN_UNUSED_RESULT
bool point32_from_node_id(struct point32 *key, const struct node_id *id)
{
struct pubkey k;
if (!pubkey_from_node_id(&k, id))
return false;
key->pubkey = k.pubkey;
return true;
}

/* It's valid if we can convert to a real pubkey. */
bool node_id_valid(const struct node_id *id)
{
Expand Down
4 changes: 0 additions & 4 deletions common/node_id.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ void node_id_from_pubkey(struct node_id *id, const struct pubkey *key);
WARN_UNUSED_RESULT
bool pubkey_from_node_id(struct pubkey *key, const struct node_id *id);

/* Returns false if not a valid pubkey: relatively expensive */
WARN_UNUSED_RESULT
bool point32_from_node_id(struct point32 *key, const struct node_id *id);

/* Convert to hex string of SEC1 encoding. */
char *node_id_to_hexstr(const tal_t *ctx, const struct node_id *id);

Expand Down
1 change: 0 additions & 1 deletion common/type_to_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
/* This must match the type_to_string_ cases. */
union printable_types {
const struct pubkey *pubkey;
const struct point32 *point32;
const struct node_id *node_id;
const struct bitcoin_txid *bitcoin_txid;
const struct bitcoin_blkid *bitcoin_blkid;
Expand Down
1 change: 0 additions & 1 deletion contrib/pyln-proto/pyln/proto/message/fundamental_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ def fundamental_types() -> List[FieldType]:
# Extra types added in offers draft:
IntegerType('utf8', 1, 'B'),
FundamentalHexType('bip340sig', 64),
FundamentalHexType('point32', 32),
]


Expand Down
4 changes: 0 additions & 4 deletions contrib/pyln-proto/tests/test_fundamental_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ def test_fundamental_types():
'2122232425262728292a2b2c2d2e2f30'
'3132333435363738393a3b3c3d3e3f40',
bytes(range(1, 65))]],
'point32': [['02030405060708090a0b0c0d0e0f10'
'1112131415161718191a1b1c1d1e1f20'
'21',
bytes(range(2, 34))]],
}

untested = set()
Expand Down
9 changes: 0 additions & 9 deletions contrib/pyln-testing/pyln/testing/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,6 @@ def is_32byte_hex(self, instance):
"""
return self.is_type(instance, "hex") and len(instance) == 64

def is_point32(checker, instance):
"""x-only BIP-340 public key"""
if not checker.is_type(instance, "hex"):
return False
if len(instance) != 64:
return False
return True

def is_signature(checker, instance):
"""DER encoded secp256k1 ECDSA signature"""
if not checker.is_type(instance, "hex"):
Expand Down Expand Up @@ -414,7 +406,6 @@ def is_msat_or_any(checker, instance):
"txid": is_txid,
"signature": is_signature,
"bip340sig": is_bip340sig,
"point32": is_point32,
"short_channel_id": is_short_channel_id,
"short_channel_id_dir": is_short_channel_id_dir,
"outpoint": is_outpoint,
Expand Down
1 change: 0 additions & 1 deletion devtools/print_wire.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ PRINTWIRE_STRUCT_TYPE_TO_STRING(bitcoin_blkid)
PRINTWIRE_STRUCT_TYPE_TO_STRING(bitcoin_txid)
PRINTWIRE_STRUCT_TYPE_TO_STRING(channel_id)
PRINTWIRE_STRUCT_TYPE_TO_STRING(node_id)
PRINTWIRE_STRUCT_TYPE_TO_STRING(point32)
PRINTWIRE_STRUCT_TYPE_TO_STRING(preimage)
PRINTWIRE_STRUCT_TYPE_TO_STRING(pubkey)
PRINTWIRE_STRUCT_TYPE_TO_STRING(sha256)
Expand Down
1 change: 0 additions & 1 deletion devtools/print_wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ bool printwire_bitcoin_txid(const char *fieldname, const u8 **cursor, size_t *pl
bool printwire_channel_id(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_amount_sat(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_amount_msat(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_point32(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_preimage(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_pubkey(const char *fieldname, const u8 **cursor, size_t *plen);
bool printwire_node_id(const char *fieldname, const u8 **cursor, size_t *plen);
Expand Down
19 changes: 3 additions & 16 deletions hsmd/libhsmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,29 +221,16 @@ static void node_key(struct privkey *node_privkey, struct pubkey *node_id)
#endif
}

/*~ This returns the secret and/or public x-only key for this node. */
static void node_schnorrkey(secp256k1_keypair *node_keypair,
struct point32 *node_id32)
/*~ This returns the secret key for this node. */
static void node_schnorrkey(secp256k1_keypair *node_keypair)
{
secp256k1_keypair unused_kp;
struct privkey node_privkey;

if (!node_keypair)
node_keypair = &unused_kp;

node_key(&node_privkey, NULL);
if (secp256k1_keypair_create(secp256k1_ctx, node_keypair,
node_privkey.secret.data) != 1)
hsmd_status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Failed to derive keypair");

if (node_id32) {
if (secp256k1_keypair_pub(secp256k1_ctx,
&node_id32->pubkey,
node_keypair) != 1)
hsmd_status_failed(STATUS_FAIL_INTERNAL_ERROR,
"Failed to derive keypair pub");
}
}

/*~ This secret is the basis for all per-channel secrets: the per-channel seeds
Expand Down Expand Up @@ -634,7 +621,7 @@ static u8 *handle_sign_bolt12(struct hsmd_client *c, const u8 *msg_in)
sighash_from_merkle(messagename, fieldname, &merkle, &sha);

if (!publictweak) {
node_schnorrkey(&kp, NULL);
node_schnorrkey(&kp);
} else {
/* If we're tweaking key, we use bolt12 key */
struct privkey tweakedkey;
Expand Down
4 changes: 2 additions & 2 deletions plugins/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PLUGIN_PAY_SRC := plugins/pay.c plugins/pay_point32.c
PLUGIN_PAY_HEADER := plugins/pay_point32.h
PLUGIN_PAY_SRC := plugins/pay.c
PLUGIN_PAY_HEADER :=
PLUGIN_PAY_OBJS := $(PLUGIN_PAY_SRC:.c=.o)

PLUGIN_AUTOCLEAN_SRC := plugins/autoclean.c
Expand Down
1 change: 0 additions & 1 deletion plugins/pay.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <common/memleak.h>
#include <common/pseudorand.h>
#include <common/type_to_string.h>
#include <plugins/pay_point32.h>
#include <plugins/libplugin-pay.h>
#include <stdio.h>

Expand Down
20 changes: 0 additions & 20 deletions plugins/pay_point32.c

This file was deleted.

12 changes: 0 additions & 12 deletions plugins/pay_point32.h

This file was deleted.

68 changes: 0 additions & 68 deletions plugins/test/run-gossmap_guess_node_id.c

This file was deleted.

6 changes: 3 additions & 3 deletions wire/extracted_bolt12_01_recurrence.patch
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ index 726c3c0a1..a53ca3cdf 100644
+tlvdata,offer,recurrence_base,start_any_period,byte,
+tlvdata,offer,recurrence_base,basetime,tu64,
tlvtype,offer,node_id,30
tlvdata,offer,node_id,node_id,point32,
tlvdata,offer,node_id,node_id,pubkey,
tlvtype,offer,send_invoice,54
@@ -40,6 +54,10 @@ tlvtype,invoice_request,features,12
tlvdata,invoice_request,features,features,byte,...
Expand All @@ -30,7 +30,7 @@ index 726c3c0a1..a53ca3cdf 100644
+tlvtype,invoice_request,recurrence_start,68
+tlvdata,invoice_request,recurrence_start,period_offset,tu32,
tlvtype,invoice_request,payer_key,38
tlvdata,invoice_request,payer_key,key,point32,
tlvdata,invoice_request,payer_key,key,pubkey,
tlvtype,invoice_request,payer_note,39
@@ -74,6 +94,12 @@ tlvtype,invoice,quantity,32
tlvdata,invoice,quantity,quantity,tu64,
Expand All @@ -43,5 +43,5 @@ index 726c3c0a1..a53ca3cdf 100644
+tlvtype,invoice,recurrence_basetime,64
+tlvdata,invoice,recurrence_basetime,basetime,tu64,
tlvtype,invoice,payer_key,38
tlvdata,invoice,payer_key,key,point32,
tlvdata,invoice,payer_key,key,pubkey,
tlvtype,invoice,payer_note,39

0 comments on commit bd75295

Please sign in to comment.