Skip to content

baseid-trust

Build decentralized reputation networks where trust is expressed as Verifiable Credentials, aggregated into a graph, and proven via BBS+ zero-knowledge predicates.

  • 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.
use baseid_trust::*;
// Build a trust graph
let mut graph = TrustGraph::new();
// Alice endorses Bob in software development
let 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 score
let 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 confidence
let 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)
AlgorithmDescriptionBest For
DirectOnlyWeighted average of direct attestationsSimple reputation queries
TransitiveTrustPageRank-style propagation through networkDiscovering indirect trust
ReputationWeightedAttestor’s own score multiplies their weightPreventing gaming by low-rep nodes
// A endorses B, B endorses C — trust propagates A→B→C
let score = TrustAlgorithm::TransitiveTrust {
damping: 0.85,
iterations: 20,
}.compute(&graph, "did:key:c", "software");
// C has transitive trust from A through B
// High-reputation endorser's attestation counts more
let score = TrustAlgorithm::ReputationWeighted { depth: 2 }
.compute(&graph, "did:key:bob", "software");
// Alice's endorsement (if she has high rep) weighs more than unknown's

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+ credential
let 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 proof
let valid = verify_score_proof(&proof)?;
assert!(valid); // Score 90 > threshold 80
OperationMethodReturns
Add attestationgraph.add_attestation(&att)Edge ID
Query by subjectgraph.attestations_for(did)Edges
Query by domaingraph.attestations_for_domain(did, domain)Edges
Find trust pathgraph.find_path(from, to)DID path
Remove issuergraph.remove_issuer(did)
Graph statsgraph.node_count(), graph.edge_count()Counts
TypeDescription
ReputationAttestationVC-encoded reputation with domain, score, weight, evidence
AttestationBuilderFluent builder for creating attestations
TrustGraphDID nodes + attestation edges + queries
TrustAlgorithmDirectOnly, TransitiveTrust, ReputationWeighted
TrustScoreComputed score with confidence and breakdown
TrustNode / TrustEdgeGraph primitives

When using baseid-server, trust operations are available via REST:

MethodEndpointDescription
POST/api/trust/attestationsAdd a reputation attestation
GET/api/trust/attestations/:didGet attestations for a subject
POST/api/trust/scoreCompute trust score (supports algorithm selection)
GET/api/trust/graph/statsGraph statistics