baseid-trust
Build decentralized reputation networks where trust is expressed as Verifiable Credentials, aggregated into a graph, and proven via BBS+ zero-knowledge predicates.
Key Features
Section titled “Key Features”- Reputation Attestations — VC-encoded endorsements with domain, score, and weight
- Trust Graph — DID nodes with attestation edges, path queries, domain filtering
- Three Algorithms — DirectOnly, TransitiveTrust (PageRank), ReputationWeighted
- BBS+ Score Proofs — prove “reputation > 80” without revealing the actual score
- Domain-Specific — separate scores for software, legal, finance, etc.
Quick Start
Section titled “Quick Start”use baseid_trust::*;
// Build a trust graphlet mut graph = TrustGraph::new();
// Alice endorses Bob in software developmentlet att = AttestationBuilder::new("did:key:alice", "did:key:bob") .domain("software") .score(85) .weight(0.9) .evidence("https://github.com/bob/project") .build()?;
graph.add_attestation(&att);
// Compute trust scorelet score = TrustAlgorithm::DirectOnly.compute(&graph, "did:key:bob", "software");println!("Score: {:.1}, Confidence: {:.1}", score.score, score.confidence);// Score: 85.0, Confidence: 0.2
// Add more endorsers to increase confidencelet att2 = AttestationBuilder::new("did:key:carol", "did:key:bob") .domain("software").score(90).weight(1.0).build()?;graph.add_attestation(&att2);
let score = TrustAlgorithm::DirectOnly.compute(&graph, "did:key:bob", "software");// Score: ~87.4, Confidence: 0.4 (2/5 endorsers)Trust Algorithms
Section titled “Trust Algorithms”| Algorithm | Description | Best For |
|---|---|---|
DirectOnly | Weighted average of direct attestations | Simple reputation queries |
TransitiveTrust | PageRank-style propagation through network | Discovering indirect trust |
ReputationWeighted | Attestor’s own score multiplies their weight | Preventing gaming by low-rep nodes |
TransitiveTrust Example
Section titled “TransitiveTrust Example”// A endorses B, B endorses C — trust propagates A→B→Clet score = TrustAlgorithm::TransitiveTrust { damping: 0.85, iterations: 20,}.compute(&graph, "did:key:c", "software");// C has transitive trust from A through BReputationWeighted Example
Section titled “ReputationWeighted Example”// High-reputation endorser's attestation counts morelet score = TrustAlgorithm::ReputationWeighted { depth: 2 } .compute(&graph, "did:key:bob", "software");// Alice's endorsement (if she has high rep) weighs more than unknown'sPrivacy-Preserving Score Proofs
Section titled “Privacy-Preserving Score Proofs”Prove reputation exceeds a threshold without revealing the actual score:
use baseid_trust::*;use baseid_bbs::BbsKeyPair;
let kp = BbsKeyPair::generate()?;
// Issue reputation as BBS+ credentiallet att = AttestationBuilder::new("did:key:alice", "did:key:bob") .domain("software").score(90).build()?;let credential = issue_reputation_credential(&att, &kp)?;
// Prove score > 80 (verifier learns domain but NOT actual score)let proof = prove_score_threshold(&credential, 80, &kp)?;
// Verify the prooflet valid = verify_score_proof(&proof)?;assert!(valid); // Score 90 > threshold 80Graph Operations
Section titled “Graph Operations”| Operation | Method | Returns |
|---|---|---|
| Add attestation | graph.add_attestation(&att) | Edge ID |
| Query by subject | graph.attestations_for(did) | Edges |
| Query by domain | graph.attestations_for_domain(did, domain) | Edges |
| Find trust path | graph.find_path(from, to) | DID path |
| Remove issuer | graph.remove_issuer(did) | — |
| Graph stats | graph.node_count(), graph.edge_count() | Counts |
Key Types
Section titled “Key Types”| Type | Description |
|---|---|
ReputationAttestation | VC-encoded reputation with domain, score, weight, evidence |
AttestationBuilder | Fluent builder for creating attestations |
TrustGraph | DID nodes + attestation edges + queries |
TrustAlgorithm | DirectOnly, TransitiveTrust, ReputationWeighted |
TrustScore | Computed score with confidence and breakdown |
TrustNode / TrustEdge | Graph primitives |
Server API
Section titled “Server API”When using baseid-server, trust operations are available via REST:
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/trust/attestations | Add a reputation attestation |
| GET | /api/trust/attestations/:did | Get attestations for a subject |
| POST | /api/trust/score | Compute trust score (supports algorithm selection) |
| GET | /api/trust/graph/stats | Graph statistics |
Related Crates
Section titled “Related Crates”baseid-bbs— BBS+ signatures for ZK score proofsbaseid-verifier-core— TrustRegistry integrationbaseid-core— ClaimSet, AssuranceLevel