Crate eigen_trust
source · [−]Expand description
Eigen Trust
A library for managing trust in a distributed network with zero-knowledge features.
Main characteristics:
Self-policing - the shared ethics of the user population is defined and enforced by the peers themselves and not by some central authority.
Minimal - computation, infrastructure, storage, and message complexity are reduced to a minimum.
Incorruptible - Reputation should be obtained by consistent good behavior through several transactions. This is enforced for all users, so no one can cheat the system and obtain a higher reputation. It is also resistant to malicious collectives.
Usage:
use eigen_trust::{EigenError, Keypair, LevelFilter, Multiaddr, Node, NodeConfig, PeerId};
use std::str::FromStr;
const BOOTSTRAP_PEERS: [(&str, &str, f64); 2] = [
(
"/ip4/127.0.0.1/tcp/58584",
"12D3KooWLyTCx9j2FMcsHe81RMoDfhXbdyyFgNGQMdcrnhShTvQh",
0.5,
),
(
"/ip4/127.0.0.1/tcp/58601",
"12D3KooWKBKXsLwbmVBySEmbKayJzfWp3tPCKrnDCsmNy9prwjvy",
0.5,
),
];
const DEFAULT_ADDRESS: &str = "/ip4/0.0.0.0/tcp/0";
struct Config;
impl NodeConfig for Config {
const INTERVAL: u64 = 2;
const NUM_CONNECTIONS: usize = 12;
const PRE_TRUST_WEIGHT: f64 = 0.2;
}
#[tokio::main]
async fn main() -> Result<(), EigenError> {
let local_key = Keypair::generate_ed25519();
let local_address =
Multiaddr::from_str(DEFAULT_ADDRESS).map_err(|_| EigenError::InvalidAddress)?;
let mut bootstrap_nodes = Vec::new();
for info in BOOTSTRAP_PEERS.iter() {
let peer_addr = Multiaddr::from_str(info.0).map_err(|_| EigenError::InvalidAddress)?;
let peer_id = PeerId::from_str(info.1).map_err(|_| EigenError::InvalidPeerId)?;
bootstrap_nodes.push((peer_id, peer_addr, info.2));
}
let node = Node::<Config>::new(local_key, local_address, bootstrap_nodes)?;
node.main_loop(Some(1)).await?;
Ok(())
}
Implementation
The library is implemented according to the original Eigen Trust paper. It is developed under the Ethereum Foundation grant.
Structs
Epoch struct, which is a wrapper around epoch number and timestamp.
Representation of a Multiaddr.
The Node struct.
The peer struct.
Identifier of a peer of the network.
Enums
The crate-wide error variants.
Identity keypair of a node.
An enum representing the available verbosity level filters of the logger.
Traits
Node configuration crate.