The matrix define above describes the distribution of the reputation owned by the peers. Notice that the sum of the distribution of one peer is equal to 1.0, and we are also not giving ourselves any amount.
Now, let's turn that that distribution into scores:
We take the score of Peer N and multiply it with each element in op[n]:
Now, from this new matrix we can get the new scores for Peer 0:
If we apply the same for formula we can get the new scores for all peers:
Notice that amount of reputation in the system is always the same (compare with initial s). The reputation cannot be created or destroyed, it can only be allocated.
Everything we did was just one iteration of Eigen Trust algorithm. If we apply the same process throughout several iterations, the reputation score of each peer will not change much further after a certain point. When that happens we say that the reputation scores has converged.
Here is an algorithm example written in Rust:
The logs:
We can see that only after a few iterations, the scores will converge, depending on how much accuracy is needed.
In the real world, we are working with finite field, so our data structures and algorithm has to be modified a bit.
First we define a constant for a number of iterations:
Then, the EigenTrust set which includes the inital score for each peer:
Now, the scores map:
Minimum number of participants should be 2, if it is less, the matrix would not be able to converge:
Before we run the algorithm, we have to normalise the scores:
Now, we have conditions to run the EigenTrust algorithm:
// Normalise the scores
for i in 0..s.len() {
let (pk_i, creadits) = s[i];
if pk == null {
continue;
}
let sum = sum(scores[pk_i]);
for j in 0..s.len() {
scores[pk_i][j] = scores[pk_i][j] / sum;
}
}
for _ in 0..NUM_ITER {
for i in 0..s.len() {
let (pk_i, _) = s[i];
let new_score = 0;
if pk_i == null {
continue;
}
for j in 0..s.len() {
let (pk_j, neighbour_score) = s[j];
if pk_j == null {
continue;
}
let score = scores[pk_j][i];
new_score += score * neighbour_score;
}
s[i].1 = new_score
}
}