pub struct CredentialVerifier<'a, S: NonceStorage> { /* private fields */ }Expand description
A verifier for NonceCredentials, created by NonceServer::credential_verifier.
This builder-like struct provides a safe and ergonomic API for verifying credentials.
Implementations§
Source§impl<'a, S: NonceStorage> CredentialVerifier<'a, S>
impl<'a, S: NonceStorage> CredentialVerifier<'a, S>
Sourcepub fn with_context(self, context: Option<&'a str>) -> Self
pub fn with_context(self, context: Option<&'a str>) -> Self
Sets the context for this verification operation.
The context provides an additional layer of isolation for nonces.
Sourcepub fn with_secret(self, secret: &'a [u8]) -> Self
pub fn with_secret(self, secret: &'a [u8]) -> Self
Sets the secret key for this verification operation.
This is required for signature verification. Each user/client may have a different secret.
Sourcepub async fn verify(self, payload: &[u8]) -> Result<(), NonceError>
pub async fn verify(self, payload: &[u8]) -> Result<(), NonceError>
Verifies the credential against a standard payload.
This is the recommended verification method for most use cases. It assumes the
signature was created on the client using sign(payload).
§Arguments
payload: The payload that was signed on the client side.
Sourcepub async fn verify_with<F>(
self,
signature_builder: F,
) -> Result<(), NonceError>
pub async fn verify_with<F>( self, signature_builder: F, ) -> Result<(), NonceError>
Verifies the credential using custom signature-reconstruction logic.
This method is for advanced scenarios where the signature includes more than just the standard payload.
§Warning
The logic in the signature_builder closure must exactly match the logic
used on the client side in sign_with, otherwise verification will fail.
§Arguments
signature_builder: A closure to reconstruct the signed data.