• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    JavaScript
  • License
    GNU Affero Genera...
  • Created over 4 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a flexible and distributed system for deriving, and interacting with, computational trust

TrustNet

a flexible and distributed system for deriving, and interacting with, computational trust

TrustNet is a complete trust system that can be incorporated as a ready-made software component for e.g. distributed ledger technologies, or in a traditional client-server model, and which provides real value for impacted users by way of automating decision-making and actions as a result of assigned trust scores.

TrustNet has support for:

  • managing different trust areas,
  • discarding statements from distrusted nodes, and
  • computing the subjectively most trusted nodes, as seen from a particular node.

TrustNet is the result of over 1 year of research into systems for transitive and computational trust. Read the 103-page report, or the shorter blog post.

See the examples/ folder for short snippets on how to use the system.

If you are unfamiliar to the terminology used in this repository, see the Concepts section, below.

Usage

TrustNet can be used either directly, or through the TrustHandler class. The TrustHandler has an extended API for managing trust across disparate trust areas (such as moderation and music recommendations, for example).

See the API section below for the available methods.

const { TrustNet } = require("../")

const distrusted = ["eve", "mallory"]
const trustAssignments = []
trustAssignments.push({ src: 'alice', dst: 'bob', weight: 0.25 })
trustAssignments.push({ src: 'alice', dst: 'carole', weight: 0.8 })
trustAssignments.push({ src: 'carole', dst: 'david', weight: 0.8 })
trustAssignments.push({ src: 'david', dst: 'carole', weight: 0.8 })
trustAssignments.push({ src: 'carole', dst: 'alice', weight: 0.8 })
trustAssignments.push({ src: 'bob', dst: 'eve', weight: 0.80 })
trustAssignments.push({ src: 'eve', dst: 'mallory', weight: 1.0 })
trustAssignments.push({ src: 'mallory', dst: 'eve', weight: 1.0 })

const trust = new TrustNet()
const root = process.argv.length > 2 ? process.argv[2] : "alice"
trust.load(root, trustAssignments, distrusted).then(() => {
    let mostTrusted = trust.getMostTrusted()
    console.log(`${root}'s most trusted:`, mostTrusted)
    console.log("all trusted", trust.getAllTrusted())
})

Concepts

TrustNet operates on trust assignments issued by nodes, which are typically peers in a peer-to-peer system like Cabal or Secure Scuttlebutt.

A trust assignment has a trust source, a trust target (or destination), and a trust weight. It is typically issued within a trust area. See the table below for descriptions of these terms.

Term Description
Trust Source The issuer of a trust assignment.
Trust Target The target of a trust assignment; the entity being trusted.
Trust Weight The amount of trust assigned to trust target.
Trust Area For example: book recommendations, moderation capabilities

The trust assignments TrustNet operates on are of the following form:

{ 
	src: 'alice', 
	dst: 'bob', 
	weight: 0.25 
}

The trust weight weight is a float defined on the range 0.0 - 1.0, while src and dst are strings representing unique user identities.

TrustNet takes the trust assignments, and a trust root with id rootid, and derives a trust graph. The trust graph is basically the subjective view of the trust assignments from the trust root. Using this trust graph, and the trust root, we follow the trust assignments stemming out from the root and iteratively calculate trust ranks. The goal is to end up with a subset of the unique identities, represented in the trust assignments, which are regarded as the most trusted nodes, as seen from the passed-in trust root.**

If you want to know more about TrustNet, consider reading:

If you want to fund the development of TrustNet, or other independent research, sponsor me on GitHub or elsewhere.

API

Use either TrustNet, for a single trust area, or TrustHandler if you are managing multiple trust areas:

const { TrustNet, TrustHandler } = require("trustnet") 
const tnet = new TrustNet() // or..
const handler = new TrustHandler(["moderation", "music recommendations"])

TrustNet(opts)

opts.threshold

