@zkpassport/aztec 0.1.0-beta.0 → 0.1.0-beta.2
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 +11 -2
- package/dist/index.d.ts +52 -18
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,10 +16,19 @@ npm install @zkpassport/aztec @aztec-labs/aztec.js@6.0 @aztec-labs/stdlib@6.0
|
|
|
16
16
|
## Features
|
|
17
17
|
|
|
18
18
|
- **`ZKPassportRegistryArtifact` + `registerZKPassportRegistry(wallet, node, address)`**: utility to register the shared registry's artifact with the user's PXE (the verifier transitively `.view()`s it during local simulation/proving).
|
|
19
|
-
- **`
|
|
19
|
+
- **`toAztecCapsules(params, contract, sender)`**: a contract that verifies a proof reads it, and the data its query asks for, from capsules. The ZKPassport SDK's `getAztecVerifierParameters({ proof })` returns them as plain data for an `outer_count_N` proof, and this turns them into the aztec.js `Capsule`s to send with the call:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
// `network` is needed for a proof bound to no Aztec network
|
|
23
|
+
const params = await zkPassport.getAztecVerifierParameters({ proof, network: "aztec" })
|
|
24
|
+
const capsules = toAztecCapsules(params, gate.address, sender)
|
|
25
|
+
await gate.methods.claim(user).send({ from: sender, capsules })
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- **`assembleProofCapsule` / `assembleDiscloseCapsule` / `assembleSanctionsCapsule`**: the same capsules' fields from the parts of a proof, for a client that builds them itself. The proof capsule ends with the circuits release that made the proof; only 0.23.x proofs verify.
|
|
20
29
|
- **`nationalityBytes` / `packNationality` / `isIdCard`** — TS twins of the Noir `disclosed_data` module's nationality reader. `@zkpassport/utils`' `DisclosedData.fromDisclosedBytes(bytes, isIdCard(bytes) ? "id_card" : "passport")` reads every field.
|
|
21
30
|
- **`fetchOuterVk(vkeyHash)`**: the outer vk from the live `circuits2.zkpassport.id` host.
|
|
22
|
-
- **`constants.ts
|
|
31
|
+
- **`constants.ts`**: the field counts and capsule slots, from `@zkpassport/utils`' mirror of `core/src/constants.nr`.
|
|
23
32
|
|
|
24
33
|
## Development
|
|
25
34
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ContractArtifact } from '@aztec-labs/aztec.js/abi';
|
|
2
|
-
import { Fr } from '@aztec-labs/aztec.js/fields';
|
|
3
2
|
import { AztecAddress } from '@aztec-labs/aztec.js/addresses';
|
|
3
|
+
import { Fr } from '@aztec-labs/aztec.js/fields';
|
|
4
|
+
import { Capsule } from '@aztec-labs/aztec.js/tx';
|
|
5
|
+
import { AztecVerifierParameters, getAztecOuterPublicInputCount } from '@zkpassport/utils';
|
|
4
6
|
import { ContractInstanceWithAddress } from '@aztec-labs/stdlib/contract';
|
|
5
7
|
|
|
6
8
|
/**
|
|
@@ -9,24 +11,35 @@ import { ContractInstanceWithAddress } from '@aztec-labs/stdlib/contract';
|
|
|
9
11
|
|
|
10
12
|
declare const ZKPassportRegistryArtifact: ContractArtifact;
|
|
11
13
|
|
|
12
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* The three field groups of an outer proof, as hex strings from the SDK/utils, and the circuits
|
|
16
|
+
* release that made it (the SDK's `ProofResult.version`, e.g. "0.23.0").
|
|
17
|
+
*/
|
|
13
18
|
interface OuterProofParts {
|
|
14
19
|
vk: string[];
|
|
15
20
|
proof: string[];
|
|
16
21
|
publicInputs: string[];
|
|
22
|
+
version: string;
|
|
17
23
|
}
|
|
18
24
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
25
|
+
* The capsules of the SDK's `getAztecVerifierParameters` for `contract`, scoped to `sender`, the
|
|
26
|
+
* account whose PXE sends the transaction: pass them as the `capsules` of the call that verifies
|
|
27
|
+
* the proof.
|
|
28
|
+
*/
|
|
29
|
+
declare function toAztecCapsules(params: AztecVerifierParameters, contract: AztecAddress, sender: AztecAddress): Capsule[];
|
|
30
|
+
/**
|
|
31
|
+
* Assemble the proof-capsule blob the library's `verify_zkpassport_proof` consumes:
|
|
32
|
+
* `vk(115) ‖ proof(458) ‖ public_inputs(K + 6) ‖ circuit_version`, which can then be delivered on
|
|
33
|
+
* `PROOF_CAPSULE_SLOT` of the verifier contract. The version is packed as the registry keys vks
|
|
34
|
+
* by it, and the registry only accepts the proof's vk under the release that built it.
|
|
22
35
|
*
|
|
23
36
|
* Shape-checks first: the on-chain load of a wrong-shaped blob just returns
|
|
24
37
|
* None ("missing zkpassport proof capsule"). `k` is the outer circuit's subproof count
|
|
25
|
-
* (`outer_count_5` → 5, the shape current SDK queries produce).
|
|
38
|
+
* (`outer_count_5` → 5, the shape current SDK queries produce). A release other than 0.23.x is
|
|
39
|
+
* rejected, since the library would reject its proof.
|
|
26
40
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* string as decimal — so every element is parsed explicitly as hex.
|
|
41
|
+
* The SDK/utils emit field elements as bare hex (no `0x`), which are read as hex, never as
|
|
42
|
+
* decimal.
|
|
30
43
|
*/
|
|
31
44
|
declare function assembleProofCapsule(parts: OuterProofParts, k?: number): Fr[];
|
|
32
45
|
/**
|
|
@@ -42,23 +55,33 @@ declare function assembleDiscloseCapsule(discloseMask: number[], disclosedBytes:
|
|
|
42
55
|
declare function assembleSanctionsCapsule(rootHash: string): Fr[];
|
|
43
56
|
|
|
44
57
|
/**
|
|
45
|
-
* Note:
|
|
58
|
+
* Note: these come from `@zkpassport/utils`, a TS mirror of `noir/core/src/constants.nr`. That is
|
|
59
|
+
* the source of truth.
|
|
46
60
|
*/
|
|
61
|
+
|
|
47
62
|
/** Fields in the outer circuit's UltraHonk verification key. */
|
|
48
63
|
declare const VK_FIELDS = 115;
|
|
49
64
|
/** Fields in the outer ZK UltraHonk proof. */
|
|
50
65
|
declare const PROOF_FIELDS = 458;
|
|
51
66
|
/** Capsule slot the library loads the proof blob from (per-verifier address space). */
|
|
52
|
-
declare const PROOF_CAPSULE_SLOT
|
|
67
|
+
declare const PROOF_CAPSULE_SLOT: bigint;
|
|
53
68
|
/** Capsule slot for the disclose preimage (mask ‖ disclosed bytes). */
|
|
54
|
-
declare const DISCLOSE_CAPSULE_SLOT
|
|
69
|
+
declare const DISCLOSE_CAPSULE_SLOT: bigint;
|
|
55
70
|
/** Capsule slot for the sanctions exclusion payload. */
|
|
56
|
-
declare const SANCTIONS_CAPSULE_SLOT
|
|
71
|
+
declare const SANCTIONS_CAPSULE_SLOT: bigint;
|
|
57
72
|
/** The canonical 90-byte disclose payload length (TD1 exactly; TD3 zero-padded). */
|
|
58
73
|
declare const MRZ_LENGTH = 90;
|
|
59
|
-
/**
|
|
60
|
-
declare const
|
|
61
|
-
/**
|
|
74
|
+
/** The circuits releases the library parses: 0.23.x. */
|
|
75
|
+
declare const SUPPORTED_CIRCUIT_VERSION: RegExp;
|
|
76
|
+
/**
|
|
77
|
+
* Public-input count for a circuits 0.23.x `outer_count_K` proof is K + 6, ending in the
|
|
78
|
+
* verification method; param commitments are K - 3.
|
|
79
|
+
*/
|
|
80
|
+
declare const outerPublicInputCount: typeof getAztecOuterPublicInputCount;
|
|
81
|
+
/**
|
|
82
|
+
* Total field count of the proof-capsule blob for `outer_count_K`:
|
|
83
|
+
* vk ‖ proof ‖ public inputs ‖ circuit version.
|
|
84
|
+
*/
|
|
62
85
|
declare const outerCapsuleLength: (k: number) => number;
|
|
63
86
|
|
|
64
87
|
/**
|
|
@@ -90,9 +113,15 @@ declare function packNationality(disclosedBytes: number[]): bigint;
|
|
|
90
113
|
interface RegistryNode {
|
|
91
114
|
getContract(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
92
115
|
}
|
|
116
|
+
/** The slice of an aztec.js `Wallet` that registration uses. */
|
|
93
117
|
interface RegistryWallet {
|
|
94
118
|
registerContract(instance: ContractInstanceWithAddress, artifact: ContractArtifact): Promise<unknown>;
|
|
95
|
-
|
|
119
|
+
getContractMetadata(address: AztecAddress): Promise<{
|
|
120
|
+
instance?: unknown;
|
|
121
|
+
}>;
|
|
122
|
+
getContractClassMetadata(id: Fr): Promise<{
|
|
123
|
+
isArtifactRegistered: boolean;
|
|
124
|
+
}>;
|
|
96
125
|
}
|
|
97
126
|
/**
|
|
98
127
|
* Register the shared ZKPassportRegistry's artifact with the wallet's PXE.
|
|
@@ -100,6 +129,11 @@ interface RegistryWallet {
|
|
|
100
129
|
* Any app whose verifier calls `verify_zkpassport_proof*` needs this once per
|
|
101
130
|
* wallet: the verifier privately `.view()`s the registry, and the PXE executes
|
|
102
131
|
* that call locally during simulation/proving.
|
|
132
|
+
*
|
|
133
|
+
* Registration is skipped only when the wallet reports both the registry's
|
|
134
|
+
* instance and the artifact of its current class. After the registry is
|
|
135
|
+
* upgraded, a wallet that still holds the old class's artifact is registered
|
|
136
|
+
* again with the current one.
|
|
103
137
|
*/
|
|
104
138
|
declare function registerZKPassportRegistry(wallet: RegistryWallet, node: RegistryNode, registryAddress: AztecAddress | string, artifact?: ContractArtifact): Promise<ContractInstanceWithAddress>;
|
|
105
139
|
|
|
@@ -118,4 +152,4 @@ declare function registerZKPassportRegistry(wallet: RegistryWallet, node: Regist
|
|
|
118
152
|
*/
|
|
119
153
|
declare function fetchOuterVk(vkeyHash: string): Promise<string[]>;
|
|
120
154
|
|
|
121
|
-
export { DISCLOSE_CAPSULE_SLOT, MRZ_LENGTH, type OuterProofParts, PROOF_CAPSULE_SLOT, PROOF_FIELDS, type RegistryNode, type RegistryWallet, SANCTIONS_CAPSULE_SLOT, TD1_NATIONALITY_INDEX, TD3_NATIONALITY_INDEX, VK_FIELDS, ZKPassportRegistryArtifact, assembleDiscloseCapsule, assembleProofCapsule, assembleSanctionsCapsule, fetchOuterVk, isIdCard, nationalityBytes, outerCapsuleLength, outerPublicInputCount, packNationality, registerZKPassportRegistry };
|
|
155
|
+
export { DISCLOSE_CAPSULE_SLOT, MRZ_LENGTH, type OuterProofParts, PROOF_CAPSULE_SLOT, PROOF_FIELDS, type RegistryNode, type RegistryWallet, SANCTIONS_CAPSULE_SLOT, SUPPORTED_CIRCUIT_VERSION, TD1_NATIONALITY_INDEX, TD3_NATIONALITY_INDEX, VK_FIELDS, ZKPassportRegistryArtifact, assembleDiscloseCapsule, assembleProofCapsule, assembleSanctionsCapsule, fetchOuterVk, isIdCard, nationalityBytes, outerCapsuleLength, outerPublicInputCount, packNationality, registerZKPassportRegistry, toAztecCapsules };
|