Skip to content

Commit

Permalink
seal: distinguish client-side witness and public witness messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Nov 13, 2024
1 parent a3bf2da commit 71eb981
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions single_use_seals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,24 +137,26 @@ pub trait SingleUseSeal: Clone + Debug + Display {
}

pub trait ClientSideWitness {
type Message;
type Seal: SingleUseSeal;
type Error: Clone + Error;

fn convolve_commit(
&self,
msg: <Self::Seal as SingleUseSeal>::Message,
msg: Self::Message,
) -> Result<<Self::Seal as SingleUseSeal>::Message, Self::Error>;
}

#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, Default)]
pub struct NoWitness<Seal: SingleUseSeal>(PhantomData<Seal>);
impl<Seal: SingleUseSeal> ClientSideWitness for NoWitness<Seal> {
type Message = Seal::Message;
type Seal = Seal;
type Error = Infallible;

fn convolve_commit(
&self,
msg: <Self::Seal as SingleUseSeal>::Message,
msg: Self::Message,
) -> Result<<Self::Seal as SingleUseSeal>::Message, Self::Error> {
Ok(msg)
}
Expand Down Expand Up @@ -188,15 +190,15 @@ where Seal: SingleUseSeal
pub fn verify_seal_closing(
&self,
seal: impl Borrow<Seal>,
message: Seal::Message,
message: <Seal::CliWitness as ClientSideWitness>::Message,
) -> Result<(), SealError<Seal>> {
self.verify_seals_closing([seal], message)
}

pub fn verify_seals_closing(
&self,
seals: impl IntoIterator<Item = impl Borrow<Seal>>,
message: Seal::Message,
message: <Seal::CliWitness as ClientSideWitness>::Message,
) -> Result<(), SealError<Seal>> {
// ensure that witness includes all seals
for seal in seals {
Expand Down

0 comments on commit 71eb981

Please sign in to comment.