Default value of 0.50. Sets the threshold determining which trust assignments are regarded as too low for a accurate trust computation (see meta-ranking trust strategy in paper or article).

NOTE As long as there exists at least one direct trust assignment, i.e. issued from the trust source rootid, with a trust weight > opts.threshold, the computation will continue as expected.

async TrustNet.load (rootid, assignments, distrusted=[])

Returns a promise. The promise is resolved when the trust computation has finished, and the final trust ranks (based on the passed-in trust assignments) have been determined.

  • rootid is the id you are viewing the trust graph from, the trust source,
  • assignments is a list of trust assignments of form { src, dst, weight }. Where src and dst are strings representing a unique id, and weight is a float in the range 0.0-1.0.
  • distrusted is an optional list containing ids to discard from the final trust graph, before performing trust computation

TrustNet.getMostTrusted()

Synchronous, requires having run load() at least once.

Returns the ids of the most trusted nodes, as seen from the trust source passed into load().

TrustNet.getAllTrusted()

Synchronous, requires having run load() at least once.

Returns the ids of all nodes with a non-zero ranking, as seen from the trust source passed into load().

TrustNet.getRankings()

Synchronous, requires having run load() at least once.

Returns a mapping of id -> trust rank of the most trusted nodes, as seen from the trust source passed into load(). Only returns non-zero mappings.

TrustHandler(areas=[])

Also allows passing in areas as an object mapping trust area to its opts, see TrustNet for which opts are applicable.

Example:

const { TrustHandler } = require("trustnet")
const handler = new TrustHandler({ "moderation": { threshold: 0.75 }, "recommendations": { threshold: 0.25 }})

TrustHandler.load = async function (area, rootid, assignments, distrusted=[])

Returns a promise. The promise is resolved when the trust computation has finished, and the final trust ranks (based on the passed-in trust assignments) have been determined.

Same as TrustNet.load except it takes an area, representing the trust area.

  • area name of the trust area to perform trust computations for. If the trust area is being added for the first time, a call to TrustHandler.add(area) will be issued.

TrustHandler.getMostTrusted()

Synchronous, requires having run load() or loadAll() at least once.

Same as TrustNet.getMostTrusted except it takes an area, representing the trust area.

Returns the ids of the most trusted nodes, as seen from the trust source passed into load().

TrustHandler.getAllTrusted()

Synchronous, requires having run load() or loadAll() at least once.

Same as TrustNet.getAllTrusted except it takes an area, representing the trust area.

Returns the ids of all nodes with a non-zero ranking, as seen from the trust source passed into load().

TrustHandler.getRankings()

Synchronous, requires having run load() or loadAll() at least once.

Same as TrustNet.getRankings except it takes an area, representing the trust area.

Returns a mapping of id -> trust rank of the most trusted nodes, as seen from the trust source passed into load(). Only returns non-zero mappings.

TrustHandler.loadAll = async function (areaMapping)

Returns a promise. The promise is resolved when the trust computation has finished for all passed in trust areas.

  • areaMapping An object mapping a trust area to the parameters load requires

Example:

const rootid = areaMapping[area].rootid
const assignments = areaMapping[area].assignments
const distrusted = areaMapping[area].distrusted

TrustHandler.add(area, opts=null)

Adds a new trust area to TrustHandler

  • area the name of the trust area
  • opts optional object containing options to pass to TrustNet

TrustHandler.get(area)

Gets the TrustNet instantiation for the passed in trust area.

  • area the name of the trust area. area should have been added previously during TrustHandler's instatination or via a call to add(), load(), or loadAll().

TrustHandler.list()

Returns a list of all the currently registered trust areas.

TrustHandler.remove(area)

Removes a trust area.

Note: Current implementation of TrustNet is lacking a .destroy() method. PR adding it welcome.

Sponsor

If you want to fund the development of TrustNet, or other independent research, sponsor me on GitHub or elsewhere.

License

