Skip to content

Commit 6a3a043

Browse files
Evalironbjerg
andauthored
feat(primitives): Add y_parity_byte_non_eip155 to Parity (#499)
* feat(primitives): add fn to get v as 27,28 in the case of a non eip155 sig * rename * Update crates/primitives/src/signature/parity.rs Co-authored-by: Bjerg <onbjerg@users.noreply.github.com> * feat: also apply + 27 in the simple Parity case --------- Co-authored-by: Bjerg <onbjerg@users.noreply.github.com>
1 parent f5fbc85 commit 6a3a043

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

crates/primitives/src/signature/parity.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ impl Parity {
8383
self.y_parity() as u8
8484
}
8585

86+
/// Return the y-parity byte as 27 or 28,
87+
/// in the case of a non-EIP155 signature.
88+
pub const fn y_parity_byte_non_eip155(&self) -> Option<u8> {
89+
match self {
90+
Self::NonEip155(v) | Self::Parity(v) => Some(*v as u8 + 27),
91+
_ => None,
92+
}
93+
}
94+
8695
/// Inverts the parity.
8796
pub const fn inverted(&self) -> Self {
8897
match *self {

0 commit comments

Comments
 (0)