BOLTs: update which renames blinding terminology.

No code changes, just catching up with the BOLT changes which rework our
blinded path terminology (for the better!).

Another patch will sweep the rest of our internal names, this tries only to
make things compile and fix up the BOLT quotes.

1. Inside payload: current_blinding_point -> current_path_key
2. Inside update_add_htlc TLV: blinding_point -> blinded_path
3. Inside blinded_path: blinding -> first_path_key
4. Inside onion_message: blinding -> path_key.
5. Inside encrypted_data_tlv: next_blinding_override -> next_path_key_override

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2024-10-15 02:33:49 +10:30
parent f944e03fca
commit dc18f3cd7b
40 changed files with 338 additions and 351 deletions

View File

@@ -95,13 +95,13 @@ static void test_ecdh(const struct pubkey *point, struct secret *ss)
abort();
}
static void test_decrypt(const struct pubkey *blinding,
static void test_decrypt(const struct pubkey *path_key,
const u8 *enctlv,
const struct privkey *me,
const struct pubkey *expected_next_node,
const struct privkey *expected_next_blinding_priv)
const struct privkey *expected_next_path_key_priv)
{
struct pubkey expected_next_blinding, dummy, next_blinding;
struct pubkey expected_next_path_key, dummy, next_path_key;
struct secret ss;
struct tlv_encrypted_data_tlv *enc;
@@ -109,17 +109,17 @@ static void test_decrypt(const struct pubkey *blinding,
pubkey_from_privkey(me, &dummy);
mykey = me;
assert(unblind_onion(blinding, test_ecdh, &dummy, &ss));
enc = decrypt_encrypted_data(tmpctx, blinding, &ss, enctlv);
assert(unblind_onion(path_key, test_ecdh, &dummy, &ss));
enc = decrypt_encrypted_data(tmpctx, &ss, enctlv);
assert(enc);
pubkey_from_privkey(expected_next_blinding_priv, &expected_next_blinding);
blindedpath_next_blinding(enc, blinding, &ss, &next_blinding);
assert(pubkey_eq(&next_blinding, &expected_next_blinding));
pubkey_from_privkey(expected_next_path_key_priv, &expected_next_path_key);
blindedpath_next_path_key(enc, path_key, &ss, &next_path_key);
assert(pubkey_eq(&next_path_key, &expected_next_path_key));
assert(pubkey_eq(enc->next_node_id, expected_next_node));
}
static void test_final_decrypt(const struct pubkey *blinding,
static void test_final_decrypt(const struct pubkey *path_key,
const u8 *enctlv,
const struct privkey *me,
const struct pubkey *expected_alias,
@@ -134,8 +134,8 @@ static void test_final_decrypt(const struct pubkey *blinding,
mykey = me;
pubkey_from_privkey(me, &my_pubkey);
assert(unblind_onion(blinding, test_ecdh, &dummy, &ss));
enc = decrypt_encrypted_data(tmpctx, blinding, &ss, enctlv);
assert(unblind_onion(path_key, test_ecdh, &dummy, &ss));
enc = decrypt_encrypted_data(tmpctx, &ss, enctlv);
assert(enc);
assert(blindedpath_get_alias(&ss, &my_pubkey, &alias));
@@ -146,8 +146,8 @@ static void test_final_decrypt(const struct pubkey *blinding,
int main(int argc, char *argv[])
{
struct privkey alice, bob, carol, dave, blinding, override_blinding;
struct pubkey alice_id, bob_id, carol_id, dave_id, blinding_pub, override_blinding_pub, alias;
struct privkey alice, bob, carol, dave, path_key, override_path_key;
struct pubkey alice_id, bob_id, carol_id, dave_id, path_key_pub, override_path_key_pub, alias;
struct secret self_id;
u8 *enctlv;
struct tlv_encrypted_data_tlv *tlv;
@@ -163,8 +163,8 @@ int main(int argc, char *argv[])
pubkey_from_privkey(&carol, &carol_id);
pubkey_from_privkey(&dave, &dave_id);
memset(&blinding, 5, sizeof(blinding));
pubkey_from_privkey(&blinding, &blinding_pub);
memset(&path_key, 5, sizeof(path_key));
pubkey_from_privkey(&path_key, &path_key_pub);
/* We output the JSON test vectors. */
printf("[{");
@@ -173,10 +173,10 @@ int main(int argc, char *argv[])
fmt_privkey(tmpctx, &alice));
json_strfield("node_id",
fmt_pubkey(tmpctx, &alice_id));
json_strfield("blinding_secret",
fmt_privkey(tmpctx, &blinding));
json_strfield("blinding",
fmt_pubkey(tmpctx, &blinding_pub));
json_strfield("path_key_secret",
fmt_privkey(tmpctx, &path_key));
json_strfield("path_key",
fmt_pubkey(tmpctx, &path_key_pub));
printf("\t\"encrypted_data_tlv\": {\n"
"\t\t\"next_node_id\": \"%s\"\n"
"\t},\n",
@@ -184,50 +184,50 @@ int main(int argc, char *argv[])
tlv = tlv_encrypted_data_tlv_new(tmpctx);
tlv->next_node_id = &bob_id;
enctlv = encrypt_tlv_encrypted_data(tmpctx, &blinding, &alice_id, tlv,
&blinding, &alias);
enctlv = encrypt_tlv_encrypted_data(tmpctx, &path_key, &alice_id, tlv,
&path_key, &alias);
printf("\t\"encrypted_recipient_data_hex\": \"%s\"\n"
"},\n",
tal_hex(tmpctx, enctlv));
test_decrypt(&blinding_pub, enctlv, &alice, &bob_id, &blinding);
test_decrypt(&path_key_pub, enctlv, &alice, &bob_id, &path_key);
pubkey_from_privkey(&blinding, &blinding_pub);
memset(&override_blinding, 7, sizeof(override_blinding));
pubkey_from_privkey(&override_blinding, &override_blinding_pub);
pubkey_from_privkey(&path_key, &path_key_pub);
memset(&override_path_key, 7, sizeof(override_path_key));
pubkey_from_privkey(&override_path_key, &override_path_key_pub);
printf("{");
json_strfield("test name",
"Blinding-key-override encrypted_recipient_data for Bob, next is Carol");
"path_key_override encrypted_recipient_data for Bob, next is Carol");
json_strfield("node_privkey",
fmt_privkey(tmpctx, &bob));
json_strfield("node_id",
fmt_pubkey(tmpctx, &bob_id));
json_strfield("blinding_secret",
fmt_privkey(tmpctx, &blinding));
json_strfield("blinding",
fmt_pubkey(tmpctx, &blinding_pub));
json_strfield("path_key_secret",
fmt_privkey(tmpctx, &path_key));
json_strfield("path_key",
fmt_pubkey(tmpctx, &path_key_pub));
printf("\t\"encrypted_data_tlv\": {\n"
"\t\t\"next_node_id\": \"%s\",\n"
"\t\t\"blinding\": \"%s\"\n"
"\t\t\"path_key\": \"%s\"\n"
"\t},\n",
fmt_pubkey(tmpctx, &carol_id),
fmt_privkey(tmpctx, &override_blinding));
fmt_privkey(tmpctx, &override_path_key));
tlv = tlv_encrypted_data_tlv_new(tmpctx);
tlv->next_node_id = &carol_id;
tlv->next_blinding_override = &override_blinding_pub;
enctlv = encrypt_tlv_encrypted_data(tmpctx, &blinding, &bob_id, tlv,
&blinding, &alias);
tlv->next_path_key_override = &override_path_key_pub;
enctlv = encrypt_tlv_encrypted_data(tmpctx, &path_key, &bob_id, tlv,
&path_key, &alias);
printf("\t\"encrypted_recipient_data_hex\": \"%s\"\n"
"},\n",
tal_hex(tmpctx, enctlv));
test_decrypt(&blinding_pub, enctlv, &bob, &carol_id, &override_blinding);
test_decrypt(&path_key_pub, enctlv, &bob, &carol_id, &override_path_key);
/* That replaced the blinding */
blinding = override_blinding;
blinding_pub = override_blinding_pub;
/* That replaced the path_key */
path_key = override_path_key;
path_key_pub = override_path_key_pub;
printf("{");
json_strfield("test name", "Padded encrypted_recipient_data for Carol, next is Dave");
@@ -235,10 +235,10 @@ int main(int argc, char *argv[])
fmt_privkey(tmpctx, &carol));
json_strfield("node_id",
fmt_pubkey(tmpctx, &carol_id));
json_strfield("blinding_secret",
fmt_privkey(tmpctx, &blinding));
json_strfield("blinding",
fmt_pubkey(tmpctx, &blinding_pub));
json_strfield("path_key_secret",
fmt_privkey(tmpctx, &path_key));
json_strfield("path_key",
fmt_pubkey(tmpctx, &path_key_pub));
printf("\t\"encrypted_data_tlv\": {\n"
"\t\t\"next_node_id\": \"%s\",\n"
"\t\t\"padding\": \"%s\"\n"
@@ -249,13 +249,13 @@ int main(int argc, char *argv[])
tlv = tlv_encrypted_data_tlv_new(tmpctx);
tlv->padding = tal_arrz(tlv, u8, 35);
tlv->next_node_id = &dave_id;
enctlv = encrypt_tlv_encrypted_data(tmpctx, &blinding, &carol_id, tlv,
&blinding, &alias);
enctlv = encrypt_tlv_encrypted_data(tmpctx, &path_key, &carol_id, tlv,
&path_key, &alias);
printf("\t\"encrypted_recipient_data_hex\": \"%s\"\n"
"},\n",
tal_hex(tmpctx, enctlv));
test_decrypt(&blinding_pub, enctlv, &carol, &dave_id, &blinding);
test_decrypt(&path_key_pub, enctlv, &carol, &dave_id, &path_key);
for (size_t i = 0; i < sizeof(self_id); i++)
self_id.data[i] = i+1;
@@ -265,10 +265,10 @@ int main(int argc, char *argv[])
fmt_privkey(tmpctx, &dave));
json_strfield("node_id",
fmt_pubkey(tmpctx, &dave_id));
json_strfield("blinding_secret",
fmt_privkey(tmpctx, &blinding));
json_strfield("blinding",
fmt_pubkey(tmpctx, &blinding_pub));
json_strfield("path_key_secret",
fmt_privkey(tmpctx, &path_key));
json_strfield("path_key",
fmt_pubkey(tmpctx, &path_key_pub));
printf("\t\"encrypted_data_tlv\": {\n"
"\t\t\"self_id\": \"%s\"\n"
"\t},\n",
@@ -277,15 +277,15 @@ int main(int argc, char *argv[])
tlv = tlv_encrypted_data_tlv_new(tmpctx);
tlv->path_id = tal_dup_arr(tlv, u8,
self_id.data, ARRAY_SIZE(self_id.data), 0);
enctlv = encrypt_tlv_encrypted_data(tmpctx, &blinding, &dave_id, tlv,
enctlv = encrypt_tlv_encrypted_data(tmpctx, &path_key, &dave_id, tlv,
NULL, &alias);
printf("\t\"encrypted_recipient_data_hex\": \"%s\"\n",
tal_hex(tmpctx, enctlv));
printf("}]\n");
pubkey_from_privkey(&blinding, &blinding_pub);
pubkey_from_privkey(&path_key, &path_key_pub);
test_final_decrypt(&blinding_pub, enctlv, &dave, &alias, &self_id);
test_final_decrypt(&path_key_pub, enctlv, &dave, &alias, &self_id);
common_shutdown();
}

View File

@@ -118,11 +118,11 @@ void ecdh(const struct pubkey *point, struct secret *ss)
static u8 *next_onion(const tal_t *ctx, u8 *omsg,
const struct privkey *nodekey,
const struct pubkey *expected_blinding)
const struct pubkey *expected_path_key)
{
struct onionpacket *op;
struct pubkey blinding, ephemeral;
struct pubkey next_blinding;
struct pubkey path_key, ephemeral;
struct pubkey next_path_key;
struct tlv_onionmsg_tlv *om;
struct secret ss, onion_ss;
const u8 *cursor;
@@ -130,14 +130,14 @@ static u8 *next_onion(const tal_t *ctx, u8 *omsg,
struct route_step *rs;
struct tlv_encrypted_data_tlv *enc;
assert(fromwire_onion_message(tmpctx, omsg, &blinding, &omsg));
assert(pubkey_eq(&blinding, expected_blinding));
assert(fromwire_onion_message(tmpctx, omsg, &path_key, &omsg));
assert(pubkey_eq(&path_key, expected_path_key));
op = parse_onionpacket(tmpctx, omsg, tal_bytelen(omsg), NULL);
ephemeral = op->ephemeralkey;
ecdh_key = nodekey;
assert(unblind_onion(&blinding, ecdh, &ephemeral, &ss));
assert(unblind_onion(&path_key, ecdh, &ephemeral, &ss));
ecdh(&ephemeral, &onion_ss);
rs = process_onionpacket(tmpctx, op, &onion_ss, NULL, 0);
@@ -152,17 +152,17 @@ static u8 *next_onion(const tal_t *ctx, u8 *omsg,
if (rs->nextcase == ONION_END)
return NULL;
enc = decrypt_encrypted_data(tmpctx, &blinding, &ss, om->encrypted_recipient_data);
enc = decrypt_encrypted_data(tmpctx, &ss, om->encrypted_recipient_data);
assert(enc);
blindedpath_next_blinding(enc, &blinding, &ss, &next_blinding);
return towire_onion_message(ctx, &next_blinding,
blindedpath_next_path_key(enc, &path_key, &ss, &next_path_key);
return towire_onion_message(ctx, &next_path_key,
serialize_onionpacket(tmpctx, rs->next));
}
int main(int argc, char *argv[])
{
struct privkey nodekey[4], blinding[4], override_blinding;
struct pubkey id[4], blinding_pub[4], override_blinding_pub, alias[4];
struct privkey nodekey[4], path_key[4], override_path_key;
struct pubkey id[4], path_key_pub[4], override_path_key_pub, alias[4];
struct secret self_id;
struct tlv_encrypted_data_tlv *tlv[4];
u8 *enctlv[4];
@@ -181,43 +181,43 @@ int main(int argc, char *argv[])
}
/* Make enctlvs as per enctlv test vectors */
memset(&blinding[ALICE], 5, sizeof(blinding[ALICE]));
pubkey_from_privkey(&blinding[ALICE], &blinding_pub[ALICE]);
memset(&path_key[ALICE], 5, sizeof(path_key[ALICE]));
pubkey_from_privkey(&path_key[ALICE], &path_key_pub[ALICE]);
tlv[ALICE] = tlv_encrypted_data_tlv_new(tmpctx);
tlv[ALICE]->next_node_id = &id[BOB];
enctlv[ALICE] = encrypt_tlv_encrypted_data(tmpctx,
&blinding[ALICE],
&path_key[ALICE],
&id[ALICE], tlv[ALICE],
&blinding[BOB],
&path_key[BOB],
&alias[ALICE]);
pubkey_from_privkey(&blinding[BOB], &blinding_pub[BOB]);
pubkey_from_privkey(&path_key[BOB], &path_key_pub[BOB]);
/* We override blinding for Carol. */
memset(&override_blinding, 7, sizeof(override_blinding));
pubkey_from_privkey(&override_blinding, &override_blinding_pub);
/* We override path_key for Carol. */
memset(&override_path_key, 7, sizeof(override_path_key));
pubkey_from_privkey(&override_path_key, &override_path_key_pub);
tlv[BOB] = tlv_encrypted_data_tlv_new(tmpctx);
tlv[BOB]->next_node_id = &id[CAROL];
tlv[BOB]->next_blinding_override = &override_blinding_pub;
tlv[BOB]->next_path_key_override = &override_path_key_pub;
enctlv[BOB] = encrypt_tlv_encrypted_data(tmpctx,
&blinding[BOB],
&path_key[BOB],
&id[BOB], tlv[BOB],
&blinding[CAROL],
&path_key[CAROL],
&alias[BOB]);
/* That replaced the blinding */
blinding[CAROL] = override_blinding;
blinding_pub[CAROL] = override_blinding_pub;
/* That replaced the path_key */
path_key[CAROL] = override_path_key;
path_key_pub[CAROL] = override_path_key_pub;
tlv[CAROL] = tlv_encrypted_data_tlv_new(tmpctx);
tlv[CAROL]->next_node_id = &id[DAVE];
tlv[CAROL]->padding = tal_arrz(tlv[CAROL], u8, 35);
enctlv[CAROL] = encrypt_tlv_encrypted_data(tmpctx,
&blinding[CAROL],
&path_key[CAROL],
&id[CAROL], tlv[CAROL],
&blinding[DAVE],
&path_key[DAVE],
&alias[CAROL]);
for (size_t i = 0; i < sizeof(self_id); i++)
@@ -228,11 +228,11 @@ int main(int argc, char *argv[])
self_id.data, ARRAY_SIZE(self_id.data),
0);
enctlv[DAVE] = encrypt_tlv_encrypted_data(tmpctx,
&blinding[DAVE],
&path_key[DAVE],
&id[DAVE], tlv[DAVE],
NULL,
&alias[DAVE]);
pubkey_from_privkey(&blinding[DAVE], &blinding_pub[DAVE]);
pubkey_from_privkey(&path_key[DAVE], &path_key_pub[DAVE]);
/* Create an onion which encodes this. */
sphinx_path = sphinx_path_new(tmpctx, NULL);
@@ -248,7 +248,7 @@ int main(int argc, char *argv[])
&path_secrets);
/* And finally, the onion message as handed to Alice */
omsg = towire_onion_message(tmpctx, &blinding_pub[ALICE],
omsg = towire_onion_message(tmpctx, &path_key_pub[ALICE],
serialize_onionpacket(tmpctx, op));
printf("{\n");
@@ -265,10 +265,10 @@ int main(int argc, char *argv[])
printf("\t\"onion_message\": {");
json_strfield("raw", tal_hex(tmpctx, omsg));
json_strfield("blinding_secret",
fmt_privkey(tmpctx, &blinding[i]));
json_strfield("blinding",
fmt_pubkey(tmpctx, &blinding_pub[i]));
json_strfield("path_key_secret",
fmt_privkey(tmpctx, &path_key[i]));
json_strfield("path_key",
fmt_pubkey(tmpctx, &path_key_pub[i]));
json_strfield("blinded_alias",
fmt_pubkey(tmpctx, &alias[i]));
json_strfield("onionmsg_tlv",
@@ -280,7 +280,7 @@ int main(int argc, char *argv[])
printf(",\n");
/* Unwrap for next hop */
omsg = next_onion(tmpctx, omsg, &nodekey[i], &blinding_pub[i]);
omsg = next_onion(tmpctx, omsg, &nodekey[i], &path_key_pub[i]);
}
assert(!omsg);
printf("\n]}\n");

View File

@@ -230,7 +230,7 @@ int main(int argc, char *argv[])
offer->offer_paths[0]->first_node_id.is_pubkey = true;
assert(pubkey_from_secret(&bob, &offer->offer_paths[0]->first_node_id.pubkey));
/* Random blinding secret. */
assert(pubkey_from_hexstr("020202020202020202020202020202020202020202020202020202020202020202", 66, &offer->offer_paths[0]->blinding));
assert(pubkey_from_hexstr("020202020202020202020202020202020202020202020202020202020202020202", 66, &offer->offer_paths[0]->first_path_key));
offer->offer_paths[0]->path = tal_arr(offer->offer_paths[0],
struct onionmsg_hop *,
2);
@@ -242,7 +242,7 @@ int main(int argc, char *argv[])
struct onionmsg_hop);
assert(pubkey_from_hexstr("020202020202020202020202020202020202020202020202020202020202020202", 66, &offer->offer_paths[0]->path[1]->blinded_node_id));
offer->offer_paths[0]->path[1]->encrypted_recipient_data = tal_hexdata(offer->offer_paths[0]->path[1], "1111111111111111", 16);
print_valid_offer(offer, "with blinded path via Bob (0x424242...), blinding 020202...",
print_valid_offer(offer, "with blinded path via Bob (0x424242...), path_key 020202...",
"path is [id=02020202..., enc=0x00*16], [id=02020202..., enc=0x11*8]", NULL);
/* BOLT-offers #12:
@@ -253,7 +253,7 @@ int main(int argc, char *argv[])
* - MUST set `offer_issuer_id` to the node's public key to request the invoice from.
*/
offer->offer_issuer_id = tal_free(offer->offer_issuer_id);
print_valid_offer(offer, "with no issuer_id and blinded path via Bob (0x424242...), blinding 020202...",
print_valid_offer(offer, "with no issuer_id and blinded path via Bob (0x424242...), path_key 020202...",
"path is [id=02020202..., enc=0x00*16], [id=02020202..., enc=0x11*8]", NULL);
offer->offer_issuer_id = tal(offer, struct pubkey);
assert(pubkey_from_secret(&alice, offer->offer_issuer_id));
@@ -263,8 +263,8 @@ int main(int argc, char *argv[])
offer->offer_paths[1]->first_node_id.is_pubkey = false;
assert(short_channel_id_dir_from_str("1x2x3/1", strlen("1x2x3/1"),
&offer->offer_paths[1]->first_node_id.scidd));
/* Random blinding secret. */
assert(pubkey_from_hexstr("020202020202020202020202020202020202020202020202020202020202020202", 66, &offer->offer_paths[1]->blinding));
/* Random path_key secret. */
assert(pubkey_from_hexstr("020202020202020202020202020202020202020202020202020202020202020202", 66, &offer->offer_paths[1]->first_path_key));
offer->offer_paths[1]->path = tal_arr(offer->offer_paths[1],
struct onionmsg_hop *,
2);
@@ -276,7 +276,7 @@ int main(int argc, char *argv[])
struct onionmsg_hop);
assert(pubkey_from_hexstr("020202020202020202020202020202020202020202020202020202020202020202", 66, &offer->offer_paths[1]->path[1]->blinded_node_id));
offer->offer_paths[1]->path[1]->encrypted_recipient_data = tal_hexdata(offer->offer_paths[1]->path[1], "2222222222222222", 16);
print_valid_offer(offer, "... and with second blinded path via 1x2x3 (direction 1), blinding 020202...",
print_valid_offer(offer, "... and with second blinded path via 1x2x3 (direction 1), path_key 020202...",
"path is [id=02020202..., enc=0x00*16], [id=02020202..., enc=0x22*8]", NULL);
paths = offer->offer_paths;
offer->offer_paths = NULL;
@@ -363,7 +363,7 @@ int main(int argc, char *argv[])
"0A05414C494345"
"10020202020202020202020202020202020202020202020202020202020202020202030303030303030303030303030303030303030303030303030303030303030303010202020202020202020202020202020202020202020202020202020202020202020100"
"1621020202020202020202020202020202020202020202020202020202020202020202",
"Malformed: bad blinding in blinded_path");
"Malformed: bad path_key in blinded_path");
print_malformed_tlv("lno",
"0A05414C494345"
"10020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202010303030303030303030303030303030303030303030303030303030303030303030100"

View File

@@ -119,15 +119,15 @@ void ecdh(const struct pubkey *point, struct secret *ss)
#define LARGEST_DAVE_TLV_SIZE 42
/* Generic, ugly, function to calc encrypted_recipient_data,
alias and next blinding, and print out JSON */
alias and next path_key, and print out JSON */
static u8 *add_hop(const char *name,
const char *comment,
const struct pubkey *me,
const struct pubkey *next,
const struct privkey *override_blinding,
const struct privkey *override_path_key,
const char *additional_field_hexstr,
const char *path_id_hexstr,
struct privkey *blinding, /* in and out */
struct privkey *path_key, /* in and out */
struct pubkey *alias /* out */)
{
struct tlv_encrypted_data_tlv *tlv = tlv_encrypted_data_tlv_new(tmpctx);
@@ -137,7 +137,7 @@ static u8 *add_hop(const char *name,
json_start(NULL, '{');
json_strfield("alias", name);
json_strfield("comment", comment);
json_hexfield("blinding_secret", blinding->secret.data, sizeof(*blinding));
json_hexfield("path_key_secret", path_key->secret.data, sizeof(*path_key));
/* We have to calc first, to make padding correct */
tlv->next_node_id = tal_dup_or_null(tlv, struct pubkey, next);
@@ -145,12 +145,12 @@ static u8 *add_hop(const char *name,
tlv->path_id = tal_hexdata(tlv, path_id_hexstr,
strlen(path_id_hexstr));
/* Normally we wouldn't know blinding privkey, and we'd just
/* Normally we wouldn't know path_key privkey, and we'd just
* paste in the rest of the path as given, but here we're actually
* generating the lot. */
if (override_blinding) {
tlv->next_blinding_override = tal(tlv, struct pubkey);
assert(pubkey_from_privkey(override_blinding, tlv->next_blinding_override));
if (override_path_key) {
tlv->next_path_key_override = tal(tlv, struct pubkey);
assert(pubkey_from_privkey(override_path_key, tlv->next_path_key_override));
}
/* This is assumed to be a valid TLV tuple, and greater than
@@ -178,7 +178,7 @@ static u8 *add_hop(const char *name,
enctlv = tal_arr(tmpctx, u8, 0);
towire_tlv_encrypted_data_tlv(&enctlv, tlv);
towire(&enctlv, additional, tal_bytelen(additional));
if (!override_blinding)
if (!override_path_key)
assert(tal_bytelen(enctlv) == LARGEST_DAVE_TLV_SIZE);
json_start("tlvs", '{');
@@ -188,12 +188,12 @@ static u8 *add_hop(const char *name,
json_pubkey("next_node_id", tlv->next_node_id);
if (tlv->path_id)
json_hex_talfield("path_id", tlv->path_id);
if (tlv->next_blinding_override) {
json_pubkey("next_blinding_override",
tlv->next_blinding_override);
json_hexfield("blinding_override_secret",
override_blinding->secret.data,
sizeof(*override_blinding));
if (tlv->next_path_key_override) {
json_pubkey("next_path_key_override",
tlv->next_path_key_override);
json_hexfield("path_key_override_secret",
override_path_key->secret.data,
sizeof(*override_path_key));
}
if (additional) {
/* Deconstruct into type, len, value */
@@ -211,16 +211,16 @@ static u8 *add_hop(const char *name,
flush_comma();
enable_superverbose = true;
encrypted_recipient_data = enctlv_from_encmsg_raw(tmpctx,
blinding,
path_key,
me,
enctlv,
blinding,
path_key,
alias);
enable_superverbose = false;
json_hex_talfield("encrypted_recipient_data",
encrypted_recipient_data);
if (override_blinding)
*blinding = *override_blinding;
if (override_path_key)
*path_key = *override_path_key;
json_end('}');
maybe_comma();
@@ -230,8 +230,8 @@ static u8 *add_hop(const char *name,
int main(int argc, char *argv[])
{
const char *alias[] = {"Alice", "Bob", "Carol", "Dave"};
struct privkey privkey[ARRAY_SIZE(alias)], blinding, override_blinding;
struct pubkey id[ARRAY_SIZE(alias)], blinding_pub;
struct privkey privkey[ARRAY_SIZE(alias)], path_key, override_path_key;
struct pubkey id[ARRAY_SIZE(alias)], path_key_pub;
struct secret session_key;
u8 *erd[ARRAY_SIZE(alias)]; /* encrypted_recipient_data */
u8 *onion_message_packet, *onion_message;
@@ -257,36 +257,36 @@ int main(int argc, char *argv[])
json_hexfield("session_key", session_key.data, sizeof(session_key));
json_start("hops", '[');
memset(&blinding, 99, sizeof(blinding));
memset(&override_blinding, 1, sizeof(override_blinding));
erd[0] = add_hop("Alice", "Alice->Bob: note next_blinding_override to match that give by Dave for Bob",
memset(&path_key, 99, sizeof(path_key));
memset(&override_path_key, 1, sizeof(override_path_key));
erd[0] = add_hop("Alice", "Alice->Bob: note next_path_key_override to match that give by Dave for Bob",
&id[0], &id[1],
&override_blinding, NULL, NULL,
&blinding, &blinded[0]);
&override_path_key, NULL, NULL,
&path_key, &blinded[0]);
erd[1] = add_hop("Bob", "Bob->Carol",
&id[1], &id[2],
NULL, "fd023103123456", NULL,
&blinding, &blinded[1]);
&path_key, &blinded[1]);
erd[2] = add_hop("Carol", "Carol->Dave",
&id[2], &id[3],
NULL, NULL, NULL,
&blinding, &blinded[2]);
&path_key, &blinded[2]);
erd[3] = add_hop("Dave", "Dave is final node, hence path_id",
&id[3], NULL,
NULL, "fdffff0206c1",
"deadbeefbadc0ffeedeadbeefbadc0ffeedeadbeefbadc0ffeedeadbeefbadc0",
&blinding, &blinded[3]);
&path_key, &blinded[3]);
json_end(']');
json_end('}');
maybe_comma();
memset(&blinding, 99, sizeof(blinding));
assert(pubkey_from_privkey(&blinding, &blinding_pub));
memset(&path_key, 99, sizeof(path_key));
assert(pubkey_from_privkey(&path_key, &path_key_pub));
json_start("route", '{');
json_strfield("comment", "The resulting blinded route Alice to Dave.");
json_pubkey("introduction_node_id", &id[0]);
json_pubkey("blinding", &blinding_pub);
json_pubkey("path_key", &path_key_pub);
json_start("hops", '[');
for (size_t i = 0; i < ARRAY_SIZE(erd); i++) {
@@ -338,7 +338,7 @@ int main(int argc, char *argv[])
json_start("decrypt", '{');
json_strfield("comment", "This section contains the internal values generated by intermediate nodes when decrypting the onion.");
onion_message = towire_onion_message(tmpctx, &blinding_pub, onion_message_packet);
onion_message = towire_onion_message(tmpctx, &path_key_pub, onion_message_packet);
json_start("hops", '[');
for (size_t i = 0; i < ARRAY_SIZE(erd); i++) {
@@ -354,11 +354,11 @@ int main(int argc, char *argv[])
/* Now, do full decrypt code, to check */
assert(fromwire_onion_message(tmpctx, onion_message,
&blinding_pub, &onion_message_packet));
&path_key_pub, &onion_message_packet));
/* For test_ecdh */
mykey = &privkey[i];
assert(onion_message_parse(tmpctx, onion_message_packet, &blinding_pub,
assert(onion_message_parse(tmpctx, onion_message_packet, &path_key_pub,
&id[i],
&onion_message, &next_node,
&final_om,

View File

@@ -59,7 +59,6 @@ struct amount_sat amount_tx_fee(u32 fee_per_kw UNNEEDED, size_t weight UNNEEDED)
{ fprintf(stderr, "amount_tx_fee called!\n"); abort(); }
/* Generated stub for decrypt_encrypted_data */
struct tlv_encrypted_data_tlv *decrypt_encrypted_data(const tal_t *ctx UNNEEDED,
const struct pubkey *blinding UNNEEDED,
const struct secret *ss UNNEEDED,
const u8 *enctlv)

View File

@@ -111,7 +111,7 @@ int main(int argc, char *argv[])
"final_amount_msat:%,"
"final_cltv:%,"
"blinded_payinfo:{fee_base_msat:%,fee_proportional_millionths:%,cltv_expiry_delta:%},"
"blinded_route:{introduction_node_id:%,blinding:%,hops:%}}}",
"blinded_route:{first_node_id:%,first_path_key:%,hops:%}}}",
JSON_SCAN(json_to_secret, &session_key),
JSON_SCAN_TAL(tmpctx, json_tok_bin_from_hex, &associated_data),
JSON_SCAN(json_to_msat, &final_amount),
@@ -120,7 +120,7 @@ int main(int argc, char *argv[])
JSON_SCAN(json_to_u32, &path_fee_proportional_millionths),
JSON_SCAN(json_to_u32, &path_cltv_delta),
JSON_SCAN(json_to_pubkey, &bpath->first_node_id.pubkey),
JSON_SCAN(json_to_pubkey, &bpath->blinding),
JSON_SCAN(json_to_pubkey, &bpath->first_path_key),
JSON_SCAN(json_to_tok, &hops_tok)) == NULL);
/* FIXME: Test scid as well! */

View File

@@ -118,10 +118,10 @@ static u8 *json_to_enctlvs(const tal_t *ctx,
enctlv->path_id = json_tok_bin_from_hex(enctlv,
buf, t+1);
assert(enctlv->path_id);
} else if (json_tok_streq(buf, t, "next_blinding_override")) {
enctlv->next_blinding_override = tal(enctlv, struct pubkey);
} else if (json_tok_streq(buf, t, "next_path_key_override")) {
enctlv->next_path_key_override = tal(enctlv, struct pubkey);
assert(json_to_pubkey(buf, t+1,
enctlv->next_blinding_override));
enctlv->next_path_key_override));
} else if (json_tok_streq(buf, t, "payment_relay")) {
enctlv->payment_relay = json_to_payment_relay(enctlv, buf, t+1);
} else if (json_tok_streq(buf, t, "payment_constraints")) {
@@ -159,7 +159,7 @@ int main(int argc, char *argv[])
const jsmntok_t *t, *hops_tok;
struct pubkey *ids;
u8 **enctlvs;
struct privkey blinding;
struct privkey path_key;
common_setup(argv[0]);
@@ -212,20 +212,20 @@ int main(int argc, char *argv[])
if (json_get_member(json, t, "session_key"))
assert(json_to_secret(json,
json_get_member(json, t, "session_key"),
&blinding.secret));
&path_key.secret));
else
assert(secret_eq_consttime(&blinding.secret, &s));
assert(secret_eq_consttime(&path_key.secret, &s));
assert(pubkey_from_privkey(&blinding, &pubkey));
assert(pubkey_from_privkey(&path_key, &pubkey));
json_to_pubkey(json, json_get_member(json, t, "ephemeral_pubkey"),
&expected_pubkey);
assert(pubkey_eq(&pubkey, &expected_pubkey));
enctlv = enctlv_from_encmsg_raw(tmpctx,
&blinding,
&path_key,
&ids[i],
enctlvs[i],
&blinding,
&path_key,
&alias);
expected_enctlv = json_tok_bin_from_hex(tmpctx,json,
json_get_member(json, t,

View File

@@ -60,7 +60,6 @@ size_t bigsize_put(u8 buf[BIGSIZE_MAX_LEN] UNNEEDED, bigsize_t v UNNEEDED)
{ fprintf(stderr, "bigsize_put called!\n"); abort(); }
/* Generated stub for decrypt_encrypted_data */
struct tlv_encrypted_data_tlv *decrypt_encrypted_data(const tal_t *ctx UNNEEDED,
const struct pubkey *blinding UNNEEDED,
const struct secret *ss UNNEEDED,
const u8 *enctlv)