Skip to content

Commit

Permalink
Merge branch 'main' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
saleel committed Apr 15, 2024
2 parents f2fb77c + fd7558a commit f2b4e72
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 14 deletions.
8 changes: 5 additions & 3 deletions docs/zk-email-docs/UsageGuide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ To compile the circuit locally, you need to have Rust and Circom installed first


```bash
circom MyCircuit.circom -o --r1cs --wasm --sym --c
circom -l node_modules MyCircuit.circom -o --r1cs --wasm --sym --c --O0
```
*Note: You can add `-l` to specify the directory where the directive `include` should look for the circuits indicated. For our repo, use `circom -l node_modules` instead of `circom`. Additionally, we generally recommend using the `--O0` flag for optimization during compilation for beginners. However, if you're more experienced with Circom, feel free to use the `--O1` flag instead. It's important to avoid using the `--O2` flag as that is the default setting and it may lead to the deletion of additional constraints.*
*Note: You can add `-l` to specify the directory where the directive `include` should look for the circuits indicated. For our repo, if you are having errors, we recommend to use `circom -l node_modules` instead of `circom`.*

After running this command, the circuit will be compiled into a `.r1cs` file, a `.wasm` file, and a `.sym` file. These files are used in the next steps to generate the proving and verifying keys, and to compute the witness.
We generally recommend using the --O0 flag for ensuring there are no unintended underconstraints, but if you need to optimize constraints and understand what is being changed in circom, feel free to use --O1 instead. It's important to avoid using the `--O2` flag as that is the default setting and it may lead to the deletion of addition constraints.

Refer to these discussions on StackOverflow ([1](https://stackoverflow.com/questions/78136647/circom-does-not-create-a-constraint-for-addition/78177349#78177349), [2](https://stackoverflow.com/questions/77688466/circom-compiler-removes-crucial-constraint-after-simplication/78177354?noredirect=1#comment137833229_78177354)) for more information on constraint deletion.

After running this command, the circuit will be compiled into a `.r1cs` file, a `.wasm` file, and a `.sym` file. These files are used in the next steps to generate the proving and verifying keys, and to compute the witness.

## Step 5: Compute the Witness

Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/DKIMRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import "./interfaces/IDKIMRegistry.sol";
Input is DKIM pub key split into 17 chunks of 121 bits. You can use `helpers` package to fetch/split DKIM keys
*/
contract DKIMRegistry is IDKIMRegistry, Ownable {
constructor(address _signer) Ownable(_signer) { }

event DKIMPublicKeyHashRegistered(string domainName, bytes32 publicKeyHash);
event DKIMPublicKeyHashRevoked(bytes32 publicKeyHash);

Expand Down
6 changes: 6 additions & 0 deletions packages/contracts/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Set up

```bash
yarn install
```

## DKIMRegistry.sol

The `DKIMRegistry.sol` is a Solidity contract that serves as a registry for storing the hash of the DomainKeys Identified Mail (DKIM) public key for each domain. This contract is part of the `@zk-email/contracts` package.
Expand Down
3 changes: 2 additions & 1 deletion packages/contracts/foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
src = './'
out = 'out'
allow_paths = ['../../node_modules']
solc_version = '0.8.21'
libs = ['../../node_modules']
solc_version = '0.8.21'
9 changes: 6 additions & 3 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"name": "@zk-email/contracts",
"version": "5.0.2",
"version": "6.0.0",
"scripts": {
"build": "forge build",
"publish": "yarn npm publish --access=public"
},
"dependencies": {
"@openzeppelin/contracts": "^4.9.3",
"@openzeppelin/contracts": "^5.0.0",
"dotenv": "^16.3.1"
},
"files": [
"DKIMRegistry.sol",
"/utils",
"/interfaces"
]
],
"devDependencies": {
"forge-std": "https://github.com/foundry-rs/forge-std"
}
}
5 changes: 3 additions & 2 deletions packages/contracts/remappings.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@openzeppelin=../../node_modules/@openzeppelin/contracts
@openzeppelin/contracts=../../node_modules/@openzeppelin/contracts
@openzeppelin/contracts-upgradeable=../../node_modules/@openzeppelin/contracts-upgradeable
@openzeppelin=../../node_modules/@openzeppelin/contracts
forge-std=../../node_modules/forge-std

27 changes: 27 additions & 0 deletions packages/contracts/test/DKIMRegistry.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.12;

import "@openzeppelin/contracts/utils/Strings.sol";
import "forge-std/src/Test.sol";
import "forge-std/src/console.sol";
import "../interfaces/IDKIMRegistry.sol";
import "../DKIMRegistry.sol";

/// @title ECDSAOwnedDKIMRegistry
/// @notice A DKIM Registry that could be updated by predefined ECDSA signer
contract TestDKIMRegistry is Test {
DKIMRegistry public dkimRegistry;
address public signer;

constructor() {
dkimRegistry = new DKIMRegistry(msg.sender);
signer = msg.sender;
}

function test_setDKIM() public {
vm.prank(signer);
dkimRegistry.setDKIMPublicKeyHash("test.com", "a81273981273bce922");
vm.stopPrank();
}
}

18 changes: 13 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2319,10 +2319,10 @@ __metadata:
languageName: node
linkType: hard

"@openzeppelin/contracts@npm:^4.9.3":
version: 4.9.6
resolution: "@openzeppelin/contracts@npm:4.9.6"
checksum: 274b6e968268294f12d5ca4f0278f6e6357792c8bb4d76664f83dbdc325f780541538a127e6a6e97e4f018088b42f65952014dec9c745c0fa25081f43ef9c4bf
"@openzeppelin/contracts@npm:^5.0.0":
version: 5.0.2
resolution: "@openzeppelin/contracts@npm:5.0.2"
checksum: 0cce6fc284bd1d89e2a447027832a62f1356b44ee31088899453e10349a63a62df2f07da63d76e4c41aad9c86b96b650b2b6fc85439ef276850dda1170a047fd
languageName: node
linkType: hard

Expand Down Expand Up @@ -2777,8 +2777,9 @@ __metadata:
version: 0.0.0-use.local
resolution: "@zk-email/contracts@workspace:packages/contracts"
dependencies:
"@openzeppelin/contracts": ^4.9.3
"@openzeppelin/contracts": ^5.0.0
dotenv: ^16.3.1
forge-std: "https://github.com/foundry-rs/forge-std"
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -4839,6 +4840,13 @@ __metadata:
languageName: node
linkType: hard

"forge-std@https://github.com/foundry-rs/forge-std":
version: 1.7.6
resolution: "forge-std@https://github.com/foundry-rs/forge-std.git#commit=e4aef94c1768803a16fe19f7ce8b65defd027cfd"
checksum: 6fab51b92a24c97384f55dcb1b9eba29ce5043b67930b4179a9f9f4f8da85e8315163db60bec2ffbe7334135755630ba549b246db9e503e59ec93ba2f11931cc
languageName: node
linkType: hard

"fs-minipass@npm:^2.0.0":
version: 2.1.0
resolution: "fs-minipass@npm:2.1.0"
Expand Down

0 comments on commit f2b4e72

Please sign in to comment.