pub struct SelfAgentVerifier { /* private fields */ }Expand description
Service-side verifier for Self Agent ID requests.
Security chain:
- Recover signer address from ECDSA signature
- Derive agent key: zeroPadValue(recoveredAddress, 32)
- Check on-chain: isVerifiedAgent(agentKey)
- Check proof provider matches selfProofProvider()
- Check timestamp freshness (replay protection)
- Sybil resistance check
- Credential checks (age, OFAC, nationality)
- Rate limiting
§Construction
use self_agent_sdk::{
NetworkName, SelfAgentVerifier, VerifierConfig, VerifierFromConfig,
};
// Direct construction
let verifier = SelfAgentVerifier::new(VerifierConfig::default());
// Chainable builder
let verifier = SelfAgentVerifier::create()
.network(NetworkName::Testnet)
.require_age(18)
.require_ofac()
.build();
// From config object
let verifier = SelfAgentVerifier::from_config(VerifierFromConfig {
network: Some(NetworkName::Testnet),
require_age: Some(18),
..Default::default()
});Implementations§
Source§impl SelfAgentVerifier
impl SelfAgentVerifier
Sourcepub fn new(config: VerifierConfig) -> Self
pub fn new(config: VerifierConfig) -> Self
Create a new verifier instance from a VerifierConfig.
Sourcepub fn create() -> VerifierBuilder
pub fn create() -> VerifierBuilder
Create a chainable VerifierBuilder for configuring a verifier.
Sourcepub fn from_config(cfg: VerifierFromConfig) -> Self
pub fn from_config(cfg: VerifierFromConfig) -> Self
Create a verifier from a flat config object.
Automatically enables include_credentials when any credential
requirement is set (age, OFAC, nationality).
Sourcepub async fn verify(
&mut self,
signature: &str,
timestamp: &str,
method: &str,
url: &str,
body: Option<&str>,
) -> VerificationResult
pub async fn verify( &mut self, signature: &str, timestamp: &str, method: &str, url: &str, body: Option<&str>, ) -> VerificationResult
Verify a signed agent request.
The agent’s identity is derived from the signature — not from any header.
Sourcepub async fn verify_with_keytype(
&mut self,
signature: &str,
timestamp: &str,
method: &str,
url: &str,
body: Option<&str>,
keytype: Option<&str>,
agent_key: Option<&str>,
) -> VerificationResult
pub async fn verify_with_keytype( &mut self, signature: &str, timestamp: &str, method: &str, url: &str, body: Option<&str>, keytype: Option<&str>, agent_key: Option<&str>, ) -> VerificationResult
Verify a signed agent request with key type awareness.
When keytype is Some("ed25519"), uses Ed25519 verification with the
provided agent_key (32-byte public key). Otherwise falls through to
standard ECDSA verification via [verify].
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear the on-chain status cache.
Auto Trait Implementations§
impl Freeze for SelfAgentVerifier
impl RefUnwindSafe for SelfAgentVerifier
impl Send for SelfAgentVerifier
impl Sync for SelfAgentVerifier
impl Unpin for SelfAgentVerifier
impl UnsafeUnpin for SelfAgentVerifier
impl UnwindSafe for SelfAgentVerifier
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more