@crisp-e3/sdk 0.17.0 → 0.18.0-insecure.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 +38 -4
- package/dist/.tsbuildinfo +1 -1
- package/dist/circuits-BWegRaZy.d.ts +49 -0
- package/dist/index.d.ts +82 -10
- package/dist/index.js +70 -53
- package/dist/index.js.map +1 -1
- package/dist/presets/insecure-512.d.ts +14 -0
- package/dist/presets/insecure-512.js +26 -0
- package/dist/workers/generateCircuitInputs.worker.js +19 -27
- package/dist/workers/generateCircuitInputs.worker.js.map +1 -1
- package/package.json +21 -5
package/README.md
CHANGED
|
@@ -16,6 +16,36 @@ npm install @crisp-e3/sdk
|
|
|
16
16
|
- **Merkle Tree Utilities**: Generate proofs for voter inclusion in the eligibility tree
|
|
17
17
|
- **Vote Proof Generation**: Create zero-knowledge proofs for votes and mask votes
|
|
18
18
|
- **Proof Verification**: Verify generated proofs using Noir circuits
|
|
19
|
+
- **Selectable Parameters**: `insecure-512` and `secure-8192` circuits ship as separate entry points
|
|
20
|
+
|
|
21
|
+
## Choosing a preset
|
|
22
|
+
|
|
23
|
+
Proving needs the BFV-shaped circuits, and those exist once per parameter set. They are not part of
|
|
24
|
+
the main entry point: the `secure-8192` set is far larger than `insecure-512`, and no consumer needs
|
|
25
|
+
both. Each ships as its own subpath, so your bundler pulls only the one you import.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { setCircuits } from '@crisp-e3/sdk'
|
|
29
|
+
import { loadCircuits } from '@crisp-e3/sdk/insecure-512' // or '@crisp-e3/sdk/secure-8192'
|
|
30
|
+
|
|
31
|
+
setCircuits(await loadCircuits())
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Register once at start-up, before the first `prepareBallot`/`generateProof`. There is deliberately
|
|
35
|
+
no default: a ballot proved against the wrong parameters is rejected on chain rather than locally,
|
|
36
|
+
so `generateProof` throws a directed error instead of guessing.
|
|
37
|
+
|
|
38
|
+
In a browser, load it through a dynamic `import()` so the circuits become their own chunk and the
|
|
39
|
+
app boots without them:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const { loadCircuits } = await import('@crisp-e3/sdk/insecure-512')
|
|
43
|
+
setCircuits(await loadCircuits())
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`verifyProof`, `encodeVote`, `decodeTally` and the round/token helpers need no preset. The
|
|
47
|
+
aggregation circuits they use are proof-shaped rather than polynomial-shaped, so a single artifact
|
|
48
|
+
covers every preset and ships in the main entry point.
|
|
19
49
|
|
|
20
50
|
## Usage
|
|
21
51
|
|
|
@@ -151,8 +181,11 @@ const address = await getAddressFromSignature(signature, messageHash)
|
|
|
151
181
|
```typescript
|
|
152
182
|
import { getPreviousCiphertext } from '@crisp-e3/sdk'
|
|
153
183
|
|
|
154
|
-
const
|
|
155
|
-
//
|
|
184
|
+
const head = await getPreviousCiphertext(serverUrl, e3Id, slotAddress)
|
|
185
|
+
// { ciphertext, index }, or undefined when the slot holds nothing usable (404).
|
|
186
|
+
// `index` is the entry a new input names as its parent. It is the end of the slot's chain of
|
|
187
|
+
// usable entries, not simply the newest one published: an entry whose bytes do not reproduce its
|
|
188
|
+
// commitment is never selected by the Secure Process, and never a valid parent.
|
|
156
189
|
```
|
|
157
190
|
|
|
158
191
|
## API
|
|
@@ -170,8 +203,9 @@ const previousCiphertext = await getPreviousCiphertext(serverUrl, e3Id, slotAddr
|
|
|
170
203
|
- `getRoundDetails(serverUrl: string, e3Id: bigint): Promise<RoundDetails>` - Get round details
|
|
171
204
|
- `getRoundTokenDetails(serverUrl: string, e3Id: bigint): Promise<TokenDetails>` - Get token details
|
|
172
205
|
for a round
|
|
173
|
-
- `getPreviousCiphertext(serverUrl: string, e3Id: bigint, address: string): Promise<
|
|
174
|
-
Get
|
|
206
|
+
- `getPreviousCiphertext(serverUrl: string, e3Id: bigint, address: string): Promise<SlotHead | undefined>` -
|
|
207
|
+
Get the end of a slot's chain of usable entries, as `{ ciphertext, index }`. `index` is what a new
|
|
208
|
+
input names as its parent. Undefined when the slot holds nothing usable.
|
|
175
209
|
|
|
176
210
|
### Token Functions
|
|
177
211
|
|