{"id":18031509,"url":"https://github.com/distributed-lab/nero","last_synced_at":"2025-03-27T05:30:47.116Z","repository":{"id":257367419,"uuid":"856952922","full_name":"distributed-lab/nero","owner":"distributed-lab","description":"Practical implementation of the BitVM2 protocol","archived":false,"fork":false,"pushed_at":"2024-12-24T19:02:20.000Z","size":5397,"stargazers_count":11,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-23T04:23:40.331Z","etag":null,"topics":["bitcoin","bitcoin-script","bitvm","bitvm2","rust","zk"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/distributed-lab.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":"2024-09-13T14:19:24.000Z","updated_at":"2025-01-20T14:03:32.000Z","dependencies_parsed_at":"2024-09-16T09:43:50.529Z","dependency_job_id":"3f1908b0-15e1-4c8b-b49e-a690b782ae8d","html_url":"https://github.com/distributed-lab/nero","commit_stats":null,"previous_names":["distributed-lab/bitvm2-splitter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distributed-lab%2Fnero","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distributed-lab%2Fnero/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distributed-lab%2Fnero/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/distributed-lab%2Fnero/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/distributed-lab","download_url":"https://codeload.github.com/distributed-lab/nero/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791270,"owners_count":20672664,"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":["bitcoin","bitcoin-script","bitvm","bitvm2","rust","zk"],"created_at":"2024-10-30T10:09:25.871Z","updated_at":"2025-03-27T05:30:47.108Z","avatar_url":"https://github.com/distributed-lab.png","language":"Rust","readme":"\u003cdiv align=\"center\"\u003e\n\u003ch1\u003e Nero: BitVM2 Made Practical \u003c/h1\u003e\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"25%\" src=\"./docs/images/icon.png\"\u003e\n\u003c/p\u003e\n\nPractical implementation of the BitVM2 protocol by Distributed Lab. You can check the \n[original BitVM2 paper](https://bitvm.org/bitvm_bridge.pdf) and\n[our implementation paper](./docs/paper/nero.pdf) for more details).\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e This project is under heavy development and API can drastically vary due to its early development stage.\n\u003e We do not guarantee any backward compatibility until the first release and recommend using it with great caution.\n\n## :file_folder: Contents\n\nThe project contains multiple crates:\n\n| Crate | Description |\n| --- | --- |\n| [`bitcoin-splitter`](bitcoin-splitter/README.md) | A crate for splitting the Bitcoin script into multiple parts as suggested by the recent [^1]). |\n| [`bitcoin-winternitz`](bitcoin-winternitz) | Winternitz Signature and recovery implementation based on BitVM's [`[signatures]`](https://github.com/BitVM/BitVM/tree/main/src/signatures) package. |\n| [`bitcoin-utils`](bitcoin-utils) | Helper package containing the implementation of certain fundamental operations and debugging functions. |\n| [`bitcoin-testscripts`](bitcoin-testscripts) | A collection of test scripts for testing BitVM2 concept. |\n| [`bitcoin-scriptexec`](bitcoin-scriptexec) | A helper crate for executing Bitcoin scripts. Fork of [BitVM package](https://github.com/BitVM/rust-bitcoin-scriptexec). |\n\n## Setting up a Local Bitcoin Node\n\n```shell\ndocker compose up -d\n```\n\n\u003e [!WARNING]\n\u003e\n\u003e Sometimes Docker Compose may fail at step of creating the volumes,\n\u003e the most simple solution is, in regards of failure, just trying\n\u003e starting it again several times until it works.\n\nLet us create a temporary alias for `bitcoin-cli` from the container like this:\n\n```shell\nalias bitcoin-cli=\"docker compose exec bitcoind bitcoin-cli\"\n```\n\nCreate a fresh wallet for your user:\n\n```shell\nbitcoin-cli createwallet \"my\"\n```\n\n\u003e [!WARNING]\n\u003e\n\u003e Do not create more than one wallet, otherwise further steps would\n\u003e require a bit of modification.\n\nGenerate fresh address and store it to environmental variable:\n\n```shell\nexport ADDRESS=$(bitcoin-cli -rpcwallet=\"my\" getnewaddress \"main\" \"bech32\")\n```\n\nThen mine 101 blocks to your address:\n\n```shell\nbitcoin-cli generatetoaddress 101 $ADDRESS\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e Rewards for mined locally blocks will go to this address, but, by\n\u003e protocol rules, BTCs are mature only after 100 confirmations, so\n\u003e that's why 101 blocks are mined. You can see other in `immature`\n\u003e balances fields, after executing next command.\n\u003e\n\u003e For more info about Bitcoin RPC API see [^2].\n\n```shell\nbitcoin-cli -rpcwallet=\"my\" getbalances\n```\n\n## Working with `nero-cli`\n\nCompile `nero-cli`:\n\n```shell\ncargo install --path ./nero-cli\n```\n\t\nGenerate random pair of keys for payout path spending:\n\n```shell\nnero-cli --config ./nero.toml generate-keys\n```\n\nPossible output:\n\n```shell\nabffe139daab7e63742643886728755f08288f5d05fb6a0aebc3f3ff41d1d83c\n02dedae18ba57d264289ae13f9009ba4ff62d006d8a64078724a5f153c8f7cca71\n```\n\nGenerate some random input for script:\n\n```shell\nnero-cli --config ./nero.toml generate-input\n```\n\nNow you got a generated script input in `input.txt` file in hex format\nand in Bitcoin script in stdout, for example output could be:\n\n```\nOP_PUSHBYTES_3 f4531f OP_PUSHBYTES_4 5bca4206 OP_PUSHBYTES_4 d3d2de1f OP_PUSHBYTES_4 831e530e OP_PUSHBYTES_4 35364014 OP_PUSHBYTES_4 c54c6802 OP_PUSHBYTES_4 be8eaa14 OP_PUSHBYTES_4 1907b201 OP_PUSHBYTES_4 9eb1a719 OP_PUSHBYTES_3 f4531f OP_PUSHBYTES_4 5bca4206 OP_PUSHBYTES_4 d3d2de1f OP_PUSHBYTES_4 831e530e OP_PUSHBYTES_4 35364014 OP_PUSHBYTES_4 c54c6802 OP_PUSHBYTES_4 be8eaa14 OP_PUSHBYTES_4 1907b201 OP_PUSHBYTES_4 9eb1a719\n```\n\n### Payout path spending\n\nNow, let's generate and send assert transaction:\n\n```shell\nnero-cli --config ./nero.toml assert-tx --input ./input.txt --amount 0.007BTC --pubkey dedae18ba57d264289ae13f9009ba4ff62d006d8a64078724a5f153c8f7cca71\n```\n\nThis could take a while for fibonachi sequence. You'll then get a\ntransaction id:\n\n```shell\na35153ff68d3fce1fd1f270c4a3a3ef1f1fb1703055c03f6b5b1fef9d08f50ee:0\n```\n\n\u003e And all disprove scripts in `disproves` directories with payout script\n\u003e in `payout.txt`.\n\n\nWhich you could fetch and check:\n\n```shell\nbitcoin-cli getrawtransaction A35153ff68d3fce1fd1f270c4a3a3ef1f1fb1703055c03f6b5b1fef9d08f50ee\n```\n\nThen convert it from hex to JSON:\n\n```shell\nbitcoin-cli decoderawtransaction 020000000001014754bb8d55fb1a9dcf2380c7011eed1601e3c070aeb9f2481f0c28e322199ac90100000000fdffffff0260ae0a0000000000225120d75e8e13e5467b03ea564f8f60c9acdc0859a320bf5359c2accd20e34cbb73ec67c94704000000002251203d8f7c4be893b12bd0a81aa99dd313f01f6cde1eca6ce67d2b029c940b5c804c0140b045b92d05c9b78ca58bc7402650bf8bac49a06b8d85991ca841fff95e1f21ed3f40c5ec84a966dc824b0a706ec8de8e2f5fa0f754ded8c27e1162aaa86d861700000000\n```\n\nLet's spend it by payout transaction. To pass the default locktime of\ntwo weeks, we need to mine 2017 blocks:\n\n```shell\nbitcoin-cli generatetoaddress 2017 $ADDRESS \u0026\u003e /dev/null\n```\n\nAnd then spend it:\n\n```shell\nnero-cli --config ./nero.toml spend-payout --assert a35153ff68d3fce1fd1f270c4a3a3ef1f1fb1703055c03f6b5b1fef9d08f50ee:0 --seckey Abffe139daab7e63742643886728755f08288f5d05fb6a0aebc3f3ff41d1d83c --address $ADDRESS\n```\n\nOutput:\n\n```shell\n7bb040e609cc1acababfb17a50b6c48646c28d5afdcbb45cf33dca1e69542d2a\n```\n\n### Disprove spending\n\n```shell\nnero-cli --config ./nero.toml assert-tx --input ./input.txt --amount 0.007BTC --pubkey dedae18ba57d264289ae13f9009ba4ff62d006d8a64078724a5f153c8f7cca71 --address $ADDRESS --distort\n```\n\nOutput:\n\n```shell\n11283f38271775b6250ce97d9f633a6977f4318625ab7ea4d36b8535e7c2c692:0 # \u003c-- assert tx out\n445 # \u003c-- spendable disprove script (because of invalid states)\n```\n\nAnd let's spend it using disprove script from local directory\n`disproves` by number:\n\n```shell\nnero-cli --config ./nero.toml spend-disprove --assert 11283f38271775b6250ce97d9f633a6977f4318625ab7ea4d36b8535e7c2c692:0 --address $ADDRESS --disprove 445\n```\n\n[^1]: https://bitvm.org/bitvm_bridge.pdf\n[^2]: https://developer.bitcoin.org/reference/rpc/\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistributed-lab%2Fnero","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdistributed-lab%2Fnero","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdistributed-lab%2Fnero/lists"}