Skip to content

Commit

Permalink
commit: require result of verify functions to be used
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 15, 2023
1 parent d9161f0 commit 9a49cb2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions commit_verify/src/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ where Self: Eq + Sized
/// Verifies commitment against the message; default implementation just
/// repeats the commitment to the message and check it against the `self`.
#[inline]
#[must_use = "the boolean inside Ok(_) must be used since it carries the result of the \
validation"]
fn verify(&self, msg: &Msg) -> bool { Self::commit(msg) == *self }
}

Expand All @@ -63,6 +65,8 @@ where Self: Eq + Sized
/// just repeats the commitment to the message and check it against the
/// `self`.
#[inline]
#[must_use = "the boolean inside Ok(_) must be used since it carries the result of the \
validation"]
fn try_verify(&self, msg: &Msg) -> Result<bool, Self::Error> {
Ok(Self::try_commit(msg)? == *self)
}
Expand Down
2 changes: 2 additions & 0 deletions commit_verify/src/convolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ where
/// However if the proofs are provided by some sort of user/network input
/// from an untrusted party, a proper form would be
/// `if commitment.verify(...).unwrap_or(false) { .. }`.
#[must_use = "the boolean inside Ok(_) must be used since it carries the result of the \
validation"]
fn verify(
&self,
msg: &Msg,
Expand Down
2 changes: 2 additions & 0 deletions commit_verify/src/embed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ where
/// from an untrusted party, a proper form would be
/// `if commitment.verify(...).unwrap_or(false) { .. }`.
#[inline]
#[must_use = "the boolean inside Ok(_) must be used since it carries the result of the \
validation"]
fn verify(&self, msg: &Msg, proof: &Self::Proof) -> Result<bool, Self::VerifyError>
where
Self: VerifyEq,
Expand Down

0 comments on commit 9a49cb2

Please sign in to comment.