pzp-wiki/assets/js/b922ccdb.2705b496.js

1 line
8.1 KiB
JavaScript

"use strict";(self.webpackChunkpzp_wiki=self.webpackChunkpzp_wiki||[]).push([[204],{8860:(e,n,t)=>{t.d(n,{xA:()=>p,yg:()=>y});var a=t(7953);function r(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function o(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);n&&(a=a.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,a)}return t}function i(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?o(Object(t),!0).forEach((function(n){r(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):o(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function s(e,n){if(null==e)return{};var t,a,r=function(e,n){if(null==e)return{};var t,a,r={},o=Object.keys(e);for(a=0;a<o.length;a++)t=o[a],n.indexOf(t)>=0||(r[t]=e[t]);return r}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)t=o[a],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(r[t]=e[t])}return r}var c=a.createContext({}),l=function(e){var n=a.useContext(c),t=n;return e&&(t="function"==typeof e?e(n):i(i({},n),e)),t},p=function(e){var n=l(e.components);return a.createElement(c.Provider,{value:n},e.children)},d="mdxType",u={inlineCode:"code",wrapper:function(e){var n=e.children;return a.createElement(a.Fragment,{},n)}},g=a.forwardRef((function(e,n){var t=e.components,r=e.mdxType,o=e.originalType,c=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),d=l(t),g=r,y=d["".concat(c,".").concat(g)]||d[g]||u[g]||o;return t?a.createElement(y,i(i({ref:n},p),{},{components:t})):a.createElement(y,i({ref:n},p))}));function y(e,n){var t=arguments,r=n&&n.mdxType;if("string"==typeof e||r){var o=t.length,i=new Array(o);i[0]=g;var s={};for(var c in n)hasOwnProperty.call(n,c)&&(s[c]=n[c]);s.originalType=e,s[d]="string"==typeof e?e:r,i[1]=s;for(var l=2;l<o;l++)i[l]=t[l];return a.createElement.apply(null,i)}return a.createElement.apply(null,t)}g.displayName="MDXCreateElement"},8970:(e,n,t)=>{t.r(n),t.d(n,{assets:()=>c,contentTitle:()=>i,default:()=>u,frontMatter:()=>o,metadata:()=>s,toc:()=>l});var a=t(5265),r=(t(7953),t(8860));const o={sidebar_position:30},i="Feed",s={unversionedId:"concepts/feed",id:"concepts/feed",title:"Feed",description:"A feed is an evolving set of interlinked messages intended for continuous replication in a gossip network.",source:"@site/guide/concepts/feed.md",sourceDirName:"concepts",slug:"/concepts/feed",permalink:"/guide/concepts/feed",draft:!1,editUrl:"https://codeberg.org/pzp/pzp-wiki/src/branch/master/guide/guide/concepts/feed.md",tags:[],version:"current",sidebarPosition:30,frontMatter:{sidebar_position:30},sidebar:"tutorialSidebar",previous:{title:"Message",permalink:"/guide/concepts/message"},next:{title:"Replication",permalink:"/guide/concepts/replication"}},c={},l=[],p={toc:l},d="wrapper";function u(e){let{components:n,...t}=e;return(0,r.yg)(d,(0,a.A)({},p,t,{components:n,mdxType:"MDXLayout"}),(0,r.yg)("h1",{id:"feed"},"Feed"),(0,r.yg)("admonition",{title:"Definition",type:"note"},(0,r.yg)("p",{parentName:"admonition"},(0,r.yg)("strong",{parentName:"p"},"A feed is an evolving set of interlinked messages intended for continuous replication in a gossip network."))),(0,r.yg)("p",null,'In computer science terms, it\'s an Directed Acyclic Graph (DAG) with only one source node, where all the "nodes" are messages, and "edges" are references that each message contains of other messages.'),(0,r.yg)("mermaid",{value:'graph RL;\n D--"A"--\x3eC--"A"--\x3eB--"A"--\x3eA;\n F--\x3eE--\x3eC;\n G--\x3eD & F;\n\nstyle A color:red;'}),(0,r.yg)("p",null,"The root is..."),(0,r.yg)("p",null,"The tangle is identified by the hash of its root message."),(0,r.yg)("h1",{id:"account"},"Account"),(0,r.yg)("p",null,'An account is a special type of tangle, where the messages describe which keypairs are part of the same "account".'),(0,r.yg)("mermaid",{value:'graph RL;\n D--"A"--\x3eC--"A"--\x3eB--"A"--\x3eA;\n F--\x3eE--\x3eC;\n G--\x3eD & F;\n\nstyle A color:red;'}),(0,r.yg)("p",null,"Msgs in an account tangle are special because they have empty ",(0,r.yg)("inlineCode",{parentName:"p"},"account")," and ",(0,r.yg)("inlineCode",{parentName:"p"},"accountTips")," fields."),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"interface Msg {\n data: AccountData\n metadata: {\n dataHash: ContentHash\n dataSize: number\n account: 'self' // MUST be the string 'self'\n accountTips: null // MUST be null\n tangles: {\n [accountTangleId: string]: {\n depth: number // maximum distance (positive integer) from this msg to the root\n prev: Array<MsgHash> // list of msg hashes of existing msgs, unique set and ordered alphabetically\n }\n }\n domain: string // alphanumeric string, at least 3 chars, max 100 chars\n v: 3\n }\n pubkey: Pubkey\n sig: Signature\n}\n\ntype AccountData =\n | { action: 'add', add: AccountAdd }\n | { action: 'del', del: AccountDel }\n\n// \"add\" means this keypair can validly add more keypairs to the account tangle\n// \"del\" means this keypair can validly revoke other keypairs from the account\n// \"box\" means the peer with this keypair should get access to the box keypair\ntype AccountPower = 'add' | 'del' | 'box'\n\ntype AccountAdd = {\n key: Key\n nonce?: string // nonce required only on the account tangle's root\n consent?: string // base58 encoded signature of the string `:account-add:<ID>` where `<ID>` is the account's ID, required only on non-root msgs\n accountPowers?: Array<AccountPower> // list of powers granted to this key, defaults to []\n}\n\ntype AccountDel = {\n key: Key\n}\n\ntype Key =\n | {\n purpose: 'sig' // digital signatures\n algorithm: 'ed25519' // libsodium crypto_sign_detached\n bytes: string // base58 encoded string for the public key being added\n }\n | {\n // WIP!!\n purpose: 'box' // asymmetric encryption\n algorithm: 'x25519-xsalsa20-poly1305' // libsodium crypto_box_easy\n bytes: string // base58 encoded string of the public key\n }\n")),(0,r.yg)("p",null,"Examples of ",(0,r.yg)("inlineCode",{parentName:"p"},"accountData"),":"),(0,r.yg)("ul",null,(0,r.yg)("li",{parentName:"ul"},"Registering the first signing pubkey:",(0,r.yg)("pre",{parentName:"li"},(0,r.yg)("code",{parentName:"pre",className:"language-json"},'{\n "action": "add",\n "add": {\n "key": {\n "purpose": "sig",\n "algorithm": "ed25519",\n "bytes": "3JrJiHEQzRFMzEqWawfBgq2DSZDyihP1NHXshqcL8pB9"\n },\n "nonce": "6GHR1ZFFSB3C5qAGwmSwVH8f7byNo8Cqwn5PcyG3qDvS"\n }\n}\n'))),(0,r.yg)("li",{parentName:"ul"},"Registering a subaccount:",(0,r.yg)("pre",{parentName:"li"},(0,r.yg)("code",{parentName:"pre",className:"language-json"},'{\n "action": "add",\n "add": {\n "key": {\n "purpose": "subaccount",\n "algorithm": "tangle",\n "bytes": "6yqq7iwyJEKdofJ3xpRLEq"\n }\n }\n}\n'))),(0,r.yg)("li",{parentName:"ul"},"Revoking a signing pubkey:",(0,r.yg)("pre",{parentName:"li"},(0,r.yg)("code",{parentName:"pre",className:"language-json"},'{\n "action": "del",\n "del": {\n "key": {\n "purpose": "sig",\n "algorithm": "ed25519",\n "bytes": "3JrJiHEQzRFMzEqWawfBgq2DSZDyihP1NHXshqcL8pB9"\n }\n }\n}\n')))),(0,r.yg)("h1",{id:"moot-feeds"},"Moot feeds"),(0,r.yg)("p",null,"A feed is a special type of tangle, where the root is a predictable (by any peer) message with no content."),(0,r.yg)("mermaid",{value:'graph RL;\n D--"A"--\x3eC--"A"--\x3eB--"A"--\x3eA;\n F--\x3eE--\x3eC;\n G--\x3eD & F;\n\nstyle A color:red;'}),(0,r.yg)("p",null,"Root:"),(0,r.yg)("pre",null,(0,r.yg)("code",{parentName:"pre",className:"language-typescript"},"interface Msg {\n data: null // MUST be null\n metadata: {\n dataHash: null // MUST be null\n dataSize: 0 // MUST be 0\n account: string // MUST be an ID\n accountTips: null // MUST be null\n tangles: {} // MUST be empty object\n domain: string\n v: 2\n }\n pubkey: Pubkey\n sig: Signature\n}\n")))}u.isMDXComponent=!0}}]);