Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ arbitrary = "1.3"
# for 7702 signed authorization list arbitrary
k256 = { version = "0.13", default-features = false, features = ["ecdsa"] }
rand = "0.8"

[patch.crates-io]
alloy-primitives = { git = "https://github.com/alloy-rs/core", rev = "237cfc4" }
12 changes: 6 additions & 6 deletions crates/eip7702/src/auth_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use core::ops::Deref;

#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use alloy_primitives::{keccak256, Address, PrimitiveSignature, SignatureError, B256, U256, U8};
use alloy_primitives::{keccak256, Address, Signature, SignatureError, B256, U256, U8};
use alloy_rlp::{
length_of_length, BufMut, Decodable, Encodable, Header, Result as RlpResult, RlpDecodable,
RlpEncodable,
Expand Down Expand Up @@ -92,7 +92,7 @@ impl Authorization {
}

/// Convert to a signed authorization by adding a signature.
pub fn into_signed(self, signature: PrimitiveSignature) -> SignedAuthorization {
pub fn into_signed(self, signature: Signature) -> SignedAuthorization {
SignedAuthorization {
inner: self,
r: signature.r(),
Expand Down Expand Up @@ -130,9 +130,9 @@ impl SignedAuthorization {
///
/// Note that this signature might still be invalid for recovery as it might have `s` value
/// greater than [secp256k1n/2](crate::constants::SECP256K1N_HALF).
pub fn signature(&self) -> Result<PrimitiveSignature, SignatureError> {
pub fn signature(&self) -> Result<Signature, SignatureError> {
if self.y_parity() <= 1 {
Ok(PrimitiveSignature::new(self.r, self.s, self.y_parity() == 1))
Ok(Signature::new(self.r, self.s, self.y_parity() == 1))
} else {
Err(SignatureError::InvalidParity(self.y_parity() as u64))
}
Expand Down Expand Up @@ -291,7 +291,7 @@ impl<'a> arbitrary::Arbitrary<'a> for SignedAuthorization {
let (recoverable_sig, recovery_id) =
signing_key.sign_prehash(signature_hash.as_ref()).unwrap();
let signature =
PrimitiveSignature::from_signature_and_parity(recoverable_sig, recovery_id.is_y_odd());
Signature::from_signature_and_parity(recoverable_sig, recovery_id.is_y_odd());

Ok(inner.into_signed(signature))
}
Expand Down Expand Up @@ -397,7 +397,7 @@ mod tests {
let auth =
Authorization { chain_id: 1u64, address: Address::left_padding_from(&[6]), nonce: 1 };

let auth = auth.into_signed(PrimitiveSignature::from_str("48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c8041b").unwrap());
let auth = auth.into_signed(Signature::from_str("48b55bfa915ac795c431978d8a6a992b628d557da5ff759b307d495a36649353efffd310ac743f371de3b9f7f9cb56c0b28ad43601b4ab949f53faa07bd2c8041b").unwrap());
let mut buf = Vec::new();
auth.encode(&mut buf);

Expand Down