p2panda_encryption/traits/
key_registry.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3use std::error::Error;
4use std::fmt::Debug;
5
6use serde::{Deserialize, Serialize};
7
8use crate::crypto::x25519::PublicKey;
9
10/// Manages public identity keys of other members.
11pub trait IdentityRegistry<ID, Y> {
12    type Error: Error;
13
14    fn identity_key(y: &Y, id: &ID) -> Result<Option<PublicKey>, Self::Error>;
15}
16
17/// Manages public key bundles of other members.
18pub trait PreKeyRegistry<ID, KB> {
19    type State: Debug + Serialize + for<'a> Deserialize<'a>;
20
21    type Error: Error;
22
23    fn key_bundle(y: Self::State, id: &ID) -> Result<(Self::State, Option<KB>), Self::Error>;
24}