diff --git a/Protocol.md b/Protocol.md index 844c5796d3d7e9e54fe788c6754e065ab2936eec..857edc0f2605347e138ef9addd00d79504ed5ce2 100644 --- a/Protocol.md +++ b/Protocol.md @@ -2,41 +2,37 @@ ## Informal description -**FYgg** is a **decentralised operating system** protocol managing permissionned **tokens** -representing **assets**, **currency units** or even **program states** which can be **created**, -**provided** and **consumed** in **transactions**. Each *token* is part of a **family** of tokens -following the sames conditions while each *token* can provide additional ones. *Tokens* are stored -in a [Merkle tree] to provide proof of existence and correctness and can be updated with -transactions involving *tokens* where all conditions are fullfiled. This tree represent a state of -the system and is called the **world tree** or **yggdrasil** (named from [Norse cosmology]). - -> Only the tree root need to be stored as the branch of each token is provided alongside it by -> users. It allows nodes to store only tokens they care about while being able to verify the -> consistency of the tree state. - -Multiple **yggdrasils** can be run in parallel and roots can be inserted in others to allow -communication between them, forming a **f**ederation of independent ***ygg**drasils*, thus the -name **FYgg**. - -*Tokens* are used in *transactions* as part of **tokens bags**. Each *tokens bag* is -**signed** with the requiered keys to express aggrement in tokens data. Changing any data in these -tokens will cause the signatures to become invalid. While a *token* is created in a unique **primary -bag**, it can be used in multiple bags to allow *transaction* creation in multiple steps by -different parties without the need for each party to aggree on the whole transaction. Each *token* -script can access to all bags the token is in to verify conditions, while the *primary bag* of a -created *token* is used to deterministically compute a unique id based on the other (non created) -*tokens* in the bag. - -> Let's implement transactions fees with this. If the sender wants to send 10 units to someone -> and need to pay an 1 unit fee, he can consume currency tokens representing 11 units and create a -> new currency token of 10 units locked with the receiver key, then sign this bag. It's not -> currently valid, since currency token scripts will check that no money is created or destroyed. -> However when a miner try to include this transaction in a state update (block), he can create a -> bag with the 11 unit token an a new token of its own of 1 unit, and sign it. While each individual -> bag is invalid both bags together becomes valid. - -[Merkle tree]: https://en.wikipedia.org/wiki/Merkle_tree -[Norse cosmology]: https://en.wikipedia.org/wiki/Yggdrasil +**FYgg** is a **decentralised operating system** protocol managing permissioned **tokens** +that can represent programs, states, assets or even currency units. A token can have children an +defines how they can be **created**, **provided**, **updated** or **destroyed** in a specialized +**pure functionnal programming language**. The protocol *as is* is **usage-agnostic** and unable +to perform any task of it's own except running the *root token* main function, and its power comes +from the ability of tokens to program how them and their children can be used. These programs are +not meant to perform complex calculation, but only to verify the new state is valid. + +When created a token is assigned a **unique and definitive ID**, while it also have a **state ID** +changing each time the token is updated to avoid *replay attacks*. Children are stored in a +**Merkle tree** structure, the parent storing the **Merkle root** of the tree while the +**Merkle proof** of the children must be provided when it's used. Thanks to this it's possible to +discard any token while begin able to verify **state updates** (or **transformations**) if all used +tokens and their proofs are provided. + +**Transformations** (or *transforms* for short) describes changed in a group of tokens. It list +tokens which are used together and can store additionnal data (such as signatures) which can be used +to verify their validity. A token can be used in multiple transforms if multiple sub-groups of +tokens require different additionnal data. Each of these individual transforms can be invalid but as +a whole become valid. A transform stores a list of transforms it depends on (sub-groups transforms +or child token transforms). These dependencies make a **directed acyclic graph** which can be +used in token programs to verify rules. + +By default, many things are not verified automatically and are dangerous unless they are check +manually by token programs. By this construct it's possible to create really complex systems which +could not be created otherwise while allowing to make a globally secure tree. For exemple, it's +possible by default to create a token with a *subtree Merkle root* **without** providing nor +verifying its children. Most tokens will forbid this, but it can be used to import a large amount of +somehow trusted tokens into the tree. The main usage is cross-tree communication with trust coming +from an user-based oracle (detailed later in this document), allowing bandswitch and computation +sharding between multiple independent trees. ## Formal description