Skip to content

Commit 4e743ba

Browse files
author
AztecBot
committed
Merge branch 'next' into merge-train/avm
2 parents 26bdc8d + 39c8120 commit 4e743ba

File tree

14 files changed

+165
-128
lines changed

14 files changed

+165
-128
lines changed

l1-contracts/lib/circuits

Submodule circuits updated 764 files

l1-contracts/script/StakingAssetHandler.s.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ contract StakingAssetHandlerScript is Test {
3030
bytes32 public constant DEPOSIT_MERKLE_ROOT = bytes32(0);
3131

3232
ZKPassportVerifier internal constant zkPassportVerifier =
33-
ZKPassportVerifier(0x62e33cC35e29130e135341586e8Cf9C2BAbFB3eE);
33+
ZKPassportVerifier(0xBec82dec0747C9170D760D5aba9cc44929B17C05);
3434

35-
TestERC20 public constant stakingAsset = TestERC20(0x0C04089ED32638ae3cDf649F54F90544aC3Fc199);
36-
IRegistry public constant registry = IRegistry(0xEc4156431d0F3DF66d4E24ba3D30dCb4c85FA309);
35+
TestERC20 public constant stakingAsset = TestERC20(0xad6618B0f91d3fe156eF4CbEb08844C32954f089);
36+
IRegistry public constant registry = IRegistry(0x2e48aDdcA360dA61e4d6C21ff2B1961Af56eB83b);
3737

3838
function setUp() public {}
3939

l1-contracts/src/mock/StakingAssetHandler.sol

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {IMintableERC20} from "@aztec/shared/interfaces/IMintableERC20.sol";
77
import {G1Point, G2Point} from "@aztec/shared/libraries/BN254Lib.sol";
88
import {Ownable} from "@oz/access/Ownable.sol";
99
import {MerkleProof} from "@oz/utils/cryptography/MerkleProof.sol";
10-
import {ZKPassportVerifier, ProofVerificationParams} from "@zkpassport/ZKPassportVerifier.sol";
10+
import {ZKPassportVerifier, ProofVerificationParams, ProofType} from "@zkpassport/ZKPassportVerifier.sol";
1111

1212
/**
1313
* @title StakingAssetHandler
@@ -50,8 +50,13 @@ interface IStakingAssetHandler {
5050
error InvalidProof();
5151
error InvalidScope();
5252
error InvalidDomain();
53-
error ProofNotBoundToAddress(address _expected, address _received);
54-
error ProofNotBoundToChainId(uint256 _expected, uint256 _received);
53+
error InvalidBoundAddress(address _expected, address _received);
54+
error InvalidChainId(uint256 _expected, uint256 _received);
55+
error InvalidAge();
56+
error InvalidCountry();
57+
error InvalidCurrentDate();
58+
error InvalidValidityPeriod();
59+
error ExtraDiscloseDataNonZero();
5560
error SybilDetected(bytes32 _nullifier);
5661
error AttesterDoesNotExist(address _attester);
5762
error NoNullifier();
@@ -126,8 +131,18 @@ contract StakingAssetHandler is IStakingAssetHandler, Ownable {
126131

127132
address public withdrawer;
128133

134+
// ZKPassport constraints
129135
string public validDomain;
130136
string public validScope;
137+
uint256 public validValidityPeriodInSeconds = 7 days;
138+
uint256 public validMinAge = 18;
139+
uint256 public validMaxAge = 0;
140+
141+
// ZKPassport - Excluded counties
142+
bytes32 internal pkr = keccak256(bytes("PRK"));
143+
bytes32 internal ukr = keccak256(bytes("UKR"));
144+
bytes32 internal irn = keccak256(bytes("IRN"));
145+
bytes32 internal cub = keccak256(bytes("CUB"));
131146

132147
constructor(StakingAssetHandlerArgs memory _args) Ownable(_args.owner) {
133148
require(_args.depositsPerMint > 0, CannotMintZeroAmount());
@@ -303,13 +318,34 @@ contract StakingAssetHandler is IStakingAssetHandler, Ownable {
303318

304319
if (!skipBindCheck) {
305320
bytes memory data = zkPassportVerifier.getBindProofInputs(_params.committedInputs, _params.committedInputCounts);
306-
// Use the getBoundData function to get the formatted data
307-
// which includes the user's address, chainId and any custom data
308-
(address boundAddress, uint256 chainId,) = zkPassportVerifier.getBoundData(data);
321+
322+
(address boundAddress, uint256 chainId, string memory customData) = zkPassportVerifier.getBoundData(data);
309323
// Make sure the bound user address is the same as the _attester
310-
require(boundAddress == _attester, ProofNotBoundToAddress(boundAddress, _attester));
324+
require(boundAddress == _attester, InvalidBoundAddress(boundAddress, _attester));
311325
// Make sure the chainId is the same as the current chainId
312-
require(chainId == block.chainid, ProofNotBoundToChainId(chainId, block.chainid));
326+
require(chainId == block.chainid, InvalidChainId(chainId, block.chainid));
327+
// Make sure the custom data is empty
328+
require(bytes(customData).length == 0, ExtraDiscloseDataNonZero());
329+
330+
// Validity period check
331+
require(validValidityPeriodInSeconds == _params.validityPeriodInSeconds, InvalidValidityPeriod());
332+
333+
// Age check
334+
(uint256 currentDate, uint8 minAge, uint8 maxAge) =
335+
zkPassportVerifier.getAgeProofInputs(_params.committedInputs, _params.committedInputCounts);
336+
require(block.timestamp >= currentDate, InvalidCurrentDate());
337+
require(validMinAge == minAge && validMaxAge == maxAge, InvalidAge());
338+
339+
// Country exclusion check
340+
string[] memory exclusionCountryList = zkPassportVerifier.getCountryProofInputs(
341+
_params.committedInputs, _params.committedInputCounts, ProofType.NATIONALITY_EXCLUSION
342+
);
343+
require(keccak256(bytes(exclusionCountryList[0])) == cub, InvalidCountry());
344+
require(keccak256(bytes(exclusionCountryList[1])) == irn, InvalidCountry());
345+
require(keccak256(bytes(exclusionCountryList[2])) == pkr, InvalidCountry());
346+
require(keccak256(bytes(exclusionCountryList[3])) == ukr, InvalidCountry());
347+
348+
zkPassportVerifier.enforceSanctionsRoot(_params.committedInputs, _params.committedInputCounts);
313349
}
314350

315351
// Set nullifier to consumed

l1-contracts/test/staking_asset_handler/bind.t.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ contract BindTest is StakingAssetHandlerBase {
3535

3636
vm.assume(_attester != BOUND_ADDRESS && _attester != address(this));
3737

38-
vm.expectRevert(
39-
abi.encodeWithSelector(IStakingAssetHandler.ProofNotBoundToAddress.selector, BOUND_ADDRESS, _attester)
40-
);
38+
vm.expectRevert(abi.encodeWithSelector(IStakingAssetHandler.InvalidBoundAddress.selector, BOUND_ADDRESS, _attester));
4139
vm.prank(_attester);
4240
stakingAssetHandler.addValidator(
4341
_attester, validMerkleProof, realProof, BN254Lib.g1Zero(), BN254Lib.g2Zero(), BN254Lib.g1Zero()

l1-contracts/test/staking_asset_handler/zkpassport/ZKPassportBase.sol

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,34 @@ pragma solidity >=0.8.27;
44

55
import {ZKPassportVerifier, ProofVerificationParams} from "@zkpassport/ZKPassportVerifier.sol";
66
import {IRootRegistry} from "@zkpassport/IRootRegistry.sol";
7-
import {HonkVerifier as OuterVerifier5} from "@zkpassport/OuterCount5.sol";
7+
import {HonkVerifier as OuterVerifier7} from "@zkpassport/OuterCount7.sol";
88
import {MockRootRegistry} from "./MockRootRegistry.sol";
99
import {MockZKPassportVerifier} from "@aztec/mock/staking_asset_handler/MockZKPassportVerifier.sol";
10+
import {CommittedInputLen} from "@zkpassport/Constants.sol";
1011

1112
import {Test} from "forge-std/Test.sol";
1213

1314
contract ZKPassportBase is Test {
1415
ZKPassportVerifier public zkPassportVerifier;
1516
MockZKPassportVerifier public mockZKPassportVerifier;
1617

17-
OuterVerifier5 public verifier;
18+
OuterVerifier7 public verifier;
1819
IRootRegistry public rootRegistry;
1920

2021
ProofVerificationParams internal fakeProof;
2122
ProofVerificationParams internal realProof;
2223

2324
// Path to the proof file - using files directly in project root
2425
// Fixtures copied from within the zk passport subrepo
25-
bytes32 constant VKEY_HASH = bytes32(uint256(0x2ab349ef31f5d516da820a3f55f93c53f9c899b0b991c93fc341199cc1e3b36c));
26-
bytes32 constant CERTIFICATE_REGISTRY_ROOT =
27-
bytes32(uint256(0x130b5775fe59204b0490bdfcdd02bd7cc2bbf5fe3f3fee34cee13c3a3f9b7bbb));
26+
bytes32 constant VKEY_HASH = 0x2992c925ad8932475d5784bf202b58f1c9d043d6ec04e236a7c761593caea5ce;
2827

2928
// From fixtures - see lib/circuits/src/solidity/test/SampleContract.t.sol
3029
string constant CORRECT_DOMAIN = "zkpassport.id";
3130
string constant CORRECT_SCOPE = "bigproof";
3231

32+
// Time when the proof was generated - Tue Sep 09 2025 13:20:59 UTC
33+
uint256 public PROOF_GENERATION_TIMESTAMP = 1_757_424_059;
34+
3335
// Using this base contract will make a zkpassport verifier and proof available for testing purposes
3436
constructor() {
3537
// Root registry for the zk passport verifier
@@ -38,7 +40,7 @@ contract ZKPassportBase is Test {
3840
// Deploy wrapper verifier
3941
zkPassportVerifier = new ZKPassportVerifier(address(rootRegistry));
4042
// Deploy actual circuit verifier
41-
verifier = new OuterVerifier5();
43+
verifier = new OuterVerifier7();
4244

4345
// Add to the zk passport verifier
4446
bytes32[] memory vkeyHashes = new bytes32[](1);
@@ -48,11 +50,9 @@ contract ZKPassportBase is Test {
4850
verifiers[0] = address(verifier);
4951

5052
zkPassportVerifier.addVerifiers(vkeyHashes, verifiers);
51-
zkPassportVerifier.addCertificateRegistryRoot(CERTIFICATE_REGISTRY_ROOT);
5253

53-
// ( When the proof was made )
54-
// Set the timestamp to 2025-07-16 20:26:48 UTC
55-
vm.warp(1_752_697_608);
54+
// Set the timestamp to PROOF_GENERATION_TIMESTAMP
55+
vm.warp(PROOF_GENERATION_TIMESTAMP);
5656
realProof = makeValidProof();
5757
fakeProof = makeFakeProof();
5858

@@ -66,17 +66,19 @@ contract ZKPassportBase is Test {
6666
bytes memory committedInputs = loadBytesFromFile("valid_committed_inputs.hex");
6767

6868
// Order of bytes of committed inputs for each disclosure proof
69-
uint256[] memory committedInputCounts = new uint256[](2);
70-
committedInputCounts[0] = 181;
71-
committedInputCounts[1] = 501;
69+
uint256[] memory committedInputCounts = new uint256[](4);
70+
committedInputCounts[0] = CommittedInputLen.BIND;
71+
committedInputCounts[1] = CommittedInputLen.SANCTIONS;
72+
committedInputCounts[2] = CommittedInputLen.EXCL_NATIONALITY;
73+
committedInputCounts[3] = CommittedInputLen.COMPARE_AGE;
7274

7375
params = ProofVerificationParams({
7476
vkeyHash: VKEY_HASH,
7577
proof: proof,
7678
publicInputs: publicInputs,
7779
committedInputs: committedInputs,
7880
committedInputCounts: committedInputCounts,
79-
validityPeriodInDays: 7,
81+
validityPeriodInSeconds: 7 days,
8082
domain: "zkpassport.id",
8183
scope: "bigproof",
8284
devMode: false
@@ -105,7 +107,7 @@ contract ZKPassportBase is Test {
105107
publicInputs: publicInputs,
106108
committedInputs: committedInputs,
107109
committedInputCounts: committedInputCounts,
108-
validityPeriodInDays: 7,
110+
validityPeriodInSeconds: 7 days,
109111
domain: "zkpassport.id",
110112
scope: "bigproof",
111113
devMode: true
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
00010100000001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010100010101010101010101000100000000000000000000000000000000000000000000000000503c00000053494c56455248414e443c3c4a4f484e4e593c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c3c50413132333435363700415553383831313132004d000000000000000000000000000000000000000000000000000801001404fb06e8bf44ec60b6a99d2f98551172b2f2ded80200027a6903002a656d61696c3a7465737440746573742e636f6d2c637573746f6d65725f69643a3132333435363738393000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
1+
0801001404fb06e8bf44ec60b6a99d2f98551172b2f2ded80200027a690000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009099699583ea7729a4a05821667645e927b74feb4e6e5382c6e4370e35ed2b23c0543554249524e50524b554b52000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000068c027891200

l1-contracts/test/staking_asset_handler/zkpassport/fixtures/valid_proof.hex

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
{
22
"inputs": [
3-
"0x07eb76cc780e3a054342917c91fd2717cefef6e8994286c6414e2cfe0b470f6a",
4-
"0x27c36e90dafc5d889cf2e92c2f46009b4c61203f316da84d5fe173845b9dc72a",
5-
"0x0000000000000000000000000000000000000000000000000000000000000032",
6-
"0x0000000000000000000000000000000000000000000000000000000000000030",
7-
"0x0000000000000000000000000000000000000000000000000000000000000032",
8-
"0x0000000000000000000000000000000000000000000000000000000000000035",
9-
"0x0000000000000000000000000000000000000000000000000000000000000030",
10-
"0x0000000000000000000000000000000000000000000000000000000000000037",
11-
"0x0000000000000000000000000000000000000000000000000000000000000031",
12-
"0x0000000000000000000000000000000000000000000000000000000000000036",
3+
"0x034608472e44e3d796a30320dea6693df95c42294c3a119fda9f3c2d39053ae9",
4+
"0x0e74ef920d724a7a23120f66991b1cbed34c207b593df6e421113b7c287283ac",
5+
"0x0000000000000000000000000000000000000000000000000000000068c027a3",
136
"0x008d535e2a7f4ee38a4d12aa88bcf21d2c2f6fa051d12eafba6655bf37e8c11c",
147
"0x00f54fbb0f658e7013ec2114ef095a29bb3e2f95b96dbd93e46f12f67863111a",
15-
"0x00727b8cb376e4e4ac36880437f277de0c33748a1f505725160a94be705917d0",
16-
"0x00ac375d5fafd70528bdebe251b9be49a9ac1428c5cb794e8b01e740df5760d1",
8+
"0x00ed45ee6335b3285f58a3c472e398fc6754d1eaa9d7043a60b2daa0a67332e7",
9+
"0x000105354ff92c66a5d42a8d34033ace18d259e4dc04b35a584dc370c00586ba",
10+
"0x0037e4a54fb3f1500058797f475d37f2f8cd9b87f20762c21497a2ab2f655f64",
11+
"0x004e3c2357bff38ea9c5d68fc06b8279435cdba99ee27fa272f0fe6091ca08f4",
1712
"0x0a70167613fa7c456b46f57e91d4fc40c1a7895f55bb7d36ef0ac17ff05045e6"
1813
]
19-
}
14+
}

spartan/terraform/deploy-aztec-infra/values/prover-resources-prod.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ node:
33
node:
44
resources:
55
requests:
6-
cpu: "3"
7-
memory: "12Gi"
6+
cpu: "1.6"
7+
memory: "5Gi"
88

99
nodeSelector:
1010
local-ssd: "false"
1111
node-type: "network"
12+
cores: "2"
1213

1314
affinity:
1415
podAntiAffinity:
@@ -40,6 +41,7 @@ broker:
4041
nodeSelector:
4142
local-ssd: "false"
4243
node-type: "network"
44+
cores: "2"
4345

4446
persistence:
4547
enabled: true

spartan/terraform/deploy-aztec-infra/values/rpc-resources-prod.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
nodeSelector:
22
local-ssd: "false"
33
node-type: "network"
4+
cores: "2"
45

56
affinity:
67
podAntiAffinity:
@@ -20,8 +21,8 @@ hostNetwork: true
2021
node:
2122
resources:
2223
requests:
23-
cpu: "3"
24-
memory: "12Gi"
24+
cpu: "1.6"
25+
memory: "5Gi"
2526
persistence:
2627
enabled: true
2728

0 commit comments

Comments
 (0)