common/test: remove unused padding in bolt04/blinded-onion-message-onion-test.json

This was reported by @valentinewallace: Dave would only use padding to
make all his own encrypted_recipient_data equal-length.  We did it
across the entire path, which includes the hop added by Alice, which
Dave wouldn't know about.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-01-12 14:19:38 +10:30
parent 13fe27c65f
commit 5958c9c3d6
1 changed files with 13 additions and 8 deletions

View File

@ -126,8 +126,8 @@ void ecdh(const struct pubkey *point, struct secret *ss)
abort();
}
/* This established by trial and error! */
#define LARGEST_TLV_SIZE 70
/* This established by trial and error. */
#define LARGEST_DAVE_TLV_SIZE 42
/* Generic, ugly, function to calc encrypted_recipient_data,
alias and next blinding, and print out JSON */
@ -175,17 +175,22 @@ static u8 *add_hop(const char *name,
enctlv = tal_arr(tmpctx, u8, 0);
towire_tlv_encrypted_data_tlv(&enctlv, tlv);
/* Now create padding, and reencode */
if (tal_bytelen(enctlv) + tal_bytelen(additional) != LARGEST_TLV_SIZE)
/* Now create padding (in Dave's path) */
if (tal_bytelen(enctlv) + tal_bytelen(additional)
< LARGEST_DAVE_TLV_SIZE) {
/* Add padding: T and L take 2 bytes, even before V */
assert(tal_bytelen(enctlv) + tal_bytelen(additional) + 2
<= LARGEST_DAVE_TLV_SIZE);
tlv->padding = tal_arrz(tlv, u8,
LARGEST_TLV_SIZE
LARGEST_DAVE_TLV_SIZE
- tal_bytelen(enctlv)
- tal_bytelen(additional)
- 2);
- tal_bytelen(additional) - 2);
}
enctlv = tal_arr(tmpctx, u8, 0);
towire_tlv_encrypted_data_tlv(&enctlv, tlv);
towire(&enctlv, additional, tal_bytelen(additional));
assert(tal_bytelen(enctlv) == LARGEST_TLV_SIZE);
if (!override_blinding)
assert(tal_bytelen(enctlv) == LARGEST_DAVE_TLV_SIZE);
json_start("tlvs", '{');
if (tlv->padding)