pub trait Verifiable: Sized {
type VerifiedStruct: VerifiedStruct;
// Required methods
fn unsigned_payload(&self) -> Result<Vec<u8>, Error>;
fn signature(&self) -> &Signature;
fn label(&self) -> &str;
fn verify(
self,
crypto: &impl OpenMlsCrypto,
pk: &OpenMlsSignaturePublicKey,
) -> Result<Self::VerifiedStruct, SignatureError>;
// Provided method
fn verify_no_out(
&self,
crypto: &impl OpenMlsCrypto,
pk: &OpenMlsSignaturePublicKey,
) -> Result<(), SignatureError> { ... }
}Expand description
The verifiable trait must be implemented by any struct that is signed with
a credential. The actual verify method is provided.
The unsigned_payload and signature functions have to be implemented for
each struct, returning the serialized payload and the signature respectively.
Note that Verifiable should not be implemented on the same struct as
Signable. If this appears to be necessary, it is probably a sign that the
struct implementing them aren’t well defined. Not that both traits define an
unsigned_payload function.
Required Associated Types§
Sourcetype VerifiedStruct: VerifiedStruct
type VerifiedStruct: VerifiedStruct
The type used for representing the verified data. Must implement the marker trait
VerifiedStruct.
Required Methods§
Sourcefn unsigned_payload(&self) -> Result<Vec<u8>, Error>
fn unsigned_payload(&self) -> Result<Vec<u8>, Error>
Return the unsigned, serialized payload that should be verified.
Sourcefn verify(
self,
crypto: &impl OpenMlsCrypto,
pk: &OpenMlsSignaturePublicKey,
) -> Result<Self::VerifiedStruct, SignatureError>
fn verify( self, crypto: &impl OpenMlsCrypto, pk: &OpenMlsSignaturePublicKey, ) -> Result<Self::VerifiedStruct, SignatureError>
Verifies the payload against the given credential.
Usually this is implemented by first checking that self.verify_no_out()
does not return an error, and then converting the value into
Self::VerifiedStruct.
Returns Ok(Self::VerifiedOutput) if the signature is valid and
CredentialError::InvalidSignature otherwise.
Provided Methods§
Sourcefn verify_no_out(
&self,
crypto: &impl OpenMlsCrypto,
pk: &OpenMlsSignaturePublicKey,
) -> Result<(), SignatureError>
fn verify_no_out( &self, crypto: &impl OpenMlsCrypto, pk: &OpenMlsSignaturePublicKey, ) -> Result<(), SignatureError>
Verifies the payload against the given public key.
The signature is fetched via the Verifiable::signature() function and
the payload via Verifiable::unsigned_payload().
Returns Ok(()) if the signature is valid and
SignatureError::VerificationError otherwise.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.