Skip to content

Commit

Permalink
seals: add Eq bound to ClinetSideWitness
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 22, 2024
1 parent 01ed41f commit 3b0be3c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions single_use_seals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub trait SingleUseSeal:
fn is_included(&self, message: Self::Message, witness: &SealWitness<Self>) -> bool;
}

pub trait ClientSideWitness {
pub trait ClientSideWitness: Eq {
/// Client-side witness is specific to just one type of single-use seals,
/// provided as an associated type.
type Seal: SingleUseSeal;
Expand All @@ -181,8 +181,14 @@ pub trait ClientSideWitness {
) -> Result<Self::Proof, Self::Error>;
}

#[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, Default)]
#[derive(Copy, Clone, Debug, Default)]
pub struct NoWitness<Seal: SingleUseSeal>(PhantomData<Seal>);

impl<Seal: SingleUseSeal> PartialEq for NoWitness<Seal> {
fn eq(&self, _: &Self) -> bool { true }
}
impl<Seal: SingleUseSeal> Eq for NoWitness<Seal> {}

impl<Seal: SingleUseSeal> ClientSideWitness for NoWitness<Seal> {
type Seal = Seal;
type Proof = Seal::Message;
Expand Down

0 comments on commit 3b0be3c

Please sign in to comment.