{"id":18762759,"url":"https://github.com/arnaucube/hash-chain-sonobe","last_synced_at":"2025-04-13T03:32:29.199Z","repository":{"id":239028243,"uuid":"798309271","full_name":"arnaucube/hash-chain-sonobe","owner":"arnaucube","description":"Repo showcasing usage of Sonobe with Arkworks and Circom circuits to prove a hash-chain.","archived":false,"fork":false,"pushed_at":"2024-11-03T19:01:54.000Z","size":30,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-03T19:29:36.201Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arnaucube.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-05-09T14:18:42.000Z","updated_at":"2024-11-03T19:01:57.000Z","dependencies_parsed_at":"2024-05-09T15:42:32.667Z","dependency_job_id":"20bc69f0-01b5-41c8-b4d0-3a905c63098f","html_url":"https://github.com/arnaucube/hash-chain-sonobe","commit_stats":null,"previous_names":["arnaucube/keccak-chain-sonobe"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaucube%2Fhash-chain-sonobe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaucube%2Fhash-chain-sonobe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaucube%2Fhash-chain-sonobe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arnaucube%2Fhash-chain-sonobe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arnaucube","download_url":"https://codeload.github.com/arnaucube/hash-chain-sonobe/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223565707,"owners_count":17166160,"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-07T18:23:14.062Z","updated_at":"2024-11-07T18:23:14.710Z","avatar_url":"https://github.com/arnaucube.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hash-chain-sonobe\n\nRepo showcasing usage of [Sonobe](https://github.com/privacy-scaling-explorations/sonobe) with [Arkworks](https://github.com/arkworks-rs) and [Circom](https://github.com/iden3/circom) circuits.\n\nThe main idea is to prove $z_n = H(H(...~H(H(H(z_0)))))$, where $n$ is the number of Keccak256 hashes ($H$) that we compute. Proving this in a 'normal' R1CS circuit for a large $n$ would be too costly, but with folding we can manage to prove it in a reasonable time span.\n\nFor more info about Sonobe, check out [Sonobe's docs](https://privacy-scaling-explorations.github.io/sonobe-docs).\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://privacy-scaling-explorations.github.io/sonobe-docs/imgs/folding-main-idea-diagram.png\" style=\"width:70%;\" /\u003e\n\u003c/p\u003e\n\n\n### Usage\n\n### poseidon_chain.rs (arkworks circuit)\nProves a chain of Poseidon hashes, using the [arkworks/poseidon](https://github.com/arkworks-rs/crypto-primitives/blob/main/crypto-primitives/src/sponge/poseidon/constraints.rs) circuit, with [Nova](https://eprint.iacr.org/2021/370.pdf)+[CycleFold](https://eprint.iacr.org/2023/1192.pdf).\n\n- `cargo test --release poseidon_chain -- --nocapture`\n\n### sha_chain_offchain.rs (arkworks circuit)\nProves a chain of SHA256 hashes, using the [arkworks/sha256](https://github.com/arkworks-rs/crypto-primitives/blob/main/crypto-primitives/src/crh/sha256/constraints.rs) circuit, with [Nova](https://eprint.iacr.org/2021/370.pdf)+[CycleFold](https://eprint.iacr.org/2023/1192.pdf).\n\n- `cargo test --release sha_chain_offchain -- --nocapture`\n\n### keccak_chain.rs (circom circuit)\nProves a chain of keccak256 hashes, using the [vocdoni/keccak256-circom](https://github.com/vocdoni/keccak256-circom) circuit, with [Nova](https://eprint.iacr.org/2021/370.pdf)+[CycleFold](https://eprint.iacr.org/2023/1192.pdf).\n\nAssuming rust and circom have been installed:\n- `./compile-circuit.sh`\n- `cargo test --release keccak_chain -- --nocapture`\n\nNote: the Circom variant currently has a bit of extra overhead since at each folding step it uses Circom witness generation to obtain the witness and then it imports it into the arkworks constraint system.\n\n### Repo structure\n- the Circom circuit (that defines the keccak-chain) to be folded is defined at [./circuit/keccak-chain.circom](https://github.com/arnaucube/hash-chain-sonobe/blob/main/circuit/keccak-chain.circom)\n- the logic to fold the circuit using Sonobe is defined at [src/{poseidon_chain, sha_chain_{offchain, onchain}, keccak_chain}.rs](https://github.com/arnaucube/hash-chain-sonobe/blob/main/src)\n\n\n\n## Other\nAdditionally there is the `src/naive_approach_{poseidon,sha}_chain.rs` file, which mimics the amount of hashes computed by the `src/{poseidon,sha}_chain.rs` file, but instead of folding it does it by building a big circuit that does all the hashes at once, as we would do before folding existed.\n\nTo run it:\n- `cargo test --release naive_approach_sha_chain -- --nocapture`\n- `cargo test --release naive_approach_poseidon_chain -- --nocapture`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnaucube%2Fhash-chain-sonobe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farnaucube%2Fhash-chain-sonobe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farnaucube%2Fhash-chain-sonobe/lists"}