Skip to content
Merged
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
15 changes: 14 additions & 1 deletion crates/stateless/src/recover_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,28 @@ use crate::validation::StatelessValidationError;
use alloc::vec::Vec;
use alloy_consensus::BlockHeader;
use alloy_primitives::{Address, Signature, B256};
use core::ops::Deref;
use reth_chainspec::EthereumHardforks;
use reth_ethereum_primitives::{Block, TransactionSigned};
use reth_primitives_traits::{Block as _, RecoveredBlock};
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, Bytes};

#[cfg(all(feature = "k256", feature = "secp256k1"))]
use k256 as _;

/// Serialized uncompressed public key
pub type UncompressedPublicKey = [u8; 65];
#[serde_as]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UncompressedPublicKey(#[serde_as(as = "Bytes")] pub [u8; 65]);

impl Deref for UncompressedPublicKey {
type Target = [u8];

fn deref(&self) -> &Self::Target {
&self.0
}
}
Comment on lines +20 to +26
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly to avoid vk.0 in other places where it is used. Open for feedback if you prefer to avoid Deref impl.


/// Verifies all transactions in a block against a list of public keys and signatures.
///
Expand Down
6 changes: 5 additions & 1 deletion testing/ef-tests/src/cases/blockchain_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,11 @@ where
.map(|(i, tx)| {
tx.signature()
.recover_from_prehash(&tx.signature_hash())
.map(|keys| keys.to_encoded_point(false).as_bytes().try_into().unwrap())
.map(|keys| {
UncompressedPublicKey(
keys.to_encoded_point(false).as_bytes().try_into().unwrap(),
)
})
.map_err(|e| format!("failed to recover signature for tx #{i}: {e}").into())
})
.collect::<Result<Vec<UncompressedPublicKey>, _>>()
Expand Down
Loading