tempo_primitives/reth_compat/ed25519.rs
1use alloy_rlp::Encodable;
2
3use crate::ed25519::PublicKey;
4
5impl reth_primitives_traits::InMemorySize for PublicKey {
6 fn size(&self) -> usize {
7 self.length()
8 }
9}
10
11#[cfg(feature = "reth-codec")]
12mod codec {
13 use crate::ed25519::PublicKey;
14 use alloy_primitives::B256;
15 use reth_codecs::Compact;
16
17 impl Compact for PublicKey {
18 fn to_compact<B>(&self, buf: &mut B) -> usize
19 where
20 B: alloy_rlp::bytes::BufMut + AsMut<[u8]>,
21 {
22 B256::from(self).to_compact(buf)
23 }
24
25 fn from_compact(buf: &[u8], len: usize) -> (Self, &[u8]) {
26 let (bytes, buf) = B256::from_compact(buf, len);
27 (
28 bytes.try_into().expect("well formed ed25519 public key"),
29 buf,
30 )
31 }
32 }
33}