pub struct VerifiableCredential {
pub context: Vec<String>,
pub vc_type: Vec<String>,
pub id: String,
pub issuer: String,
pub issuance_date: String,
pub expiration_date: Option<String>,
pub credential_subject: CredentialSubject,
pub proof: VcProof,
}did only.Expand description
A W3C Verifiable Credential proving an agent’s authorized capabilities.
VCs are portable, self-contained proofs that work without network calls. Any system — another agent, blockchain, enterprise IAM, EU eIDAS wallet — can verify this credential offline using only the issuer’s public key.
The signature covers a domain-separated Blake3 hash of all credential fields, making it immune to JSON canonicalization attacks.
§Example
use a1::{DyoloIdentity, did::{AgentDid, VerifiableCredential}};
let issuer = DyoloIdentity::generate();
let agent = DyoloIdentity::generate();
let agent_did = AgentDid::from_key(&agent.verifying_key());
let vc = VerifiableCredential::issue_capability(
&issuer,
&agent_did,
"acme-trading-bot",
&["trade.equity", "portfolio.read"],
now_unix,
now_unix + 86400,
&chain_fingerprint,
).unwrap();
assert!(vc.verify().is_ok());
let json = vc.to_json().unwrap();Fields§
§context: Vec<String>§vc_type: Vec<String>§id: String§issuer: String§issuance_date: String§expiration_date: Option<String>§credential_subject: CredentialSubject§proof: VcProofImplementations§
Source§impl VerifiableCredential
impl VerifiableCredential
Sourcepub fn issue_capability(
issuer: &dyn Signer,
subject_did: &AgentDid,
passport_namespace: &str,
capabilities: &[&str],
issued_at_unix: u64,
expiry_unix: u64,
chain_fingerprint: &[u8; 32],
) -> Result<Self, A1Error>
pub fn issue_capability( issuer: &dyn Signer, subject_did: &AgentDid, passport_namespace: &str, capabilities: &[&str], issued_at_unix: u64, expiry_unix: u64, chain_fingerprint: &[u8; 32], ) -> Result<Self, A1Error>
Issue a capability VC from a DyoloPassport holder.
The VC asserts that the agent identified by subject_did is authorized
to perform the listed capabilities under the named passport.
The signature is computed as Ed25519(Blake3(domain ‖ id ‖ issuer ‖ issuance ‖ expiry ‖ subject_did ‖ namespace ‖ caps ‖ fingerprint)),
preventing any tampering with the credential fields.
Trait Implementations§
Source§impl Clone for VerifiableCredential
impl Clone for VerifiableCredential
Source§fn clone(&self) -> VerifiableCredential
fn clone(&self) -> VerifiableCredential
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more