TrustNet is available for dual-licensing. All the code in this repository is licensed as AGPL3.0-or-later. If AGPL3 does not work for you, or your organization, contact cblgh-at-cblgh dotte org to purchase a more permissive usage license.

If your project is a not-for-profit project, the permissive license will likely be available at very low-cost :)

More Repositories

1

lieu

community search engine
Go
231
star
2

monotome

a personal knowledge base system. markdown markup, runs in the browser
JavaScript
201
star
3

cerca

lean forum software
Go
120
star
4

datradio

p2p music player for {old} beaker and dat
JavaScript
82
star
5

plain

network .md into .html with plaintext files
Go
76
star
6

decent-dat-intro

a buffet of tiny demos for easing in everyone with developing decentralized apps
JavaScript
69
star
7

hyperdb-examples

a small introduction to getting started with hyperdb
JavaScript
53
star
8

paperslip

share hard-to-transmit snippets with easy-to-pronounce names using dht magic
JavaScript
37
star
9

appleseed-metric

a trust propagation algorithm and trust metric for local group trust computation
JavaScript
30
star
10

piratcloud

an ipfs-based encrypted backup solution
Go
20
star
11

sector7557

a peer-to-peer distributed multi-user dungeon, built ontop of cabal
JavaScript
18
star
12

rotonde-choo

an electron client for the decentralized rotonde network
JavaScript
17
star
13

storyteller

a small templating language and python parser for generating small stories
Python
12
star
14

tooty

smol & custom mastodon client, intended solely for posting
Go
11
star
15

caballo

horse themed social network *neighs*
JavaScript
10
star
16

mould

Generate forms + the server that serves 'em using a custom plaintext syntax
Go
9
star
17

hyperdungeon

a distributed mud experiment ontop of hypercore & hyperdb
JavaScript
8
star
18

p2p-oresund

27/10 Malmรถ: an offline gathering for peer-to-peer conspirators artists and estranged developers
HTML
6
star
19

hypercore-examples

short examples on how to use hypercore & hyperdiscovery
JavaScript
5
star
20

quackfarm

everyone is welcome to quackfarm ๐Ÿฆ†
JavaScript
5
star
21

hyperotonde

save rotonde feeds for use with hashbase.io and datproject.org
JavaScript
4
star
22

cabal-crepes

wip: cabal replication diagnostics
JavaScript
4
star
23

kindling

emailing yourself project gutenberg links and having the books sent to your kindle is nice
Python
4
star
24

diplomat

https://moderator.rocks ui & frontend
JavaScript
3
star
25

kindle-to-md

takes a kindle's My Clippings.txt and outputs markdown files for quotes
Python
3
star
26

highroller

cabal bot dice game: let's get rolling!!!!!
JavaScript
3
star
27

rotonde-greeter

a bot that greets people on rotonde!
JavaScript
3
star
28

colorsampler

a tool for sampling on-screen colors
Python
3
star
29

mpv-control

a collection of scripts to control the mpv media player from the terminal
Shell
3
star
30

alarmPy

a google calendar powered alarm clock, running on raspberry pi
Python
2
star
31

cabal-dns

fork of dat-dns for cabal
JavaScript
2
star
32

rotonde-mentions

a mentions service bot for the rotonde network
JavaScript
2
star
33

prompts

read a textfile of prompts and import into anki via ankiconnect
Python
2
star
34

no-network

a list of networks that don't work with peer to peer protocols
2
star
35

cli-manual

parse markdown input, making it more readable in the terminal
JavaScript
2
star
36

dtn-presentation

HTML
2
star
37

36c3-shitty

a shitty 36c3 calendar app, based on watson's excellent 35c3 app
JavaScript
2
star
38

trustnet-graph

Underlying data structure for TrustNet (not really that interesting)
JavaScript
1
star
39

rotonde-cli

a command line client for rotonde
JavaScript
1
star
40

rotonde-python

another rotonde cli, this time in python
Python
1
star
41

solar-player

a python script for controlling an mpv player using GPIO inputs
Python
1
star