feat(crypto): Add Key Evolving Signatures (KES)
This commit is contained in:
parent
05f8b2bd07
commit
4871342a8d
11 changed files with 217 additions and 18 deletions
|
|
@ -69,15 +69,37 @@ pub type ProtocolVersion = (u64, u64);
|
|||
#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq)]
|
||||
pub struct KesSignature {}
|
||||
|
||||
pub type MintedHeaderBody<'a> = KeepRaw<'a, HeaderBody>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)]
|
||||
pub struct Header {
|
||||
pub struct PseudoHeader<T1> {
|
||||
#[n(0)]
|
||||
pub header_body: HeaderBody,
|
||||
pub header_body: T1,
|
||||
|
||||
#[n(1)]
|
||||
pub body_signature: Bytes,
|
||||
}
|
||||
|
||||
pub type Header = PseudoHeader<HeaderBody>;
|
||||
|
||||
pub type MintedHeader<'a> = KeepRaw<'a, PseudoHeader<MintedHeaderBody<'a>>>;
|
||||
|
||||
impl<'a> From<MintedHeader<'a>> for Header {
|
||||
fn from(x: MintedHeader<'a>) -> Self {
|
||||
let x = x.unwrap();
|
||||
Self {
|
||||
header_body: x.header_body.into(),
|
||||
body_signature: x.body_signature,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<MintedHeaderBody<'a>> for HeaderBody {
|
||||
fn from(x: MintedHeaderBody<'a>) -> Self {
|
||||
x.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, PartialOrd, Ord, Clone, StdHash,
|
||||
)]
|
||||
|
|
@ -1504,7 +1526,7 @@ pub struct Block {
|
|||
#[derive(Encode, Decode, Debug, PartialEq, Clone)]
|
||||
pub struct MintedBlock<'b> {
|
||||
#[n(0)]
|
||||
pub header: KeepRaw<'b, Header>,
|
||||
pub header: KeepRaw<'b, MintedHeader<'b>>,
|
||||
|
||||
#[b(1)]
|
||||
pub transaction_bodies: MaybeIndefArray<KeepRaw<'b, TransactionBody>>,
|
||||
|
|
@ -1522,7 +1544,7 @@ pub struct MintedBlock<'b> {
|
|||
impl<'b> From<MintedBlock<'b>> for Block {
|
||||
fn from(x: MintedBlock<'b>) -> Self {
|
||||
Block {
|
||||
header: x.header.unwrap(),
|
||||
header: x.header.unwrap().into(),
|
||||
transaction_bodies: x
|
||||
.transaction_bodies
|
||||
.to_vec()
|
||||
|
|
|
|||
|
|
@ -66,15 +66,37 @@ pub use crate::alonzo::ProtocolVersion;
|
|||
|
||||
pub use crate::alonzo::KesSignature;
|
||||
|
||||
pub type MintedHeaderBody<'a> = KeepRaw<'a, HeaderBody>;
|
||||
|
||||
#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Eq, Clone)]
|
||||
pub struct Header {
|
||||
pub struct PseudoHeader<T1> {
|
||||
#[n(0)]
|
||||
pub header_body: HeaderBody,
|
||||
pub header_body: T1,
|
||||
|
||||
#[n(1)]
|
||||
pub body_signature: Bytes,
|
||||
}
|
||||
|
||||
pub type Header = PseudoHeader<HeaderBody>;
|
||||
|
||||
pub type MintedHeader<'a> = KeepRaw<'a, PseudoHeader<MintedHeaderBody<'a>>>;
|
||||
|
||||
impl<'a> From<MintedHeader<'a>> for Header {
|
||||
fn from(x: MintedHeader<'a>) -> Self {
|
||||
let x = x.unwrap();
|
||||
Self {
|
||||
header_body: x.header_body.into(),
|
||||
body_signature: x.body_signature,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<MintedHeaderBody<'a>> for HeaderBody {
|
||||
fn from(x: MintedHeaderBody<'a>) -> Self {
|
||||
x.unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
pub use crate::alonzo::TransactionInput;
|
||||
|
||||
pub use crate::alonzo::NonceVariant;
|
||||
|
|
@ -706,7 +728,7 @@ pub type Block = PseudoBlock<Header, TransactionBody, WitnessSet, AuxiliaryData>
|
|||
/// original CBOR bytes for each structure that might require hashing. In this
|
||||
/// way, we make sure that the resulting hash matches what exists on-chain.
|
||||
pub type MintedBlock<'b> = PseudoBlock<
|
||||
KeepRaw<'b, Header>,
|
||||
KeepRaw<'b, MintedHeader<'b>>,
|
||||
KeepRaw<'b, MintedTransactionBody<'b>>,
|
||||
KeepRaw<'b, MintedWitnessSet<'b>>,
|
||||
KeepRaw<'b, AuxiliaryData>,
|
||||
|
|
@ -715,7 +737,7 @@ pub type MintedBlock<'b> = PseudoBlock<
|
|||
impl<'b> From<MintedBlock<'b>> for Block {
|
||||
fn from(x: MintedBlock<'b>) -> Self {
|
||||
Block {
|
||||
header: x.header.unwrap(),
|
||||
header: x.header.unwrap().into(),
|
||||
transaction_bodies: MaybeIndefArray::Def(
|
||||
x.transaction_bodies
|
||||
.iter()
|
||||
|
|
|
|||
|
|
@ -1619,6 +1619,7 @@ pub use crate::alonzo::Metadata;
|
|||
pub use crate::alonzo::AuxiliaryData;
|
||||
|
||||
pub use crate::alonzo::TransactionIndex;
|
||||
use crate::babbage::MintedHeader;
|
||||
|
||||
#[derive(Serialize, Deserialize, Encode, Decode, Debug, PartialEq, Clone)]
|
||||
pub struct PseudoBlock<T1, T2, T3, T4>
|
||||
|
|
@ -1649,7 +1650,7 @@ pub type Block = PseudoBlock<Header, TransactionBody, WitnessSet, AuxiliaryData>
|
|||
/// original CBOR bytes for each structure that might require hashing. In this
|
||||
/// way, we make sure that the resulting hash matches what exists on-chain.
|
||||
pub type MintedBlock<'b> = PseudoBlock<
|
||||
KeepRaw<'b, Header>,
|
||||
KeepRaw<'b, MintedHeader<'b>>,
|
||||
KeepRaw<'b, MintedTransactionBody<'b>>,
|
||||
KeepRaw<'b, MintedWitnessSet<'b>>,
|
||||
KeepRaw<'b, AuxiliaryData>,
|
||||
|
|
@ -1658,7 +1659,7 @@ pub type MintedBlock<'b> = PseudoBlock<
|
|||
impl<'b> From<MintedBlock<'b>> for Block {
|
||||
fn from(x: MintedBlock<'b>) -> Self {
|
||||
Block {
|
||||
header: x.header.unwrap(),
|
||||
header: x.header.unwrap().into(),
|
||||
transaction_bodies: MaybeIndefArray::Def(
|
||||
x.transaction_bodies
|
||||
.iter()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue