feat(crypto): Add Key Evolving Signatures (KES)
This commit is contained in:
parent
33b076ad23
commit
7d79407163
11 changed files with 217 additions and 18 deletions
|
|
@ -52,7 +52,13 @@ impl ComputeHash<32> for alonzo::Header {
|
|||
}
|
||||
}
|
||||
|
||||
impl OriginalHash<32> for KeepRaw<'_, alonzo::Header> {
|
||||
impl OriginalHash<32> for KeepRaw<'_, alonzo::MintedHeader<'_>> {
|
||||
fn original_hash(&self) -> pallas_crypto::hash::Hash<32> {
|
||||
Hasher::<256>::hash(self.raw_cbor())
|
||||
}
|
||||
}
|
||||
|
||||
impl OriginalHash<32> for KeepRaw<'_, babbage::MintedHeader<'_>> {
|
||||
fn original_hash(&self) -> pallas_crypto::hash::Hash<32> {
|
||||
Hasher::<256>::hash(self.raw_cbor())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,6 +87,15 @@ impl<'b> MultiEraHeader<'b> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn header_body_cbor(&self) -> Option<&'b [u8]> {
|
||||
match self {
|
||||
MultiEraHeader::ShelleyCompatible(x) => Some(x.header_body.raw_cbor()),
|
||||
MultiEraHeader::BabbageCompatible(x) => Some(x.header_body.raw_cbor()),
|
||||
MultiEraHeader::EpochBoundary(_) => None,
|
||||
MultiEraHeader::Byron(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn vrf_vkey(&self) -> Option<&[u8]> {
|
||||
match self {
|
||||
MultiEraHeader::ShelleyCompatible(x) => Some(x.header_body.vrf_vkey.as_ref()),
|
||||
|
|
@ -137,14 +146,14 @@ impl<'b> MultiEraHeader<'b> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn as_alonzo(&self) -> Option<&alonzo::Header> {
|
||||
pub fn as_alonzo(&self) -> Option<&alonzo::MintedHeader> {
|
||||
match self {
|
||||
MultiEraHeader::ShelleyCompatible(x) => Some(x.deref().deref()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_babbage(&self) -> Option<&babbage::Header> {
|
||||
pub fn as_babbage(&self) -> Option<&babbage::MintedHeader> {
|
||||
match self {
|
||||
MultiEraHeader::BabbageCompatible(x) => Some(x.deref().deref()),
|
||||
_ => None,
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ pub enum Feature {
|
|||
#[derive(Debug)]
|
||||
pub enum MultiEraHeader<'b> {
|
||||
EpochBoundary(Cow<'b, KeepRaw<'b, byron::EbbHead>>),
|
||||
ShelleyCompatible(Cow<'b, KeepRaw<'b, alonzo::Header>>),
|
||||
BabbageCompatible(Cow<'b, KeepRaw<'b, babbage::Header>>),
|
||||
ShelleyCompatible(Cow<'b, KeepRaw<'b, alonzo::MintedHeader<'b>>>),
|
||||
BabbageCompatible(Cow<'b, KeepRaw<'b, babbage::MintedHeader<'b>>>),
|
||||
Byron(Cow<'b, KeepRaw<'b, byron::BlockHead>>),
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue