sphinx: Switch to big-endian number encoding

See https://github.com/lightningnetwork/lightning-rfc/pull/619 and
https://github.com/lightningnetwork/lightning-rfc/pull/619 for discussion.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
Christian Decker
2019-07-18 14:07:07 +02:00
committed by Rusty Russell
parent c752c3318d
commit 78c7edb889
3 changed files with 73 additions and 2 deletions

View File

@@ -454,7 +454,7 @@ static bool sphinx_write_frame(u8 *dest, const struct sphinx_hop *hop)
if (hop->type == SPHINX_V0_PAYLOAD)
dest[pos++] = 0x00;
else
pos += varint_put(dest+pos, raw_size);
pos += bigsize_put(dest+pos, raw_size);
memcpy(dest + pos, hop->payload, raw_size);
pos += raw_size;
@@ -618,7 +618,7 @@ struct route_step *process_onionpacket(
} else {
/* In addition to the raw payload we need to also shift the
* length encoding itself and the HMAC away. */
vsize = varint_get(paddedheader, 3, &shift_size);
vsize = bigsize_get(paddedheader, 3, &shift_size);
shift_size += vsize + HMAC_SIZE;
/* If we get an unreasonable shift size we must return an error. */