1
0

update field naming for BOLT04 structures

see also: 3fffab3b88
This commit is contained in:
Sander van Grieken
2025-11-10 13:28:36 +01:00
parent d87f9e9a44
commit 130af59760
5 changed files with 52 additions and 52 deletions

View File

@@ -44,13 +44,13 @@ BOB_TLVS = HOPS[1]['tlvs']
CAROL_TLVS = HOPS[2]['tlvs']
DAVE_TLVS = HOPS[3]['tlvs']
ALICE_PUBKEY = bfh(test_vectors['route']['introduction_node_id'])
ALICE_PUBKEY = bfh(test_vectors['route']['first_node_id'])
BOB_PUBKEY = bfh(ALICE_TLVS['next_node_id'])
CAROL_PUBKEY = bfh(BOB_TLVS['next_node_id'])
DAVE_PUBKEY = bfh(CAROL_TLVS['next_node_id'])
BLINDING_SECRET = bfh(HOPS[0]['blinding_secret'])
BLINDING_OVERRIDE_SECRET = bfh(ALICE_TLVS['blinding_override_secret'])
BLINDING_SECRET = bfh(HOPS[0]['path_key_secret'])
BLINDING_OVERRIDE_SECRET = bfh(ALICE_TLVS['path_key_override_secret'])
SESSION_KEY = bfh(test_vectors['generate']['session_key'])
@@ -74,7 +74,7 @@ class TestOnionMessage(ElectrumTestCase):
tlv_stream_name='onionmsg_tlv',
blind_fields={
'next_node_id': {'node_id': bfh(ALICE_TLVS['next_node_id'])},
'next_blinding_override': {'blinding': bfh(ALICE_TLVS['next_blinding_override'])},
'next_path_key_override': {'path_key': bfh(ALICE_TLVS['next_path_key_override'])},
}
),
OnionHopsDataSingle(
@@ -150,7 +150,7 @@ class TestOnionMessage(ElectrumTestCase):
msgtype, data = decode_msg(bfh(msg))
self.assertEqual(msgtype, 'onion_message')
self.assertEqual(data, {
'blinding': bfh(test_vectors['route']['blinding']),
'path_key': bfh(test_vectors['route']['first_path_key']),
'len': 1366,
'onion_message_packet': ONION_MESSAGE_PACKET,
})
@@ -158,7 +158,7 @@ class TestOnionMessage(ElectrumTestCase):
def test_decrypt_onion_message(self):
o = OnionPacket.from_bytes(ONION_MESSAGE_PACKET)
our_privkey = bfh(test_vectors['decrypt']['hops'][0]['privkey'])
blinding = bfh(test_vectors['route']['blinding'])
blinding = bfh(test_vectors['route']['first_path_key'])
shared_secret = get_ecdh(our_privkey, blinding)
b_hmac = get_bolt04_onion_key(b'blinded_node_id', shared_secret)
@@ -179,7 +179,7 @@ class TestOnionMessage(ElectrumTestCase):
msgtype, data = decode_msg(bfh(onion_message_bob))
self.assertEqual(msgtype, 'onion_message')
self.assertEqual(data, {
'blinding': bfh(ALICE_TLVS['next_blinding_override']),
'path_key': bfh(ALICE_TLVS['next_path_key_override']),
'len': 1366,
'onion_message_packet': p.next_packet.to_bytes(),
})
@@ -196,7 +196,7 @@ class TestOnionMessage(ElectrumTestCase):
rp = create_blinded_path(session_key, [pubkey], final_recipient_data)
self.assertEqual(pubkey, rp['first_node_id'])
self.assertEqual(bfh('022ed557f5ad336b31a49857e4e9664954ac33385aa20a93e2d64bfe7f08f51277'), rp['blinding'])
self.assertEqual(bfh('022ed557f5ad336b31a49857e4e9664954ac33385aa20a93e2d64bfe7f08f51277'), rp['first_path_key'])
self.assertEqual(1, rp['num_hops'])
self.assertEqual([{
'blinded_node_id': bfh('031e5d91e6c417f6e8c16d1086db1887edef7be9334f5e744d04edb8da7507481e'),
@@ -234,7 +234,7 @@ class TestOnionMessage(ElectrumTestCase):
tlv_stream_name='onionmsg_tlv',
blind_fields={
'next_node_id': {'node_id': BOB_PUBKEY},
'next_blinding_override': {'blinding': bfh(ALICE_TLVS['next_blinding_override'])},
'next_path_key_override': {'path_key': bfh(ALICE_TLVS['next_path_key_override'])},
}
),
]
@@ -434,7 +434,7 @@ class TestOnionMessageManager(ElectrumTestCase):
onionmsg = bfh(test_vectors['onionmessage']['onion_message_packet'])
try:
t.on_onion_message({
'blinding': bfh(test_vectors['route']['blinding']),
'blinding': bfh(test_vectors['route']['first_path_key']),
'len': len(onionmsg),
'onion_message_packet': onionmsg
})