Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Signature bincode serialization #509

Merged
merged 3 commits into from
Feb 6, 2024

Conversation

Wollac
Copy link
Contributor

@Wollac Wollac commented Feb 4, 2024

Motivation

The current way the serialization/deserialization of Signature is implemented only works for human readable (JSON) formats. However, binary formats like bincode that do not support Deserializer::deserialize_identifier are not supported.

Solution

Similar to #221, this PR uses the is_human_readable() flag to distinguish between using the current serialization (SerializeMap) or a bincode compatible version.
For this, the serialization is implemented as a tuple (r: U256, s: U256, v: u64).

@@ -92,6 +92,15 @@ impl Parity {
}
}

/// Return the corresponding u64 V value.
pub const fn to_u64(&self) -> u64 {
Copy link
Member

Choose a reason for hiding this comment

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

should be a From/Into implementation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be, yes. To me it felt more like the y_parity_byte which is not a From<u8> either.
But I don't have a strong opinion at all, I can change it to a From. Whatever you prefer.

Copy link
Member

Choose a reason for hiding this comment

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

Can be follow ups

Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

lgtm

@DaniPopes DaniPopes merged commit d4371bc into alloy-rs:main Feb 6, 2024
21 checks passed
@Wollac Wollac deleted the fix/signature-bincode branch February 13, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants