From a625ed95943ba862b7f7b975d34ed837b2a3aba4 Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Wed, 13 Nov 2024 21:14:31 +0100 Subject: [PATCH] seal: distinguish client-side witness and public witness messages --- single_use_seals/src/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/single_use_seals/src/lib.rs b/single_use_seals/src/lib.rs index f2e2a352..b3860cb2 100644 --- a/single_use_seals/src/lib.rs +++ b/single_use_seals/src/lib.rs @@ -128,7 +128,7 @@ use core::marker::PhantomData; /// pub trait SingleUseSeal: Clone + Debug + Display { /// Message type that is supported by the current single-use-seal. - type Message: Copy; + type Message; type PubWitness: PublishedWitness; type CliWitness: ClientSideWitness; @@ -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: ::Message, + msg: Self::Message, ) -> Result<::Message, Self::Error>; } #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, Default)] pub struct NoWitness(PhantomData); impl ClientSideWitness for NoWitness { + type Message = Seal::Message; type Seal = Seal; type Error = Infallible; fn convolve_commit( &self, - msg: ::Message, + msg: Self::Message, ) -> Result<::Message, Self::Error> { Ok(msg) } @@ -188,7 +190,7 @@ where Seal: SingleUseSeal pub fn verify_seal_closing( &self, seal: impl Borrow, - message: Seal::Message, + message: ::Message, ) -> Result<(), SealError> { self.verify_seals_closing([seal], message) } @@ -196,7 +198,7 @@ where Seal: SingleUseSeal pub fn verify_seals_closing( &self, seals: impl IntoIterator>, - message: Seal::Message, + message: ::Message, ) -> Result<(), SealError> { // ensure that witness includes all seals for seal in seals {