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: correctly handle v values #13

Merged
merged 8 commits into from
Oct 22, 2024
Merged

fix: correctly handle v values #13

merged 8 commits into from
Oct 22, 2024

Conversation

klkvr
Copy link
Member

@klkvr klkvr commented Oct 21, 2024

Motivation

For EIP-7702 authorization any v value <2**8 is valid during decoding and should be attempted for recovery. During recovery, only 0 and 1 values should be accepted.

Solution

This removes inner signature: Signature field from authorization, replacing it with separate v, r, s fields. fn signature now returns a result of conversion of vrs to signature

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

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

yeah this should work

@onbjerg onbjerg added the bug Something isn't working label Oct 21, 2024
@onbjerg
Copy link
Member

onbjerg commented Oct 21, 2024

Note, this is likely a breaking change for the codec in Reth, meaning this would not work on Odyssey

crates/eip7702/src/auth_list.rs Show resolved Hide resolved
Comment on lines +111 to +112
#[cfg_attr(feature = "serde", serde(rename = "yParity"))]
y_parity: U8,
Copy link
Member

Choose a reason for hiding this comment

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

let's add some context here that any U8 is valid but will be invalid for evm?

#[cfg_attr(feature = "serde", serde(rename = "yParity"))]
y_parity: U8,
r: U256,
s: U256,
Copy link
Member

Choose a reason for hiding this comment

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

I order to write them to disk on reth we also need getters for all the fields

we need ensure that we can do:

https://github.com/paradigmxyz/reth/blob/cab76f2083be680afa4ddcff44420334dd0e71a5/crates/storage/codecs/src/alloy/authorization_list.rs#L42-L69

}

/// Returns the signature parity value.
pub const fn y_parity(&self) -> U8 {
Copy link
Member

Choose a reason for hiding this comment

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

can we do u8 here so that the caller doesn't have to do this?

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

last pedantic nit

pub const fn signature(&self) -> &Signature {
&self.signature
/// Creates a new signed authorization from raw signature values.
pub fn new_unchecked(inner: Authorization, y_parity: U8, r: U256, s: U256) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
pub fn new_unchecked(inner: Authorization, y_parity: U8, r: U256, s: U256) -> Self {
pub fn new_unchecked(inner: Authorization, y_parity: u8, r: U256, s: U256) -> Self {

@klkvr klkvr merged commit c547cac into main Oct 22, 2024
26 checks passed
@klkvr klkvr deleted the klkvr/correct-parity branch October 22, 2024 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants