Trait commit_verify::api::EmbedCommitVerify [−][src]
pub trait EmbedCommitVerify<M> where
Self: Sized + Eq, {
type Container: Clone;
type Error: Error;
fn embed_commit(
container: &mut Self::Container,
msg: &M
) -> Result<Self, Self::Error>;
fn verify(
&self,
container: &Self::Container,
msg: &M
) -> Result<bool, Self::Error> { ... }
}
Expand description
Trait for embed-commit-verify scheme, where some data structure (named container) may commit to existing message (producing commitment data structure) in such way that the original message can’t be restored from the commitment, however the fact of the commitment may be deterministically checked when the message is revealed against the original container.
To use embed-commit-verify scheme one needs to implement this trait for the commitment data structure and provide it (through associated types) with the used container type.
Operations with embed-commit-verify scheme may be represented in form of
EmbedCommit: (Container, Message) -> Commitment
and
Verify: (Commitment, Container, Message) -> bool
; the original container
is required for the verification procedure.
This trait is heavily used in deterministic bitcoin commitments
Associated Types
Error type that may be reported during `EmbedCommitVerify::embed_commit`` procedure
Required methods
Provided methods
Verifies commitment against the message; default implementation just
takes original container
, repeats the commitment to the message and
check it against the self
.
Verification is a failable procedure returning bool. The difference
between returning Ok(false)
and Err(_)
is the following:
Err(_)
: validation was not possible due to container data structure- related error or some internal error during the validation process. It is undefined whether the message corresponds to the commitment.Ok(false)
: validation was performed completely; the message does not correspond to the commitmentOk(true)
: validation was performed completely; the message does correspond to the commitment