Skip to main content

Crate agent_id_handshake

Crate agent_id_handshake 

Source
Expand description

Handshake protocol for mutual agent authentication.

This crate implements the challenge-response handshake defined in the AIP spec.

§Example

use agent_id_core::RootKey;
use agent_id_handshake::{messages::Hello, protocol::{Verifier, sign_proof}};

// Agent A initiates
let key_a = RootKey::generate();
let hello = Hello::new(key_a.did().to_string());

// Agent B responds with challenge
let key_b = RootKey::generate();
let verifier = Verifier::new(key_b.did());
let challenge = verifier.handle_hello(&hello).unwrap();

// Agent A signs proof
let proof = sign_proof(&challenge, &key_a.did(), &key_a, Some(key_b.did().to_string())).unwrap();

// Agent B verifies and accepts
verifier.verify_proof(&proof, &challenge).unwrap();

Re-exports§

pub use error::HandshakeError;
pub use error::Result;
pub use messages::Challenge;
pub use messages::Hello;
pub use messages::Proof;
pub use messages::ProofAccepted;
pub use protocol::sign_proof;
pub use protocol::verify_counter_proof;
pub use protocol::Verifier;

Modules§

error
Error types for handshake protocol.
messages
Handshake protocol message types.
protocol
Handshake protocol implementation.