fix: Signature serializes more bytes than are deserialized#686
fix: Signature serializes more bytes than are deserialized#686
Conversation
| impl Serializable for Signature { | ||
| fn write_into<W: ByteWriter>(&self, target: &mut W) { | ||
| let mut bytes = [0u8; SIGNATURE_BYTES]; | ||
| let mut bytes = [0u8; SIGNATURE_BYTES - 1]; |
There was a problem hiding this comment.
Unsure how we actually want to fix this. Put this here for now.
There was a problem hiding this comment.
I think this is probably related to #668 (and now thinking about it, my concern about the odd number of bytes is not valid).
@Al-Kindi-0 - is there a reason we need 66 bytes vs. 65 bytes for serialization?
Also, this should probably go into main as it seems like a bug fix.
There was a problem hiding this comment.
For now, we could just read the extra byte during deserialization and discard it as a fix, right? That means we wouldn't actually touch the serialization format, in case that is somehow important.
There was a problem hiding this comment.
Yeah, I think we probably want to do two things:
- The short-term fix that reads the extra byte and discards it - this would go into
main. - The longer term fix that reduces signature size to 65 bytes (assuming that's the correct thing to do) - that would go into
next.
bobbinth
left a comment
There was a problem hiding this comment.
Looks good! Thank you! Also, let's update the changelog.
I'd hold off on merging before review from @Al-Kindi-0.
CHANGELOG.md
Outdated
| @@ -1,6 +1,7 @@ | |||
| ## 0.20.0 (TBD) | |||
| ## 0.20.0 (2025-12-04) | |||
There was a problem hiding this comment.
We are not planning to release the v0.20.0 version yet - so, I'd keep it as TBD.
The bug fix (that keeps signature length as is) should go into main - and that would probably be a different PR.
Al-Kindi-0
left a comment
There was a problem hiding this comment.
LGTM
I think the reason for the extra bit was the previous solution where we wanted to accommodate both the Keccak and SHA variants of the signature. We then probably forgot to remove this extra bit when we abandoned that goal.
Closes #685.
We discovered in 0xMiden/protocol#2128 that serialization of
Signatureis problematic.It appears that an additional byte is serialized but not deserialized.