Add Keccak-256 to sha3 module and experimental hidden_pk circuit#152
Open
Mahdi171 wants to merge 6 commits intogoogle:mainfrom
Open
Add Keccak-256 to sha3 module and experimental hidden_pk circuit#152Mahdi171 wants to merge 6 commits intogoogle:mainfrom
Mahdi171 wants to merge 6 commits intogoogle:mainfrom
Conversation
feat/added hiddenpk circuit & tests
feat/added keccak to hidden pk circuit
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds Keccak-256 support to the sha3 module and a new experimental
hidden_pkcircuit undercircuits/hidden_pk/. Both pieces are independent of the existing mdoc and anoncred circuits.Motivation
The
hidden_pkcircuit is the proving step for a quantum-resistant Ethereum wallet construction ([ethresear.ch link]): an existing Ethereum EOA delegates via EIP-7702 to a contract that authorizes transactions only against a ZK proof under a hidden public key, so the public key never appears onchain in steady state. Hash preimage resistance survives quantum attacks, so the account stays quantum-safe regardless of how many transactions it processes. There is live demo here.The circuit is also reusable for any ECDSA-ZK application that needs the public key kept private and an Ethereum-address-shaped public input. The Keccak-256 addition is independent and useful on its own for any libzk caller working with Ethereum hashes.
Keccak-256
Ethereum uses Keccak-256 for address derivation and the
keccakEVM opcode. It differs from SHA3-256 only in the padding byte (0x01 vs 0x06); the underlying Keccak-f[1600] permutation is identical. The existing SHA3 machinery already handles the permutation in reference, witness, and circuit form, so this addition is small:sha3_reference.{h,cc}:keccak256Hash(32-byte output, 0x01 padding)sha3_witness.{h,cc}:compute_witness_keccak256for block witnessessha3_circuit.h:assert_keccak256circuit methodsha3_reference_test.cc: known vectors forkeccak256(""),keccak256("abc"), and an Ethereum address derivation sanity checksha3_circuit_test.cc:AssertKeccak256EthereumAddressend-to-end testhidden_pk circuit
The circuit proves the relation:
Public inputs: the 20-byte Ethereum address and the message hash
e. Private witnesses:pk = (pkx, pky)andsig = (r, s).A verifier learns that some valid secp256k1 ECDSA signature exists under a key whose Ethereum address is
eth_addr, without seeing the key or the signature. Revealing(r, s)together witheis enough to recoverpkviaecrecover, which is why both stay hidden.Files added under
lib/circuits/hidden_pk/:hidden_pk_circuit.h: composes ECDSA verify with Keccak-256 overpkx_bytes || pky_bytes(64 bytes, one Keccak block) and equates digest bytes[12:32]with the publiceth_addrhidden_pk_witness.h: witness computation from(pk, e, r, s)hidden_pk_test.cc: ZK prove/verify test andBM_HiddenPKProverbenchmarkCMakeLists.txtTests
Notes
hidden_pkis registered under the existing "experiments and tests" comment inlib/CMakeLists.txt. No production code depends on it.sk, so the two variable-base MSMs collapse to fixed-base) would cut constraints roughly 3-5x and proof size to ~50-80 KB. Left as future work.