Visualizing Trust: Trustgraphs of CirclesUBI in Neo4j

For payments, CirclesUBI heavily relies on “transitive trust”, ie. transitive multi-hops for payments between Circles users who do not trust directly, but via a intermediate users. So if Bob trusts Alice and Carol trusts Bob, Alice can pay Carol with a multi-hop payment of 2 (Alice → Bob → Carol). If Alice sends the payment, her Circle Coins (CRC) are swapped with Bobs and then Bobs are swapped with Carols, so Carol never has to trust Alice directly.

The tool Pathfinder helps finding a shortest path between Alice and Carol if it exists and checks if the amount trusted is enough for Alice to pay Carol.

Calculating transitive trustlines is not an easy tasks and at least requires to know in realtime about the current trust relationsships of all participants.

I created a prototype with an actual Graph-Database, Neo4j, which is perfectly suited for this specific task, but also supports a query language (Cypher) to generate other interesting queries for the trustgraph of Circles.

How to try

Instructions for installation and Docker versions are here: GitHub - ice09/circlesubi-trustgraph-neo4j: Create a Graph of Social Trust from CircleUBI Contract Event Data

Without any guarantee you can also connect to the REST API here to query trustpaths as a service only (no visualization) here: http://cyberdyne-101.net:8889/swagger-ui.html#/trust-graph-controller

How to play

3 Likes

Some Cyphers to play with

  • What is the shortest path (multi-hop payment) between two users?
MATCH path=shortestPath((u:User {name:"alculexum"})-[TRUSTS*]->(r:User {name:"Martin"}))
RETURN path

Recommendations

  • Who trusts the trustees of User “alculexum” (who is a friend of a friend)?
MATCH (u:User {name:"alculexum"})-[:TRUSTS]->(m)<-[:TRUSTS]-(friends)
RETURN friends
  • Who is trusted by the trustees of User “alculexum” (who is a friend of a friend)?
MATCH (u:User {name:"alculexum"})-[:TRUSTS]->(m)-[:TRUSTS]->(friends)
RETURN friends

Identity Validation

  • Who trusts most users?
MATCH (tr:User)-[r:TRUSTS]->(te:User)
RETURN tr AS Truster, COUNT(r)
ORDER BY COUNT(r) DESC
  • Who is trusted by most users?
MATCH (tr:User)<-[r:TRUSTS]-(te:User)
RETURN tr AS Trustee, COUNT(r)
ORDER BY COUNT(r) DESC
  • Who has most uni-directional trusts (is not trusted back)?
MATCH (utr:User)-[t:TRUSTS]->(ute:User)
WHERE NOT (ute)-[t:TRUSTS]->(utr)
RETURN utr, count(t) as paths
ORDER BY paths DESC
LIMIT 5
2 Likes

This is super helpful and maybe also a a solution to revive our trust network explorer and transfer simulator in the Circles Dashboard. It used to have a very nice visualization plus some helpful tooling but crashed with the amounts of data being rendered directly in the browser.

I’ve removed the bits displaying the network (you can see the code here GitHub - CirclesUBI/circles-dashboard: Status dashboard and trust network explorer for Circles) but with getting the data from an external backend there might be ways to get it back working!

Would you be up to meet and see how we can get the systems together @alculexum?

Sure, though this is honestly all about ideas and feasibility - for a production grade service a lot has to be done, including a decent and fail-over-capable operation mode. Right now, it’s my private server and is not fail-safe at all :slight_smile:
But I certainly would be interested to evaluate options, feel free to DM me.

1 Like