pub struct VerificationMiddleware { /* private fields */ }Expand description
Middleware that verifies bytecode signatures before allowing execution.
Implementations§
Source§impl VerificationMiddleware
impl VerificationMiddleware
Sourcepub fn new(trusted_keys: Vec<[u8; 32]>) -> Self
pub fn new(trusted_keys: Vec<[u8; 32]>) -> Self
Create a new middleware with at least one trusted public key.
Sourcepub fn with_strict(self, strict: bool) -> Self
pub fn with_strict(self, strict: bool) -> Self
Toggle strict mode. When strict (default), unsigned bytecode is rejected.
Sourcepub fn add_trusted_key(&mut self, public_key: [u8; 32])
pub fn add_trusted_key(&mut self, public_key: [u8; 32])
Add a new trusted public key (for key rotation).
Sourcepub fn remove_trusted_key(&mut self, public_key: &[u8; 32])
pub fn remove_trusted_key(&mut self, public_key: &[u8; 32])
Remove a trusted public key (e.g., revoke a compromised key).
Sourcepub fn trusted_key_count(&self) -> usize
pub fn trusted_key_count(&self) -> usize
Number of currently trusted keys.
Sourcepub fn verify(
&self,
bytecode: &[u8],
signature: &Signature,
) -> VerificationResult
pub fn verify( &self, bytecode: &[u8], signature: &Signature, ) -> VerificationResult
Verify bytecode against all trusted public keys.
Returns Ok(VerificationResult) if any trusted key validates the signature.
Returns an error result if none match or if the bytecode is tampered.
Sourcepub fn verify_or_reject(
&self,
bytecode: &[u8],
signature: &Signature,
) -> Result<usize, String>
pub fn verify_or_reject( &self, bytecode: &[u8], signature: &Signature, ) -> Result<usize, String>
Verify bytecode or return an error message suitable for API responses.
Sourcepub fn allow_unsigned(&self) -> bool
pub fn allow_unsigned(&self) -> bool
Check whether unsigned bytecode should be allowed (depends on strict mode).
Auto Trait Implementations§
impl Freeze for VerificationMiddleware
impl RefUnwindSafe for VerificationMiddleware
impl Send for VerificationMiddleware
impl Sync for VerificationMiddleware
impl Unpin for VerificationMiddleware
impl UnsafeUnpin for VerificationMiddleware
impl UnwindSafe for VerificationMiddleware
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more