-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: input proofs DB table and communication
Define the communication over the DB between the gw-listener, the zkproof-worker and the transaction-sender services. Add more verify proof tests in transaction-sender. Fix compiler warnings in coprocessor due to deprecated rand functions.
- Loading branch information
1 parent
b826fbf
commit d50c8e5
Showing
15 changed files
with
331 additions
and
57 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
artifacts | ||
cache |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Gateway Listener | ||
|
||
The **gw-listener** service listens for input proof verification events from the ZKPoKManager contract and inserts them into the DB into the `verify_proofs` table: [verify_proofs table](../fhevm-db/migrations/20250207092623_verify_proofs.sql) | ||
|
||
The following fields are insertion in by gw-listner: | ||
|
||
* zk_proof_id | ||
* chain_id | ||
* contract_address | ||
* user_address | ||
* input (the ciphertext + proof as a tfhe-rs serialized data structure) | ||
* created_at | ||
|
||
At the time of insertion, the `verified` and `verified_at` fields are false and NULL, respectively. | ||
|
||
The gw-listener will notify **zkproof-worker** services that work is available over the `verify_proof_requests` DB channel (configurable, but this is the default one). | ||
|
||
Once a ZK proof request is verified, a zkproof-worker should set: | ||
* `verified = true` | ||
* `verified_at = NOW()` | ||
* `handles = concatenated 32-byte handles` (s.t. the length of the handles field in bytes is a multiple of 32) | ||
|
||
Then, zkproof-worker should notify the **transaction-sender** on the **verify_proof_responses** DB channel (configurable, but this is the default one). |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use std::path::Path; | ||
|
||
use foundry_compilers::{Project, ProjectPathsConfig}; | ||
|
||
fn main() { | ||
let paths = ProjectPathsConfig::hardhat(Path::new(env!("CARGO_MANIFEST_DIR"))).unwrap(); | ||
let project = Project::builder() | ||
.paths(paths) | ||
.build(Default::default()) | ||
.unwrap(); | ||
|
||
let output = project.compile().unwrap(); | ||
assert!(!output.has_compiler_errors()); | ||
|
||
project.rerun_if_sources_changed(); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause-Clear | ||
pragma solidity ^0.8.28; | ||
|
||
contract ZKPoKManager { | ||
event VerifyProofRequest( | ||
uint256 indexed zkProofId, | ||
uint256 indexed contractChainId, | ||
address contractAddress, | ||
address userAddress, | ||
bytes ciphertextWithZKProof | ||
); | ||
|
||
uint256 zkProofIdCounter = 0; | ||
|
||
function verifyProofRequest( | ||
uint256 contractChainId, | ||
address contractAddress, | ||
address userAddress, | ||
bytes calldata ciphertextWithZKProof | ||
) public { | ||
uint256 zkProofId = zkProofIdCounter; | ||
zkProofIdCounter += 1; | ||
emit VerifyProofRequest( | ||
zkProofId, | ||
contractChainId, | ||
contractAddress, | ||
userAddress, | ||
ciphertextWithZKProof | ||
); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1 @@ | ||
pub fn add(left: u64, right: u64) -> u64 { | ||
left + right | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.