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§

source

type VerifiedStruct: VerifiedStruct

The type used for representing the verified data. Must implement the marker trait VerifiedStruct.

Required Methods§

source

fn unsigned_payload(&self) -> Result<Vec<u8>, Error>

Return the unsigned, serialized payload that should be verified.

source

fn signature(&self) -> &Signature

A reference to the signature to be verified.

source

fn label(&self) -> &str

Return the string label used for labeled verification.

source

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§

source

fn verify_no_out( &self, crypto: &impl OpenMlsCrypto, pk: &OpenMlsSignaturePublicKey ) -> Result<(), SignatureError>

Verifies the payload against the given credential. The signature is fetched via the Verifiable::signature() function and the payload via Verifiable::unsigned_payload().

Returns Ok(()) if the signature is valid and CredentialError::InvalidSignature otherwise.

Object Safety§

This trait is not object safe.

Implementors§