Skip to content

Add keccak256 to the standard library#274

Open
kmillikin wants to merge 8 commits intomainfrom
kmillikin/keccak
Open

Add keccak256 to the standard library#274
kmillikin wants to merge 8 commits intomainfrom
kmillikin/keccak

Conversation

@kmillikin
Copy link
Copy Markdown
Contributor

@kmillikin kmillikin commented Mar 30, 2026

The signature is the same as for persistentHash (SHA-256). It is implemented in the JS target by a runtime function keccak256 with the same signature as the existing runtime function persistentHash. It is implemented in ZKIR v3 with a single new operation keccak256 with the same signature as the existing persistent_hash operation.

It is unsupported in ZKIR v2 and it is a compile-time error to use it in an impure circuit without passing the experimental feature flag --feature-zkir-v3.

The signature is the same as for `persistentHash` (SHA-256).  It is implemented
in the JS target by a runtime function `keccakHash` with the same signature as
the existing runtime function `persistentHash`.  It is implemented in ZKIR v3
with a single new operation `keccak_hash` with the same signature as the
existing `persistent_hash` operation.

It is unsupported in ZKIR v2 and it is a compile-time error to use it in an
impure circuit without passing the experimental feature flag
`--feature-zkir-v3`.

Signed-off-by: Kevin Millikin <kevin.millikin@shielded.io>
@kmillikin kmillikin requested review from a team as code owners March 30, 2026 17:13
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

Plugin Test Summary

 1 files   3 suites   1s ⏱️
21 tests 21 ✅ 0 💤 0 ❌
23 runs  23 ✅ 0 💤 0 ❌

Results for commit 079eba3.

♻️ This comment has been updated with latest results.

Signed-off-by: Kevin Millikin <kevin.millikin@shielded.io>
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

Compactc E2E Test Summary

    1 files  ±    0      1 suites   - 47   5m 31s ⏱️ + 3m 3s
2 827 tests +2 346  2 827 ✅ +2 352  0 💤  - 6  0 ❌ ±0 
2 827 runs  +2 335  2 827 ✅ +2 341  0 💤  - 6  0 ❌ ±0 

Results for commit 079eba3. ± Comparison against base commit 1db6cba.

This pull request removes 481 and adds 2827 tests. Note that renamed tests count towards both.
src/tests/bugs/compiler.bugs.e2e.test.ts ‑ [Bugs] Compiler > '[MFG-413] should compile and not thro…'
src/tests/bugs/compiler.bugs.e2e.test.ts ‑ [Bugs] Compiler > '[PM-12371] should compile and not thr…'
src/tests/bugs/compiler.bugs.e2e.test.ts ‑ [Bugs] Compiler > '[PM-15405] should compile and not thr…'
src/tests/bugs/compiler.bugs.e2e.test.ts ‑ [Bugs] Compiler > '[PM-15733] should compile and not thr…'
src/tests/bugs/compiler.bugs.e2e.test.ts ‑ [Bugs] Compiler > '[PM-15826] should compile and not thr…'
src/tests/bugs/compiler.bugs.e2e.test.ts ‑ [Bugs] Compiler > '[PM-16040] should compile and not thr…'
src/tests/bugs/compiler.bugs.e2e.test.ts ‑ [Bugs] Compiler > '[PM-16059] should compile and not thr…'
src/tests/bugs/compiler.bugs.e2e.test.ts ‑ [Bugs] Compiler > '[PM-16447] should compile and not thr…'
src/tests/bugs/compiler.bugs.e2e.test.ts ‑ [Bugs] Compiler > '[PM-16853] should compile and not thr…'
src/tests/bugs/compiler.bugs.e2e.test.ts ‑ [Bugs] Compiler > '[PM-16999] should return an error if …'
…
src/tests/extracted.e2e.test.ts ‑ [E2E] Extracted unit tests for compiler > should be able to compile extracted contract: '/home/runner/work/_temp/nix-shell.2TfSdt/temp-test-2iTWof/contract_0.compact'
src/tests/extracted.e2e.test.ts ‑ [E2E] Extracted unit tests for compiler > should be able to compile extracted contract: '/home/runner/work/_temp/nix-shell.2TfSdt/temp-test-2iTWof/contract_1.compact'
src/tests/extracted.e2e.test.ts ‑ [E2E] Extracted unit tests for compiler > should be able to compile extracted contract: '/home/runner/work/_temp/nix-shell.2TfSdt/temp-test-2iTWof/contract_10.compact'
src/tests/extracted.e2e.test.ts ‑ [E2E] Extracted unit tests for compiler > should be able to compile extracted contract: '/home/runner/work/_temp/nix-shell.2TfSdt/temp-test-2iTWof/contract_100.compact'
src/tests/extracted.e2e.test.ts ‑ [E2E] Extracted unit tests for compiler > should be able to compile extracted contract: '/home/runner/work/_temp/nix-shell.2TfSdt/temp-test-2iTWof/contract_1000.compact'
src/tests/extracted.e2e.test.ts ‑ [E2E] Extracted unit tests for compiler > should be able to compile extracted contract: '/home/runner/work/_temp/nix-shell.2TfSdt/temp-test-2iTWof/contract_1001.compact'
src/tests/extracted.e2e.test.ts ‑ [E2E] Extracted unit tests for compiler > should be able to compile extracted contract: '/home/runner/work/_temp/nix-shell.2TfSdt/temp-test-2iTWof/contract_1002.compact'
src/tests/extracted.e2e.test.ts ‑ [E2E] Extracted unit tests for compiler > should be able to compile extracted contract: '/home/runner/work/_temp/nix-shell.2TfSdt/temp-test-2iTWof/contract_1003.compact'
src/tests/extracted.e2e.test.ts ‑ [E2E] Extracted unit tests for compiler > should be able to compile extracted contract: '/home/runner/work/_temp/nix-shell.2TfSdt/temp-test-2iTWof/contract_1004.compact'
src/tests/extracted.e2e.test.ts ‑ [E2E] Extracted unit tests for compiler > should be able to compile extracted contract: '/home/runner/work/_temp/nix-shell.2TfSdt/temp-test-2iTWof/contract_1005.compact'
…

♻️ This comment has been updated with latest results.

@kmillikin kmillikin changed the title Add keccakHash to the standard library Add keccak256 to the standard library Mar 31, 2026
iquerejeta and others added 4 commits March 31, 2026 17:15
Signed-off-by: Kevin Millikin <kevin.millikin@shielded.io>
Signed-off-by: Kevin Millikin <kevin.millikin@shielded.io>
Signed-off-by: Kevin Millikin <kevin.millikin@shielded.io>
`persistentHash`. Adds `keccak256` to the Compact runtime with the same
signature as `persistentHash`. `keccak256` requires the experimental feature
flag `--feature-zkir-v3` to work in an impure circuit (or called from an
impure circuit). It is a compiler error to use it in an impure circuit using
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should read: "impure" => "circuit that reads or writes public state". A circuit that invokes a witness but doesn't read or write public state is impure, but the restriction doesn't apply to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants