@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.
@@ -27,69 +27,72 @@ contract Groth16Verifier {
27
27
  uint256 constant q = 21888242871839275222246405745257275088696311157297823662689037894645226208583;
28
28
 
29
29
  // Verification Key data
30
- uint256 constant alphax = 14520529041790456786995074540012157593114958168944110579383159897030270421683;
31
- uint256 constant alphay = 12190044747698844131408403166438846980657017889827211487113361059707207182672;
32
- uint256 constant betax1 = 3099300253378967695622319524995410925435112289546553940785697138041984453350;
33
- uint256 constant betax2 = 8591562137143704349741918814436587940548574783735952328854272429056062986345;
34
- uint256 constant betay1 = 19732336449763641045562402464710747257728246716611257381901316297113485311837;
35
- uint256 constant betay2 = 17725255565992761070677663510410141440524977079751397615130866129662422673787;
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 = 11208820528355933937509114257038767265250708247101889906384837742638040921911;
41
- uint256 constant deltax2 = 2351724291376613172494929879166749577904947733878282329485300734950500675429;
42
- uint256 constant deltay1 = 10071807493466688233648885001460033354886249407194332712779982294125684050067;
43
- uint256 constant deltay2 = 10186720019104201576680755920258602838799608381365293611527506022359293309127;
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 = 12101374489738417303840181572580069764732363057515680683745090219107645090682;
47
- uint256 constant IC0y = 6622868140565385066376227039427993681099925034474371659030596024890146904163;
46
+ uint256 constant IC0x = 19703754809632249201814027769049360897773771752440156313927961195680977255238;
47
+ uint256 constant IC0y = 1863925490430054976148272770686055683655162519876480200776277689914207928337;
48
48
 
49
- uint256 constant IC1x = 3669173732190367513652034287079810078449694464897815690603816498785194709298;
50
- uint256 constant IC1y = 12787552409465063176671040388968071843096720382928171325958634655937745904306;
49
+ uint256 constant IC1x = 6842328490232091184800254442267828217282426694586120268639604059623298759838;
50
+ uint256 constant IC1y = 967714464342934108376368520755357809485356696728159664181729268436457657190;
51
51
 
52
- uint256 constant IC2x = 10170489719246253671314687317213013791640770166137501428884495801025758736797;
53
- uint256 constant IC2y = 6252395882627424781706364969531995749933564822768034059098225707092062892276;
52
+ uint256 constant IC2x = 20168307450615104806507934761145093110988772994737581512365163335324124341082;
53
+ uint256 constant IC2y = 10175921511662100555565831453583846748641455819904993446565619840555873483197;
54
54
 
55
- uint256 constant IC3x = 10687481240706766603557091601215731928279126584360618324726499550379950672384;
56
- uint256 constant IC3y = 18232245990332373208670193454828315865982081800651657649905394892430114319137;
55
+ uint256 constant IC3x = 13130823847203923185744389743407601594952943279001962854157420583880242661911;
56
+ uint256 constant IC3y = 1717961719253118057145771753432516947365256073230761126917637302458731210680;
57
57
 
58
- uint256 constant IC4x = 21479520805308843176453350540312157689793392686894956217336144931222100248332;
59
- uint256 constant IC4y = 20794240477273416707592605344748314870068446001913164610390302381834843364218;
58
+ uint256 constant IC4x = 11570200420498329636975473116508042564110840984594598431680781479352690086989;
59
+ uint256 constant IC4y = 2681790313628491490316309945974353922008319929950691351513001124290112440736;
60
60
 
61
- uint256 constant IC5x = 1639431340488776769304709738824454095007661834601823301121609655140677204345;
62
- uint256 constant IC5y = 20241100315007980443635026076756163052388871674389145654353231874849036162838;
61
+ uint256 constant IC5x = 17383935142461497800455236241660532858882483738548995787211516208205825872633;
62
+ uint256 constant IC5y = 21812547690832652944021035744811596124906251282698352572728088438967242927530;
63
63
 
64
- uint256 constant IC6x = 121645431274525990360138477525109868662860092956168925828298462395321687784;
65
- uint256 constant IC6y = 794747987098961918220870106626898804586360564216491869032162762989366388476;
64
+ uint256 constant IC6x = 17927548420151504692167355438129654718691791355276257368295386474362061086291;
65
+ uint256 constant IC6y = 20321310284767358151473081167596474276348875693336193985919659549761811512857;
66
66
 
67
- uint256 constant IC7x = 2203372645692227215676899858833836590816324059236287726456820657448783477922;
68
- uint256 constant IC7y = 2207309673745076358166732988325125705730197773311277805000897437308566547524;
67
+ uint256 constant IC7x = 11490640138309946172119907896307159561754460075139288207159881809998896901104;
68
+ uint256 constant IC7y = 21399015425377341114977066020036205236372213642636323424071239423311652240134;
69
69
 
70
- uint256 constant IC8x = 7661536419049628598164594465666263178650205781527068355000772766824470727314;
71
- uint256 constant IC8y = 8811196404119343314769069609010829337590521896699063939687119401222942408654;
70
+ uint256 constant IC8x = 13073587098352777029611799287598219241090404838333415008565749123384053614197;
71
+ uint256 constant IC8y = 6780096976642213192330292067106932985430455462072442264071195827463047236936;
72
72
 
73
- uint256 constant IC9x = 21343499519323604545088998121814591820494318698260047386701341623495150952819;
74
- uint256 constant IC9y = 6690944176613940177567986909847360918607057563241644423161570806785072607212;
73
+ uint256 constant IC9x = 10304063069706060097949924002149390132151400007771167907675220468774489442419;
74
+ uint256 constant IC9y = 3848734989942396280575580725247574077840617816983408962229650854147376789056;
75
75
 
76
- uint256 constant IC10x = 15264014509141355058781275071990577551887158548257857606419165483731082471950;
77
- uint256 constant IC10y = 15216600797471553468459707999770136646723171284081709084120301846088036216358;
76
+ uint256 constant IC10x = 12670767716151712103223751322086902107378299370689672575360531050799429950688;
77
+ uint256 constant IC10y = 3892214401665217432763449110039673837691522297147787147934049711723284107590;
78
78
 
79
- uint256 constant IC11x = 12733780935417197072452063628052190220002459201228095695184676669312707904830;
80
- uint256 constant IC11y = 16298108809776740697899759704974665278820323554206358196275176082801210672419;
79
+ uint256 constant IC11x = 12052672264941792184464623369009224229428685304257677818833685093473604781859;
80
+ uint256 constant IC11y = 194825330483639781015203119551849820798527497461262547171710476416288887343;
81
81
 
82
- uint256 constant IC12x = 6012479247763961858712330659591617235298186231561389312795940364358559647113;
83
- uint256 constant IC12y = 14721923019704138783748153829207729465935088314626429943383893818959078617779;
82
+ uint256 constant IC12x = 8474513833967152402487822542522099684202492964316709697478913113017585715777;
83
+ uint256 constant IC12y = 11180594191762522476791053549177803613388260607752128766664277934879987230209;
84
84
 
85
- uint256 constant IC13x = 13061379726279750555423847998978370480196471520457553871911806444367687353028;
86
- uint256 constant IC13y = 2975548495951886948231673481109927887365893753862741621324254610502694261941;
85
+ uint256 constant IC13x = 2129674974467473223954430982973092343153467817398447047287805202064270480021;
86
+ uint256 constant IC13y = 21694323122275709283006518607681778669855744651418931639024155273779308722027;
87
87
 
88
- uint256 constant IC14x = 17048825568529186912687446126032713752166726936647722462681262666976911028917;
89
- uint256 constant IC14y = 4770007883853892820003356098186534463380640029144851943088490003586536185193;
88
+ uint256 constant IC14x = 3250568833007067433888350215497425008219853791906085127332832556581794453248;
89
+ uint256 constant IC14y = 6399011481929268902517857078272758443475218531566888876695352617518549414569;
90
90
 
91
- uint256 constant IC15x = 13628101711350889888526860037192365772666344522220684297140938100564664858788;
92
- uint256 constant IC15y = 4355821266360537693062567273491516561731162144993540609483109600550687891933;
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[15] calldata _pubSignals) public view returns (bool) {
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
+ }
@@ -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";
@@ -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.1.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/zk-travel-rule.git",
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",