@clearproof/contracts 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/artifacts/contracts/ComplianceRegistry.sol/ComplianceRegistry.json +4 -4
- package/artifacts/contracts/ComplianceRegistry.sol/IGroth16Verifier.json +2 -2
- package/artifacts/contracts/Groth16Verifier.sol/Groth16Verifier.json +4 -4
- package/artifacts/contracts/ISanctionsRootReceiver.sol/ISanctionsRootReceiver.json +29 -0
- package/artifacts/contracts/SanctionsOracle.sol/SanctionsOracle.json +2 -2
- package/artifacts/contracts/SanctionsRootRelay.sol/SanctionsRootRelay.json +321 -0
- package/artifacts/contracts/VASPRegistry.sol/VASPRegistry.json +87 -2
- package/contracts/ComplianceRegistry.sol +22 -7
- package/contracts/Groth16Verifier.sol +50 -43
- package/contracts/ISanctionsRootReceiver.sol +14 -0
- package/contracts/SanctionsOracle.sol +2 -0
- package/contracts/SanctionsRootRelay.sol +48 -0
- package/contracts/VASPRegistry.sol +27 -4
- package/package.json +7 -3
|
@@ -27,69 +27,72 @@ contract Groth16Verifier {
|
|
|
27
27
|
uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
|
|
28
28
|
|
|
29
29
|
// Verification Key data
|
|
30
|
-
uint256 constant alphax =
|
|
31
|
-
uint256 constant alphay =
|
|
32
|
-
uint256 constant betax1 =
|
|
33
|
-
uint256 constant betax2 =
|
|
34
|
-
uint256 constant betay1 =
|
|
35
|
-
uint256 constant betay2 =
|
|
30
|
+
uint256 constant alphax = 18684454301819562296747362103013247904909563675066733611848264601238709664346;
|
|
31
|
+
uint256 constant alphay = 13382596269673849011460709490273826982834575881932794785488992240206958268988;
|
|
32
|
+
uint256 constant betax1 = 9369927713959446369253112845140960817273069559889791172429790728904899918096;
|
|
33
|
+
uint256 constant betax2 = 7018936339641547380564548801205962972325910679402088163891495006948592464872;
|
|
34
|
+
uint256 constant betay1 = 18192680457896402009106056585736590829886416492642881064592060259639186262006;
|
|
35
|
+
uint256 constant betay2 = 18772142389951268793765998116630185741982332811051964345375452390107064860773;
|
|
36
36
|
uint256 constant gammax1 = 11559732032986387107991004021392285783925812861821192530917403151452391805634;
|
|
37
37
|
uint256 constant gammax2 = 10857046999023057135944570762232829481370756359578518086990519993285655852781;
|
|
38
38
|
uint256 constant gammay1 = 4082367875863433681332203403145435568316851327593401208105741076214120093531;
|
|
39
39
|
uint256 constant gammay2 = 8495653923123431417604973247489272438418190587263600148770280649306958101930;
|
|
40
|
-
uint256 constant deltax1 =
|
|
41
|
-
uint256 constant deltax2 =
|
|
42
|
-
uint256 constant deltay1 =
|
|
43
|
-
uint256 constant deltay2 =
|
|
40
|
+
uint256 constant deltax1 = 16066285121322798283816661155683648225017439991112020715347694895015493523206;
|
|
41
|
+
uint256 constant deltax2 = 614037217300847490032117582288372304806365997874449473897067122389611050097;
|
|
42
|
+
uint256 constant deltay1 = 999132498792814032884695754087775892189854734043853267260966253796598566326;
|
|
43
|
+
uint256 constant deltay2 = 8766526840950424236933975030317606082570070701224728700739511563570212380686;
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
uint256 constant IC0x =
|
|
47
|
-
uint256 constant IC0y =
|
|
46
|
+
uint256 constant IC0x = 19703754809632249201814027769049360897773771752440156313927961195680977255238;
|
|
47
|
+
uint256 constant IC0y = 1863925490430054976148272770686055683655162519876480200776277689914207928337;
|
|
48
48
|
|
|
49
|
-
uint256 constant IC1x =
|
|
50
|
-
uint256 constant IC1y =
|
|
49
|
+
uint256 constant IC1x = 6842328490232091184800254442267828217282426694586120268639604059623298759838;
|
|
50
|
+
uint256 constant IC1y = 967714464342934108376368520755357809485356696728159664181729268436457657190;
|
|
51
51
|
|
|
52
|
-
uint256 constant IC2x =
|
|
53
|
-
uint256 constant IC2y =
|
|
52
|
+
uint256 constant IC2x = 20168307450615104806507934761145093110988772994737581512365163335324124341082;
|
|
53
|
+
uint256 constant IC2y = 10175921511662100555565831453583846748641455819904993446565619840555873483197;
|
|
54
54
|
|
|
55
|
-
uint256 constant IC3x =
|
|
56
|
-
uint256 constant IC3y =
|
|
55
|
+
uint256 constant IC3x = 13130823847203923185744389743407601594952943279001962854157420583880242661911;
|
|
56
|
+
uint256 constant IC3y = 1717961719253118057145771753432516947365256073230761126917637302458731210680;
|
|
57
57
|
|
|
58
|
-
uint256 constant IC4x =
|
|
59
|
-
uint256 constant IC4y =
|
|
58
|
+
uint256 constant IC4x = 11570200420498329636975473116508042564110840984594598431680781479352690086989;
|
|
59
|
+
uint256 constant IC4y = 2681790313628491490316309945974353922008319929950691351513001124290112440736;
|
|
60
60
|
|
|
61
|
-
uint256 constant IC5x =
|
|
62
|
-
uint256 constant IC5y =
|
|
61
|
+
uint256 constant IC5x = 17383935142461497800455236241660532858882483738548995787211516208205825872633;
|
|
62
|
+
uint256 constant IC5y = 21812547690832652944021035744811596124906251282698352572728088438967242927530;
|
|
63
63
|
|
|
64
|
-
uint256 constant IC6x =
|
|
65
|
-
uint256 constant IC6y =
|
|
64
|
+
uint256 constant IC6x = 17927548420151504692167355438129654718691791355276257368295386474362061086291;
|
|
65
|
+
uint256 constant IC6y = 20321310284767358151473081167596474276348875693336193985919659549761811512857;
|
|
66
66
|
|
|
67
|
-
uint256 constant IC7x =
|
|
68
|
-
uint256 constant IC7y =
|
|
67
|
+
uint256 constant IC7x = 11490640138309946172119907896307159561754460075139288207159881809998896901104;
|
|
68
|
+
uint256 constant IC7y = 21399015425377341114977066020036205236372213642636323424071239423311652240134;
|
|
69
69
|
|
|
70
|
-
uint256 constant IC8x =
|
|
71
|
-
uint256 constant IC8y =
|
|
70
|
+
uint256 constant IC8x = 13073587098352777029611799287598219241090404838333415008565749123384053614197;
|
|
71
|
+
uint256 constant IC8y = 6780096976642213192330292067106932985430455462072442264071195827463047236936;
|
|
72
72
|
|
|
73
|
-
uint256 constant IC9x =
|
|
74
|
-
uint256 constant IC9y =
|
|
73
|
+
uint256 constant IC9x = 10304063069706060097949924002149390132151400007771167907675220468774489442419;
|
|
74
|
+
uint256 constant IC9y = 3848734989942396280575580725247574077840617816983408962229650854147376789056;
|
|
75
75
|
|
|
76
|
-
uint256 constant IC10x =
|
|
77
|
-
uint256 constant IC10y =
|
|
76
|
+
uint256 constant IC10x = 12670767716151712103223751322086902107378299370689672575360531050799429950688;
|
|
77
|
+
uint256 constant IC10y = 3892214401665217432763449110039673837691522297147787147934049711723284107590;
|
|
78
78
|
|
|
79
|
-
uint256 constant IC11x =
|
|
80
|
-
uint256 constant IC11y =
|
|
79
|
+
uint256 constant IC11x = 12052672264941792184464623369009224229428685304257677818833685093473604781859;
|
|
80
|
+
uint256 constant IC11y = 194825330483639781015203119551849820798527497461262547171710476416288887343;
|
|
81
81
|
|
|
82
|
-
uint256 constant IC12x =
|
|
83
|
-
uint256 constant IC12y =
|
|
82
|
+
uint256 constant IC12x = 8474513833967152402487822542522099684202492964316709697478913113017585715777;
|
|
83
|
+
uint256 constant IC12y = 11180594191762522476791053549177803613388260607752128766664277934879987230209;
|
|
84
84
|
|
|
85
|
-
uint256 constant IC13x =
|
|
86
|
-
uint256 constant IC13y =
|
|
85
|
+
uint256 constant IC13x = 2129674974467473223954430982973092343153467817398447047287805202064270480021;
|
|
86
|
+
uint256 constant IC13y = 21694323122275709283006518607681778669855744651418931639024155273779308722027;
|
|
87
87
|
|
|
88
|
-
uint256 constant IC14x =
|
|
89
|
-
uint256 constant IC14y =
|
|
88
|
+
uint256 constant IC14x = 3250568833007067433888350215497425008219853791906085127332832556581794453248;
|
|
89
|
+
uint256 constant IC14y = 6399011481929268902517857078272758443475218531566888876695352617518549414569;
|
|
90
90
|
|
|
91
|
-
uint256 constant IC15x =
|
|
92
|
-
uint256 constant IC15y =
|
|
91
|
+
uint256 constant IC15x = 21361875659190037444465592626338380323701081645088974263958258082733413038127;
|
|
92
|
+
uint256 constant IC15y = 2277204784735610188074535623007303162278324355868808350267617647867247585840;
|
|
93
|
+
|
|
94
|
+
uint256 constant IC16x = 3784932913228748653290327846200321674983791114501050843187248759346176565642;
|
|
95
|
+
uint256 constant IC16y = 16161068570005881855813026196520856335621943638222458671868213423896093305442;
|
|
93
96
|
|
|
94
97
|
|
|
95
98
|
// Memory data
|
|
@@ -98,7 +101,7 @@ contract Groth16Verifier {
|
|
|
98
101
|
|
|
99
102
|
uint16 constant pLastMem = 896;
|
|
100
103
|
|
|
101
|
-
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[
|
|
104
|
+
function verifyProof(uint[2] calldata _pA, uint[2][2] calldata _pB, uint[2] calldata _pC, uint[16] calldata _pubSignals) public view returns (bool) {
|
|
102
105
|
assembly {
|
|
103
106
|
function checkField(v) {
|
|
104
107
|
if iszero(lt(v, r)) {
|
|
@@ -172,6 +175,8 @@ contract Groth16Verifier {
|
|
|
172
175
|
|
|
173
176
|
g1_mulAccC(_pVk, IC15x, IC15y, calldataload(add(pubSignals, 448)))
|
|
174
177
|
|
|
178
|
+
g1_mulAccC(_pVk, IC16x, IC16y, calldataload(add(pubSignals, 480)))
|
|
179
|
+
|
|
175
180
|
|
|
176
181
|
// -A
|
|
177
182
|
mstore(_pPairing, calldataload(pA))
|
|
@@ -255,6 +260,8 @@ contract Groth16Verifier {
|
|
|
255
260
|
|
|
256
261
|
checkField(calldataload(add(_pubSignals, 448)))
|
|
257
262
|
|
|
263
|
+
checkField(calldataload(add(_pubSignals, 480)))
|
|
264
|
+
|
|
258
265
|
|
|
259
266
|
// Validate all evaluations
|
|
260
267
|
let isValid := checkPairing(_pA, _pB, _pC, _pubSignals, pMem)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// clearproof — ZK-proven compliance without transmitting PII
|
|
3
|
+
// https://clearproof.world | https://docs.clearproof.world
|
|
4
|
+
pragma solidity ^0.8.24;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @title ISanctionsRootReceiver
|
|
8
|
+
* @notice Interface for contracts that accept sanctions root updates.
|
|
9
|
+
* Implement this to swap transport layers (direct relayer, CCIP,
|
|
10
|
+
* LayerZero) without redeploying the SanctionsOracle.
|
|
11
|
+
*/
|
|
12
|
+
interface ISanctionsRootReceiver {
|
|
13
|
+
function receiveRoot(bytes32 newRoot, uint32 leafCount) external;
|
|
14
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// clearproof — ZK-proven compliance without transmitting PII
|
|
3
|
+
// https://clearproof.world | https://docs.clearproof.world
|
|
4
|
+
pragma solidity ^0.8.24;
|
|
5
|
+
|
|
6
|
+
import "@openzeppelin/contracts/access/AccessControl.sol";
|
|
7
|
+
import "./SanctionsOracle.sol";
|
|
8
|
+
import "./ISanctionsRootReceiver.sol";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @title SanctionsRootRelay
|
|
12
|
+
* @notice Adapter that receives sanctions root updates from an authorized
|
|
13
|
+
* source (relayer EOA, CCIP receiver, LayerZero endpoint) and
|
|
14
|
+
* forwards them to the SanctionsOracle.
|
|
15
|
+
*
|
|
16
|
+
* This contract holds ORACLE_ROLE on the SanctionsOracle.
|
|
17
|
+
* Transport-layer authorization is managed via RELAYER_ROLE.
|
|
18
|
+
*
|
|
19
|
+
* To upgrade the transport layer:
|
|
20
|
+
* 1. Deploy new relay contract (e.g., SanctionsRootRelayCCIP)
|
|
21
|
+
* 2. Grant ORACLE_ROLE on SanctionsOracle to the new relay
|
|
22
|
+
* 3. Revoke ORACLE_ROLE from the old relay
|
|
23
|
+
* 4. No oracle redeployment needed
|
|
24
|
+
*/
|
|
25
|
+
contract SanctionsRootRelay is ISanctionsRootReceiver, AccessControl {
|
|
26
|
+
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
|
|
27
|
+
|
|
28
|
+
SanctionsOracle public immutable oracle;
|
|
29
|
+
|
|
30
|
+
event RootRelayed(bytes32 indexed root, uint32 leafCount, address indexed relayer);
|
|
31
|
+
|
|
32
|
+
constructor(address admin, address oracleAddress) {
|
|
33
|
+
require(admin != address(0), "Zero admin");
|
|
34
|
+
require(oracleAddress != address(0), "Zero oracle");
|
|
35
|
+
_grantRole(DEFAULT_ADMIN_ROLE, admin);
|
|
36
|
+
_grantRole(RELAYER_ROLE, admin);
|
|
37
|
+
oracle = SanctionsOracle(oracleAddress);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @notice Receive a root update and forward to the oracle.
|
|
42
|
+
* Called by the relayer EOA (phase 1) or bridge receiver (phase 2+).
|
|
43
|
+
*/
|
|
44
|
+
function receiveRoot(bytes32 newRoot, uint32 leafCount) external onlyRole(RELAYER_ROLE) {
|
|
45
|
+
oracle.updateRoot(newRoot, leafCount);
|
|
46
|
+
emit RootRelayed(newRoot, leafCount, msg.sender);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// clearproof — ZK-proven compliance without transmitting PII
|
|
3
|
+
// https://clearproof.world | https://docs.clearproof.world
|
|
2
4
|
pragma solidity ^0.8.24;
|
|
3
5
|
|
|
4
6
|
import "@openzeppelin/contracts/access/AccessControl.sol";
|
|
@@ -10,6 +12,7 @@ contract VASPRegistry is AccessControl, Pausable {
|
|
|
10
12
|
struct VASP {
|
|
11
13
|
address wallet;
|
|
12
14
|
string jurisdiction;
|
|
15
|
+
string discoveryEndpoint; // e.g. "https://vasp.example/.well-known/clearproof"
|
|
13
16
|
bool active;
|
|
14
17
|
uint64 registeredAt;
|
|
15
18
|
}
|
|
@@ -20,9 +23,10 @@ contract VASPRegistry is AccessControl, Pausable {
|
|
|
20
23
|
uint64 public issuerRootVersion;
|
|
21
24
|
uint256 public activeVaspCount; // M-6: Track active VASP count
|
|
22
25
|
|
|
23
|
-
event VASPRegistered(bytes32 indexed didHash, address wallet, string jurisdiction);
|
|
26
|
+
event VASPRegistered(bytes32 indexed didHash, address wallet, string jurisdiction, string discoveryEndpoint);
|
|
24
27
|
event VASPRevoked(bytes32 indexed didHash);
|
|
25
28
|
event VASPReactivated(bytes32 indexed didHash, address newWallet); // H-5
|
|
29
|
+
event DiscoveryEndpointUpdated(bytes32 indexed didHash, string endpoint);
|
|
26
30
|
event IssuerRootUpdated(bytes32 oldRoot, bytes32 newRoot, uint64 version);
|
|
27
31
|
|
|
28
32
|
constructor(address admin) {
|
|
@@ -35,13 +39,27 @@ contract VASPRegistry is AccessControl, Pausable {
|
|
|
35
39
|
function registerVASP(
|
|
36
40
|
bytes32 didHash,
|
|
37
41
|
address wallet,
|
|
38
|
-
string calldata jurisdiction
|
|
42
|
+
string calldata jurisdiction,
|
|
43
|
+
string calldata discoveryEndpoint
|
|
39
44
|
) external onlyRole(REGISTRAR_ROLE) whenNotPaused {
|
|
40
45
|
require(vasps[didHash].registeredAt == 0, "Already registered");
|
|
41
|
-
vasps[didHash] = VASP(wallet, jurisdiction, true, uint64(block.timestamp));
|
|
46
|
+
vasps[didHash] = VASP(wallet, jurisdiction, discoveryEndpoint, true, uint64(block.timestamp));
|
|
42
47
|
vaspIds.push(didHash);
|
|
43
48
|
activeVaspCount++; // M-6
|
|
44
|
-
emit VASPRegistered(didHash, wallet, jurisdiction);
|
|
49
|
+
emit VASPRegistered(didHash, wallet, jurisdiction, discoveryEndpoint);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function updateDiscoveryEndpoint(
|
|
53
|
+
bytes32 didHash,
|
|
54
|
+
string calldata newEndpoint
|
|
55
|
+
) external onlyRole(REGISTRAR_ROLE) whenNotPaused {
|
|
56
|
+
require(vasps[didHash].active, "Not active");
|
|
57
|
+
vasps[didHash].discoveryEndpoint = newEndpoint;
|
|
58
|
+
emit DiscoveryEndpointUpdated(didHash, newEndpoint);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function getDiscoveryEndpoint(bytes32 didHash) external view returns (string memory) {
|
|
62
|
+
return vasps[didHash].discoveryEndpoint;
|
|
45
63
|
}
|
|
46
64
|
|
|
47
65
|
// M-8: Added whenNotPaused — revocation requires explicit unpause for safety
|
|
@@ -77,6 +95,11 @@ contract VASPRegistry is AccessControl, Pausable {
|
|
|
77
95
|
return vaspIds.length;
|
|
78
96
|
}
|
|
79
97
|
|
|
98
|
+
/// @notice Returns the number of currently active (non-revoked) VASPs.
|
|
99
|
+
function getActiveVaspCount() external view returns (uint256) {
|
|
100
|
+
return activeVaspCount;
|
|
101
|
+
}
|
|
102
|
+
|
|
80
103
|
function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {
|
|
81
104
|
_pause();
|
|
82
105
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearproof/contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "On-chain Groth16 verifier for clearproof compliance proofs",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"files": [
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
],
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/clearproof
|
|
13
|
+
"url": "https://github.com/repfigit/clearproof.git",
|
|
14
14
|
"directory": "packages/contracts"
|
|
15
15
|
},
|
|
16
|
+
"homepage": "https://github.com/repfigit/clearproof",
|
|
16
17
|
"keywords": [
|
|
17
18
|
"zk",
|
|
18
19
|
"zero-knowledge",
|
|
@@ -26,7 +27,10 @@
|
|
|
26
27
|
"scripts": {
|
|
27
28
|
"compile": "hardhat compile",
|
|
28
29
|
"test": "hardhat test",
|
|
29
|
-
"deploy": "hardhat run scripts/deploy.ts"
|
|
30
|
+
"deploy": "hardhat run scripts/deploy.ts",
|
|
31
|
+
"deploy:multi": "hardhat run scripts/deploy-multichain.ts",
|
|
32
|
+
"update-sanctions": "hardhat run scripts/update-sanctions-root.ts",
|
|
33
|
+
"relay-sanctions": "ts-node scripts/relay-sanctions-root.ts"
|
|
30
34
|
},
|
|
31
35
|
"devDependencies": {
|
|
32
36
|
"@nomicfoundation/hardhat-toolbox": "^5.0",
|