{"id":20597032,"url":"https://github.com/tradle/protocol","last_synced_at":"2025-10-06T05:05:22.099Z","repository":{"id":66294737,"uuid":"56989028","full_name":"tradle/protocol","owner":"tradle","description":"tradle protocol v2","archived":false,"fork":false,"pushed_at":"2022-04-27T17:44:17.000Z","size":181,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-17T00:53:09.956Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tradle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-24T19:00:10.000Z","updated_at":"2021-12-28T11:14:29.000Z","dependencies_parsed_at":"2023-02-22T13:00:56.098Z","dependency_job_id":null,"html_url":"https://github.com/tradle/protocol","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradle%2Fprotocol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradle%2Fprotocol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradle%2Fprotocol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradle%2Fprotocol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tradle","download_url":"https://codeload.github.com/tradle/protocol/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242231440,"owners_count":20093636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T08:19:55.492Z","updated_at":"2025-10-06T05:05:17.067Z","avatar_url":"https://github.com/tradle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# protocol\n\nTradle protocol v2\n\n# Purpose\n\nAlice sends Bob a message on some channel or other. Later, Bob wants to prove who send what and when. Digital signatures get you 90% of the way there, but you still need an identity server (in our case the blockchain), and message timestamping (you got it, also the blockchain).\n\nThe sender and recipient separately derive per-message public keys based on message content and recipient's public key. The proving party, who can be either the sender or the recipient, sends a blockchain transaction to the address corresponding to the generated key. The recipient monitors the same address to get a confidential but auditable proof.\n\n# Methods\n\nBetter docs coming soon, for now see documentation embedded in code.\n\n# send({ pub: ECPubKey, message: Object })\n\n# receive({ pub: ECPrivKey, message: Object })\n\n# tree({ leaf: ?Function, parent: ?Function, message: Object })\n\n# prove({ tree: Array, leaves: Array })\n\n# verify({ proof: Array, node: Node })\n\n# Usage \n\n```js\nconst ec = require('elliptic').ec('secp256k1')\nconst alice = secp256k1.keyFromPrivate('a243732f222cae6f8fc85c302ac6e704799a6b95660fe53b0718a2e84218a718', 'hex')\nconst bob = secp256k1.keyFromPrivate('06e5db45f217a0bc399a4fd1836ca3bcde392a05b1d67e77d681e490a1039eef', 'hex')\n\nconst a = protocol.send({\n  pub: bob.getPublic(),\n  message: {\n    a: 1,\n    b: 2\n  }\n})\n\nconst b = protocol.receive({\n  priv: bob.priv,\n  message: {\n    a: 1,\n    b: 2\n  }\n})\n\n// a.destKey.getPublic(true, 'hex') === b.destKey.getPublic(true, 'hex')\n```\n\n# Objects\n\nObjects are plain JSON objects that:\n* must bear the signature of their creator (the merkle root of the object is signed)\n* if the object is not the first version:\n  * must link to the previous version of the object\n  * optionally link to the original version of the object (if it exists)\n\n## Merkle root\n\nTo build a merkle tree for an object, sort the properties alphabetically, then set the leaves to be key1, value1, key2, value2, etc.\n\n## Object headers\n\nProperties in an object header are omitted from the merkle tree. Header properties include:\n  * signature\n\n# Messages\n\nMessages are objects as described above, with the following properties:\n* object: another object\n* sender: sender pub key\n* recipient: recipient pub key\n* prev: link to previous message to this recipient\n\n# Links\n\nA link to an object is the sha256 hash of its stringified header, currently:\n\n```json\nvar header = {\n  // merkle root of tree described above\n  _s: sign(merkle_root(object))\n}\n```\n\n# Seals\n\nSeals are public keys that are created as combination of a blockchain transaction creator's known public key and an object:\n\n  p1 = link // private key derived from object link\n  P1 = ec_point(p1)\n  P2 = transaction creator pub key\n\n  Seal pub key = P1 + P2\n\nWhen a version of an object is created, two seals are created, one for the current version, and one linking to the previous. The seal pub key for the previous is calculated slightly differently so that it doesn't end up being identical to the previous version's:\n\n  p1 = sha256(prev_version_link)\n  ... // same as above\n\n\n# Todo\n\ndecide when to check that signer of prev and current version is the same\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftradle%2Fprotocol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftradle%2Fprotocol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftradle%2Fprotocol/lists"}