zaun_community_protocol/client/
owner.rs1mod content;
6mod genesis;
7mod revise;
8
9pub use content::DescriptorContent;
10pub use genesis::{Genesis, create_body, delegate, genesis};
11pub use revise::{next_revision, publish_body, resign_delegation, rotate_root, rotated_revision};
12
13use super::BuildError;
14use crate::crypto::{self, SecretKey};
15use crate::ids::{HostId, RngError};
16use crate::keys::PublicKey;
17
18pub fn generate_root_key() -> Result<SecretKey, RngError> {
24 SecretKey::generate()
25}
26
27#[derive(Debug, Clone, PartialEq, Eq)]
29pub struct HostInfo {
30 pub public_key: PublicKey,
32 pub addresses: Vec<String>,
34}
35
36impl HostInfo {
37 #[must_use]
39 pub const fn new(public_key: PublicKey, addresses: Vec<String>) -> Self {
40 Self {
41 public_key,
42 addresses,
43 }
44 }
45
46 pub fn from_advertised(
51 host_id: HostId,
52 public_key: PublicKey,
53 addresses: Vec<String>,
54 ) -> Result<Self, BuildError> {
55 if crypto::host_id(&public_key) == host_id {
56 Ok(Self::new(public_key, addresses))
57 } else {
58 Err(BuildError::HostId)
59 }
60 }
61
62 #[must_use]
64 pub fn host_id(&self) -> HostId {
65 crypto::host_id(&self.public_key)
66 }
67}