mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-17 21:08:32 +00:00
Skeleton
This commit is contained in:
committed by
realbigsean
parent
48b2efce9f
commit
3288404ec1
36
crypto/kzg/src/kzg_commitment.rs
Normal file
36
crypto/kzg/src/kzg_commitment.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use derivative::Derivative;
|
||||
use serde_big_array::BigArray;
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::fmt;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use tree_hash::{PackedEncoding, TreeHash};
|
||||
|
||||
#[derive(Derivative, Debug, Clone, Encode, Decode, Serialize, Deserialize)]
|
||||
#[derivative(PartialEq, Eq, Hash)]
|
||||
#[ssz(struct_behaviour = "transparent")]
|
||||
pub struct KzgCommitment(#[serde(with = "BigArray")] pub [u8; 48]);
|
||||
|
||||
impl Display for KzgCommitment {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", eth2_serde_utils::hex::encode(self.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl TreeHash for KzgCommitment {
|
||||
fn tree_hash_type() -> tree_hash::TreeHashType {
|
||||
<[u8; 48] as TreeHash>::tree_hash_type()
|
||||
}
|
||||
|
||||
fn tree_hash_packed_encoding(&self) -> PackedEncoding {
|
||||
self.0.tree_hash_packed_encoding()
|
||||
}
|
||||
|
||||
fn tree_hash_packing_factor() -> usize {
|
||||
<[u8; 48] as TreeHash>::tree_hash_packing_factor()
|
||||
}
|
||||
|
||||
fn tree_hash_root(&self) -> tree_hash::Hash256 {
|
||||
self.0.tree_hash_root()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user