feat(stateless): make UncompressedPublicKey serializable (#19115)

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
This commit is contained in:
Ignacio Hagopian
2025-10-18 05:41:56 -03:00
committed by GitHub
parent 8d91b9e443
commit 46228d0a18
2 changed files with 19 additions and 2 deletions

View File

@@ -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
}
}
/// Verifies all transactions in a block against a list of public keys and signatures.
///

View File

@@ -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>, _>>()