From 73523435c695f7846180e2adad48484e8e86d730 Mon Sep 17 00:00:00 2001 From: Enrique Ortiz Date: Wed, 24 Jan 2024 16:50:48 -0400 Subject: [PATCH 1/4] feat(primitives): add fn to get v as 27,28 in the case of a non eip155 sig --- crates/primitives/src/signature/parity.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/primitives/src/signature/parity.rs b/crates/primitives/src/signature/parity.rs index c83ce3e74..c1b71e789 100644 --- a/crates/primitives/src/signature/parity.rs +++ b/crates/primitives/src/signature/parity.rs @@ -83,6 +83,15 @@ impl Parity { self.y_parity() as u8 } + /// Return the y-parity byte as 27 or 28, + /// In the case of a non-EIP155 signature. + pub const fn y_parity_byte_legacy(&self) -> Option { + match self { + Self::NonEip155(v) => Some(*v as u8 + 27), + _ => None, + } + } + /// Inverts the parity. pub const fn inverted(&self) -> Self { match *self { From f24a9a17cad0d76cbe27aef85ede1936c465f47c Mon Sep 17 00:00:00 2001 From: Enrique Ortiz Date: Wed, 24 Jan 2024 17:00:32 -0400 Subject: [PATCH 2/4] rename --- crates/primitives/src/signature/parity.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/primitives/src/signature/parity.rs b/crates/primitives/src/signature/parity.rs index c1b71e789..d07868b83 100644 --- a/crates/primitives/src/signature/parity.rs +++ b/crates/primitives/src/signature/parity.rs @@ -85,7 +85,7 @@ impl Parity { /// Return the y-parity byte as 27 or 28, /// In the case of a non-EIP155 signature. - pub const fn y_parity_byte_legacy(&self) -> Option { + pub const fn y_parity_byte_non_eip155(&self) -> Option { match self { Self::NonEip155(v) => Some(*v as u8 + 27), _ => None, From 50ebf49da5c8dcfc765267af4a4049119f4d77ab Mon Sep 17 00:00:00 2001 From: Enrique Date: Thu, 25 Jan 2024 12:30:16 -0400 Subject: [PATCH 3/4] Update crates/primitives/src/signature/parity.rs Co-authored-by: Bjerg --- crates/primitives/src/signature/parity.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/primitives/src/signature/parity.rs b/crates/primitives/src/signature/parity.rs index d07868b83..4bbc0dcc1 100644 --- a/crates/primitives/src/signature/parity.rs +++ b/crates/primitives/src/signature/parity.rs @@ -84,7 +84,7 @@ impl Parity { } /// Return the y-parity byte as 27 or 28, - /// In the case of a non-EIP155 signature. + /// in the case of a non-EIP155 signature. pub const fn y_parity_byte_non_eip155(&self) -> Option { match self { Self::NonEip155(v) => Some(*v as u8 + 27), From 9a923d507ab7e8b521304c2b49d26ee749e54625 Mon Sep 17 00:00:00 2001 From: Enrique Ortiz Date: Thu, 25 Jan 2024 13:06:04 -0400 Subject: [PATCH 4/4] feat: also apply + 27 in the simple Parity case --- crates/primitives/src/signature/parity.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/primitives/src/signature/parity.rs b/crates/primitives/src/signature/parity.rs index 4bbc0dcc1..f2b43dc98 100644 --- a/crates/primitives/src/signature/parity.rs +++ b/crates/primitives/src/signature/parity.rs @@ -87,7 +87,7 @@ impl Parity { /// in the case of a non-EIP155 signature. pub const fn y_parity_byte_non_eip155(&self) -> Option { match self { - Self::NonEip155(v) => Some(*v as u8 + 27), + Self::NonEip155(v) | Self::Parity(v) => Some(*v as u8 + 27), _ => None, } }