Skip to content

Commit

Permalink
refactor: use simple boolean for parity in signature (#776)
Browse files Browse the repository at this point in the history
* wip

* fix doc

* fmt
  • Loading branch information
klkvr authored Oct 28, 2024
1 parent e715933 commit 0ee0afe
Show file tree
Hide file tree
Showing 5 changed files with 605 additions and 6 deletions.
4 changes: 3 additions & 1 deletion crates/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ mod signed;
pub use signed::{BigIntConversionError, ParseSignedError, Sign, Signed};

mod signature;
pub use signature::{to_eip155_v, Parity, Signature, SignatureError};
pub use signature::{
normalize_v, to_eip155_v, Parity, PrimitiveSignature, Signature, SignatureError,
};

pub mod utils;
pub use utils::{eip191_hash_message, keccak256, Keccak256};
Expand Down
5 changes: 4 additions & 1 deletion crates/primitives/src/signature/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ mod sig;
pub use sig::Signature;

mod utils;
pub use utils::to_eip155_v;
pub use utils::{normalize_v, to_eip155_v};

mod primitive_sig;
pub use primitive_sig::PrimitiveSignature;
2 changes: 1 addition & 1 deletion crates/primitives/src/signature/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl Parity {
#[cfg(feature = "k256")]
pub const fn recid(&self) -> k256::ecdsa::RecoveryId {
let recid_opt = match self {
Self::Eip155(v) => Some(crate::signature::utils::normalize_v(*v)),
Self::Eip155(v) => Some(crate::signature::utils::normalize_v_to_recid(*v)),
Self::NonEip155(b) | Self::Parity(b) => k256::ecdsa::RecoveryId::from_byte(*b as u8),
};

Expand Down
Loading

0 comments on commit 0ee0afe

Please sign in to comment.