pub trait Verifiable: Sized {
    // Required methods
    fn unsigned_payload(&self) -> Result<Vec<u8>, Error>;
    fn signature(&self) -> &Signature;
    fn label(&self) -> &str;

    // Provided methods
    fn verify<T>(
        self,
        crypto: &impl OpenMlsCrypto,
        pk: &OpenMlsSignaturePublicKey
    ) -> Result<T, SignatureError>
       where T: VerifiedStruct<Self> { ... }
    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 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.

Provided Methods§

source

fn verify<T>( self, crypto: &impl OpenMlsCrypto, pk: &OpenMlsSignaturePublicKey ) -> Result<T, SignatureError>where T: VerifiedStruct<Self>,

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(Self::VerifiedOutput) if the signature is valid and CredentialError::InvalidSignature otherwise.

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.

Implementors§