{"id":21352099,"url":"https://github.com/avras/nova-sha256","last_synced_at":"2025-07-12T20:32:05.384Z","repository":{"id":148292311,"uuid":"612323556","full_name":"avras/nova-sha256","owner":"avras","description":"Nova-based SHA256 benchmarks","archived":false,"fork":false,"pushed_at":"2024-03-26T04:37:41.000Z","size":89,"stargazers_count":29,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-16T08:35:20.372Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/avras.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-10T17:26:44.000Z","updated_at":"2024-06-14T05:33:57.000Z","dependencies_parsed_at":"2023-05-19T16:00:29.451Z","dependency_job_id":null,"html_url":"https://github.com/avras/nova-sha256","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avras%2Fnova-sha256","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avras%2Fnova-sha256/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avras%2Fnova-sha256/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/avras%2Fnova-sha256/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/avras","download_url":"https://codeload.github.com/avras/nova-sha256/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225834368,"owners_count":17531471,"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-22T03:12:33.631Z","updated_at":"2024-11-22T03:12:34.557Z","avatar_url":"https://github.com/avras.png","language":"Rust","funding_links":[],"categories":["Applications"],"sub_categories":["Forums"],"readme":"# Nova-based SHA256\n \n[Nova](https://github.com/microsoft/Nova) is a recursive SNARK that is suitable for computations with repeated structure, i.e. computations of the form $z_{i+1} = F(z_i)$. At each step, the function $F$ is allowed to have private inputs.\n\nThe SHA256 hash of a long input is computed by repeatedly applying the SHA256 compression function. At each step, the compression function consumes the previous 32-byte digest and a 64-byte block of the padded input. In the first step, a fixed initial value ($IV$) is used as the digest.\n\nTo use Nova to prove that the output of a message has a particular hash value, we can set $z_0 = IV$ and $F$ = SHA256 compression function. At each step, we provide the 64-byte message block as a private input.\n\n## Running the example\nRun the following commands.\n```\ncargo build --release\ncargo run -r --example sha256 6\n```\nIn the above case, The input message to SHA256 will be $2^6$ zero bytes. The output will look like the following.\n```\nNova-based SHA256 compression function iterations\n=========================================================\nProducing public parameters...\nPublicParams::setup, took 3.607127198s \nNumber of constraints per step (primary circuit): 37034\nNumber of constraints per step (secondary circuit): 10347\nNumber of variables per step (primary circuit): 37000\nNumber of variables per step (secondary circuit): 10329\nGenerating a RecursiveSNARK...\nRecursiveSNARK::prove_step 0: true, took 1.047µs \nRecursiveSNARK::prove_step 1: true, took 81.249423ms \nTotal time taken by RecursiveSNARK::prove_steps: 81.283345ms\nVerifying a RecursiveSNARK...\nRecursiveSNARK::verify: true, took 71.64086ms\nGenerating a CompressedSNARK using Spartan with IPA-PC...\nCompressedSNARK::prove: true, took 3.971226131s\nTotal proving time is 4.54092927s\nCompressedSNARK::len 9938 bytes\nVerifying a CompressedSNARK...\nCompressedSNARK::verify: true, took 141.363763ms\n=========================================================\nPublic parameters generation time: 3.607127198s \nTotal proving time (excl pp generation): 4.54092927s\nTotal verification time: 141.363763ms\n=========================================================\nExpected value of final hash = \"f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b\"\nActual value of final hash   = \"f5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b\"\n```\n\nTo change the input length to 64 KB ($2^{16}$ bytes), run the following command. The input is again all zero bytes.\n```\ncargo run -r --example sha256 16\n```\n\n## Generating the benchmarks\nRun the following commands (shell script tested only on Ubuntu).\n```bash\ncargo build --release --examples\n./genlog_all.sh\n```\nThe `logs` directory will have two files per input length `N`, for `N` in the set {64, 128, ..., 65536}.\n\n- `output_N.txt` has the program output.\n- `time_output_N.txt` has the output of the `time` command. This is used to measure peak memory usage.\n\nTo generate the logs for a particular length, you can run the `genlog.sh` script. For example, the following command will generate logs for input length 1024 bytes.\n```\n./genlog.sh 10\n```\n## Existing benchmarks\nThe existing files in the `logs` directory were generated on a Dell Inspiron laptop with a [11th Gen Intel i5-11320H CPU](https://ark.intel.com/content/www/us/en/ark/products/217183/intel-core-i511320h-processor-8m-cache-up-to-4-50-ghz-with-ipu.html) and 16 GB of RAM. The CPU has 4 cores with 2 threads per core.\n- For all lengths\n  - The peak memory usage was about 260 MB.\n  - Verification time was less than 150 milliseconds.\n  - Proof size was about 10,000 bytes.\n  - Public parameter generation time was about 4 seconds\n- The proving time for 64KB input was around 2 minutes. Proving times for other lengths are shown below.\n\n### Proving times\n```bash\n$ grep \"Total proving time is\" $(ls logs/output_* -rt)\nlogs/output_65536.txt:Total proving time is 128.361272568s\nlogs/output_32768.txt:Total proving time is 67.385187591s\nlogs/output_16384.txt:Total proving time is 35.242403037s\nlogs/output_8192.txt:Total proving time is 19.427134991s\nlogs/output_4096.txt:Total proving time is 11.853209643s\nlogs/output_2048.txt:Total proving time is 8.10600355s\nlogs/output_1024.txt:Total proving time is 6.274435826s\nlogs/output_512.txt:Total proving time is 5.395036577s\nlogs/output_256.txt:Total proving time is 4.970008973s\nlogs/output_128.txt:Total proving time is 4.551801823s\nlogs/output_64.txt:Total proving time is 4.475632468s\n```\n\n### Verification times\n```bash\n$ grep \"CompressedSNARK::verify\" $(ls logs/output_* -rt)\nlogs/output_65536.txt:CompressedSNARK::verify: true, took 161.669379ms\nlogs/output_32768.txt:CompressedSNARK::verify: true, took 154.329705ms\nlogs/output_16384.txt:CompressedSNARK::verify: true, took 154.323314ms\nlogs/output_8192.txt:CompressedSNARK::verify: true, took 150.839038ms\nlogs/output_4096.txt:CompressedSNARK::verify: true, took 140.438199ms\nlogs/output_2048.txt:CompressedSNARK::verify: true, took 135.292959ms\nlogs/output_1024.txt:CompressedSNARK::verify: true, took 132.714996ms\nlogs/output_512.txt:CompressedSNARK::verify: true, took 139.134246ms\nlogs/output_256.txt:CompressedSNARK::verify: true, took 135.419974ms\nlogs/output_128.txt:CompressedSNARK::verify: true, took 133.126469ms\nlogs/output_64.txt:CompressedSNARK::verify: true, took 123.653851ms\n```\n\n### Proof sizes\n```bash\n$ grep \"len\" $(ls logs/output_* -rt)\nlogs/output_65536.txt:CompressedSNARK::len 9976 bytes\nlogs/output_32768.txt:CompressedSNARK::len 9975 bytes\nlogs/output_16384.txt:CompressedSNARK::len 9977 bytes\nlogs/output_8192.txt:CompressedSNARK::len 9971 bytes\nlogs/output_4096.txt:CompressedSNARK::len 9974 bytes\nlogs/output_2048.txt:CompressedSNARK::len 9972 bytes\nlogs/output_1024.txt:CompressedSNARK::len 9971 bytes\nlogs/output_512.txt:CompressedSNARK::len 9975 bytes\nlogs/output_256.txt:CompressedSNARK::len 9973 bytes\nlogs/output_128.txt:CompressedSNARK::len 9974 bytes\nlogs/output_64.txt:CompressedSNARK::len 9938 bytes\n```\n\n### Peak memory usage\n```bash\n$ grep \"Maximum resident set size\" $(ls logs/time_output_* -rt)\nlogs/time_output_65536.txt:     Maximum resident set size (kbytes): 261356\nlogs/time_output_32768.txt:     Maximum resident set size (kbytes): 265844\nlogs/time_output_16384.txt:     Maximum resident set size (kbytes): 260856\nlogs/time_output_8192.txt:      Maximum resident set size (kbytes): 266920\nlogs/time_output_4096.txt:      Maximum resident set size (kbytes): 262376\nlogs/time_output_2048.txt:      Maximum resident set size (kbytes): 264108\nlogs/time_output_1024.txt:      Maximum resident set size (kbytes): 261804\nlogs/time_output_512.txt:       Maximum resident set size (kbytes): 263784\nlogs/time_output_256.txt:       Maximum resident set size (kbytes): 262496\nlogs/time_output_128.txt:       Maximum resident set size (kbytes): 263340\nlogs/time_output_64.txt:        Maximum resident set size (kbytes): 262608\n```\n### Public parameter generation time\n```bash\n$ grep \"Public parameters\" $(ls logs/output_* -rt)\nlogs/output_65536.txt:Public parameters generation time: 3.612032586s \nlogs/output_32768.txt:Public parameters generation time: 3.87279403s \nlogs/output_16384.txt:Public parameters generation time: 3.920718336s \nlogs/output_8192.txt:Public parameters generation time: 3.846917525s \nlogs/output_4096.txt:Public parameters generation time: 3.795370968s \nlogs/output_2048.txt:Public parameters generation time: 3.72987859s \nlogs/output_1024.txt:Public parameters generation time: 3.679694828s \nlogs/output_512.txt:Public parameters generation time: 3.720623095s \nlogs/output_256.txt:Public parameters generation time: 3.717689922s \nlogs/output_128.txt:Public parameters generation time: 3.662263553s \nlogs/output_64.txt:Public parameters generation time: 3.597867008s\n```\n\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0\n   ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license\n   ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favras%2Fnova-sha256","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Favras%2Fnova-sha256","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Favras%2Fnova-sha256/lists"}