What is EigenTrust?
EigenTrust turns local trust ("alice trusts bob") into a global reputation score for every peer. Trust spreads from a few seed peers you already trust, so fake accounts that only vouch for each other get almost nothing. With no seeds it behaves like PageRank.
It is the algorithm from the EigenTrust paper (Kamvar, Schlosser, Garcia-Molina, 2003), used for reputation in peer-to-peer and decentralized networks, Sybil and spam resistance, and ranking accounts or contributors by who vouches for them.
Try it: eigentrust.jenyadoesapps.com, a live playground in 10 languages that can also rank 250,000 peers in the browser.
Rust library
[]
= "0.2"
use ;
eigentrust_with_optionstakesEigenTrustOptionsforalpha(default 0.5), the convergence threshold and the iteration limit.- Results come back as
TrustScores: one score per peer, summing to 1, plus the iteration count and residual. - Errors are a typed
EigenTrustError. - Optional features:
csvaddseigentrust::csv::Networkfor named peers from CSV.parallelruns the iteration on all cores with rayon.
- There are no required dependencies beyond
log, and the same code builds forwasm32.
The documentation on docs.rs covers the exact input rules and convergence behavior. See also examples/.
Command line
alice,0.6666666865348816
bob,0.3333333134651184
It prints peer,score for every peer with a non-zero score, highest first. Errors go to stderr with exit code 1.
Browser (WebAssembly)
import init from './pkg/eigentrust.js'
await
const enc =
const result = JSON.
// { Ok: [["alice", ...], ["bob", ...], ["carol", ...]] } or { Err: "..." }
./build.shbuildspkg/and a multithreadedpkg-parallel/from thewasmcrate.- The multithreaded build needs a cross-origin isolated page; see
demo/vercel.json. demo/worker.jsruns the engine in a Web Worker and picks the right build.
Input rules
| Input | CSV line | Rust type |
|---|---|---|
| Local trust | from,to[,weight] |
TrustEdge { from, to, weight } |
| Pre-trust (seeds) | peer[,weight] |
PreTrust { peer, weight } |
- Weights: finite and non-negative, default 1. Zero means no trust. Negative trust (distrust) is rejected.
- Normalization: each truster's weights are scaled to sum to 1, and so is pre-trust. With no pre-trust, every peer starts equal.
- Duplicates: a repeated edge or seed keeps its last weight.
- Convergence: at α = 0 some networks oscillate instead of converging. The engine stops after 10,000 iterations with an error.
- CSV: standard CSV, so quoted fields (
"Smith, J"), a header row, spaces, CRLF and a UTF-8 BOM are fine. Errors name the file and line.
Performance
Random trust graphs, 10 links per peer, CSV parsing included.
| Peers | Links | CLI | Browser |
|---|---|---|---|
| 20,000 | 200,000 | 0.06 s | 58 ms |
| 100,000 | 1,000,000 | 0.3 s | 0.2 s |
| 250,000 | 2,500,000 | 0.6 s |
Results are reproducible bit for bit, with or without threads.
Repository layout
| Path | Crate | Role |
|---|---|---|
src/ |
eigentrust |
the library: one implementation of the algorithm |
cli/ |
eigentrust-cli |
the eigentrust command, built on the library's public API |
wasm/ |
eigentrust-wasm |
JavaScript bindings, built on the same API |
demo/ |
the web playground |
Development
License
Licensed under either of Apache License 2.0 or MIT, at your option.