reth_primitives_traits/transaction/
signature.rs

1//! Signature types and helpers
2
3/// Re-exported signature type
4pub use alloy_primitives::PrimitiveSignature as Signature;
5
6#[cfg(test)]
7mod tests {
8    use crate::crypto::secp256k1::recover_signer;
9    use alloy_primitives::{address, PrimitiveSignature as Signature, B256, U256};
10    use std::str::FromStr;
11
12    #[test]
13    fn test_recover_signer() {
14        let signature = Signature::new(
15            U256::from_str(
16                "18515461264373351373200002665853028612451056578545711640558177340181847433846",
17            )
18            .unwrap(),
19            U256::from_str(
20                "46948507304638947509940763649030358759909902576025900602547168820602576006531",
21            )
22            .unwrap(),
23            false,
24        );
25        let hash =
26            B256::from_str("daf5a779ae972f972197303d7b574746c7ef83eadac0f2791ad23db92e4c8e53")
27                .unwrap();
28        let signer = recover_signer(&signature, hash).unwrap();
29        let expected = address!("0x9d8a62f656a8d1615c1294fd71e9cfb3e4855a4f");
30        assert_eq!(expected, signer);
31    }
32}