mod codec;
pub mod membership;
pub mod peer;
mod persistence;
mod publication;
pub use publication::{PUBLICATION_BYTES, Publication, PublicationBinding, PublicationOutcome};
use std::fmt;
use anyhow::{Context, Result, ensure};
#[cfg(test)]
use ed25519_dalek::{Signer, SigningKey};
use zeroize::Zeroizing;
use super::{LocalSharedStatePackageContext, LocalSharedStatePackageKey};
#[cfg(test)]
use codec::{bytes, cce, hash};
pub use aven_protocol::claim::{
CLAIM_BYTES, ClaimAuthentication, ClaimRefusal, ClaimResult, GENESIS_BYTES, Genesis,
SEED_STORAGE_BYTES, Secret, SetupAuthority, StorageNotEmpty,
};
pub struct SeedAuthority(aven_protocol::claim::SeedAuthority);
impl fmt::Debug for SeedAuthority {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl std::ops::Deref for SeedAuthority {
type Target = aven_protocol::claim::SeedAuthority;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl SeedAuthority {
pub fn genesis(&self) -> &Genesis {
self.0.genesis()
}
pub fn bearer(&self) -> &Secret {
self.0.bearer()
}
pub fn protected_storage_bytes(&self) -> Zeroizing<Vec<u8>> {
self.0.protected_storage_bytes()
}
fn validate(
&self,
context: LocalSharedStatePackageContext,
key: &LocalSharedStatePackageKey,
) -> Result<()> {
self.0.validate(context, key)
}
pub fn generate(
context: LocalSharedStatePackageContext,
key: &LocalSharedStatePackageKey,
setup: [u8; 32],
) -> Result<Self> {
aven_protocol::claim::SeedAuthority::generate(context, key, setup).map(Self)
}
pub fn from_protected_storage(
raw: &[u8],
context: LocalSharedStatePackageContext,
key: &LocalSharedStatePackageKey,
) -> Result<Self> {
aven_protocol::claim::SeedAuthority::from_protected_storage(raw, context, key).map(Self)
}
}
#[cfg(test)]
mod tests;