Skip to content

lnonion/trampoline: stop double counting HMAC size#10668

Merged
SomberNight merged 1 commit into
spesmilo:masterfrom
f321x:trampoline_routing_info
May 26, 2026
Merged

lnonion/trampoline: stop double counting HMAC size#10668
SomberNight merged 1 commit into
spesmilo:masterfrom
f321x:trampoline_routing_info

Conversation

@f321x
Copy link
Copy Markdown
Member

@f321x f321x commented May 26, 2026

OnionHopsDataSingle.to_bytes() already accounts for the onions hmac internally,
it seems incorrect that we were additionally adding PER_HOP_HMAC_SIZE to the payload
size of the payload returned by .to_bytes().

def to_bytes(self) -> bytes:
hmac_ = self.hmac if self.hmac is not None else bytes(PER_HOP_HMAC_SIZE)
if self._raw_bytes_payload is not None:
ret = self._raw_bytes_payload
ret += hmac_
return ret
# adding TLV payload. note: legacy hop data format no longer supported.
payload_fd = io.BytesIO()
OnionWireSerializer.write_tlv_stream(fd=payload_fd,
tlv_stream_name=self.tlv_stream_name,
**self.payload)
payload_bytes = payload_fd.getvalue()
with io.BytesIO() as fd:
fd.write(write_bigsize_int(len(payload_bytes)))
fd.write(payload_bytes)
fd.write(hmac_)
return fd.getvalue()

`OnionHopsDataSingle.to_bytes()` already accounts for the
onions hmac internally, it seems incorrect that we were
additionally adding `PER_HOP_HMAC_SIZE` to the payload size
of the payload returned by `.to_bytes()`.
@f321x f321x added the bug 🐞 label May 26, 2026
Copy link
Copy Markdown
Member

@SomberNight SomberNight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right.. Yes, that seems to have been a logic bug.

@SomberNight SomberNight merged commit 93f5825 into spesmilo:master May 26, 2026
17 checks passed
@f321x f321x deleted the trampoline_routing_info branch May 26, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants