{"id":19358615,"url":"https://github.com/paritytech/stateless-blockchain","last_synced_at":"2025-04-23T11:32:14.465Z","repository":{"id":38300005,"uuid":"207562199","full_name":"paritytech/stateless-blockchain","owner":"paritytech","description":"Stateless Blockchain on Substrate using RSA Accumulators","archived":false,"fork":false,"pushed_at":"2023-01-04T12:26:55.000Z","size":5439,"stargazers_count":57,"open_issues_count":23,"forks_count":19,"subscribers_count":11,"default_branch":"master","last_synced_at":"2023-04-09T19:14:15.544Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paritytech.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}},"created_at":"2019-09-10T13:07:51.000Z","updated_at":"2023-01-08T23:57:55.000Z","dependencies_parsed_at":"2023-02-02T12:15:44.624Z","dependency_job_id":null,"html_url":"https://github.com/paritytech/stateless-blockchain","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fstateless-blockchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fstateless-blockchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fstateless-blockchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paritytech%2Fstateless-blockchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paritytech","download_url":"https://codeload.github.com/paritytech/stateless-blockchain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223922077,"owners_count":17225636,"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-10T07:12:29.134Z","updated_at":"2024-11-10T07:12:29.648Z","avatar_url":"https://github.com/paritytech.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stateless Blockchain Experiment\n\n## Disclaimer\nThis repository is purely experimental and is not production quality. The design choices made in this project\nare impractical from both a security and usability standpoint. Additionally, the following code has not been checked for\ncorrectness, style, or efficiency.\n\n## Testing the Project\n\nIn the root directory:\n\n* To build the project, run `cargo build --release`\n* To start the chain, run `./target/release/stateless-blockchain --dev --execution-block-construction=Native`\n* If you need to reset the chain, run `./target/release/stateless-blockchain purge-chain --dev`\n* If you would like to execute tests, run `cargo test -p stateless-blockchain-runtime --release`\n\nIn the accumulator-client directory (you must use nightly Rust):\n\n* Install `wasm-pack` if you don't already have it `cargo install wasm-pack`\n* Run `wasm-pack build` to compile the crate to WASM.\n* Inside \"pkg\", run `npm link`\n\nIn the client directory:\n\n* Run `npm install` to install all necessary dependencies.\n* Run `npm link accumulator-client` to link to the generated WASM files.\n* Run `yarn start` to start a local server on localhost:8000.\n\n## Overview and Background\nThis project implements a UTXO-based stateless blockchain on Substrate using an RSA accumulator. A cryptographic accumulator is\na short commitment to a set that includes small witnesses(a Merkle Tree is a type of accumulator). However, compared\nto Merkle Trees, accumulators have constant size inclusion proofs, can efficiently add and delete(dynamic), and can support\nboth membership and non-membership proofs(universal). These features make accumulators a suitable fit for the stateless\nvalidation model.\n\nIn this scheme, validating parties only need to track a single dynamic accumulator that represents a commitment to\nthe state instead of actually having to store the entire state(such as the UTXO set in Bitcoin). Similarly, users only need to\nstore their own UTXOs and membership proofs. However, since users must constantly watch for updates to the accumulator\nin order to update their proofs, a data service provider who handles witnesses on behalf of users is likely to be used in\npractice. This particular implementation includes batching and aggregation techniques from this paper:\nhttps://eprint.iacr.org/2018/1188.pdf.\n\n## Details\n\n### Setup\nThe accumulator can be instantiated with a group of unknown order such as an RSA group. Any RSA number up to RSA-2048\nis supported(see the \"accumulator\" crate root). Accumulators can be instantiated with no trusted setup using class groups\nbut remain mostly a research topic at the moment.\n\n### Mechanics\nThe workflow of a stateless blockchain is as follows:\n\n1. A mechanism like Proof-of-Work or some other minting mechanism can be used to add new coins to the accumulator.\n2. To spend a coin, users construct transactions that include their UTXO, the membership witness for that UTXO, and a\nvalid transaction output.\n3. At the finalization of a block, the miner/validator aggregates all of the inclusion proofs from the spent UTXOs and\nuses it to batch delete them from the accumulator. Similarly, the miner/validator batch adds the newly created UTXOs\nto the accumulator. At each step, the miner/validator outputs a proof of correctness that the deletion/addition was\nexecuted correctly.\n\n### Structure\nThe base of this project is a simple Substrate runtime. However, the core accumulator logic is stored in the \"accumulator\"\ncrate and includes all of the integer specific functions, succinct proofs of exponentiation, and functions for creating\nor updating membership witnesses.\n\nThe front-end for this project is stored in the \"client\" directory and implements a simple React page based on the\nSubstrate Front-End template.\n\n\"accumulator-client\" is a wrapper crate for \"accumulator\" that uses wasm-bindgen to export several accumulator\nfunctions to WASM. This is necessary so that the front-end can interact with the accumulator.\n\n## Limitations\n\nSince this is an experimental project, there exists numerous limitations.\n\n* Instead of using a Proof-of-Work module, this runtime allows users to trivially mint new coins.\n* The \"UTXOs\" that are created more closely resemble non-fungible tokens and are not explicitly value bearing(only contain\nidentifier and owner).\n* Users can only submit one transaction per block and each transaction is limited to one input and one output.\n* Instead of aggregating inclusion proofs in memory, the \"blockchain\" must temporarily write the details of each incoming\ntransaction to storage (but are erased at the end of the block). This is currently the only viable method for processing\nincoming extrinsics without modifying Substrate itself.\n* The scheme does not verify any signatures. Signatures could be aggregated within a block using BLS signatures.\n\n##  Miscellaneous\n\nThe primary computational bottleneck occurs when a UTXO is hashed to a prime representation. Although this implementation\nuses a deterministic variant of the Miller-Rabin primality test that is \"efficient\", since we have used a small\nlambda value for testing, it can still be a limiting factor. Page 24 of https://eprint.iacr.org/2018/1188.pdf presents\na modification to the inclusion proofs such that the verifier only needs to perform one round of primality checking\ninstead of rederiving the hash representation(which involves about log(lambda) rounds). If transactions are taking too\nlong to process, the block time can be modified by changing \"MinimumPeriod\" in the crate root of the runtime.\n\nWith regard to semantics, it is important to note that this implementation is not *actually* a stateless blockchain since\nthe runtime still utilizes the underlying storage trie of Substrate as well as multiple SRML components. However, the\nstorage requirements are still fairly minimal.\n\n## Vector Commitments\n\nThe directory titled \"vector-commitment\" is a crate that implements both binary and general vector commitments using\nthe RSA accumulator. A vector commitment is a primitive that allows for the commitment of an ordered list of elements\nwhere elements can only be opened at their corresponding indices(position binding). Particularly, one can use a vector\ncommitment to commit to a binary vector by mapping the indices of elements that are 1 to primes and then batch adding\nthem to an accumulator. A subset of those indices can be opened with constant sized openings by utilizing the batching\nfunctionality from the accumulator. This scheme can be further generalized to accumulate a key-value store using a large\nsparse vector and finally used to build an account-based stateless blockchain.\n\n## Future Work\n\nHere is a non-comprehensive list of potential future steps.\n\n* Implementing more complex UTXO logic.\n* Integrating a Proof-of-Work module.\n* Creating a UX friendly front-end.\n* Creating a data service provider.\n* Investigating class groups.\n* Signature aggregation.\n* Explore accumulator unions and multiset accumulators.\n* Creating an account-based stateless blockchain runtime.\n\n## Reading List\n\n* https://eprint.iacr.org/2018/1188.pdf\n* https://www.zeroknowledge.fm/88\n* https://blog.goodaudience.com/deep-dive-on-rsa-accumulators-230bc84144d9\n* http://diyhpl.us/wiki/transcripts/stanford-blockchain-conference/2019/accumulators/\n* https://scalingbitcoin.org/transcript/tokyo2018/accumulators\n* https://ethresear.ch/t/accumulators-scalability-of-utxo-blockchains-and-data-availability/176\n* https://www.youtube.com/watch?v=tqqsbsAHJzs\n* https://ethresear.ch/t/rsa-accumulators-for-plasma-cash-history-reduction/3739\n* https://crypto.stackexchange.com/questions/66396/cryptographic-accumulators-accumulator-size-vs-max-number-of-set-members\n\nNote: This repository will no longer be maintained by its original owner after November 2019.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparitytech%2Fstateless-blockchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparitytech%2Fstateless-blockchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparitytech%2Fstateless-blockchain/lists"}