@ome-labs/wasm 0.0.0-stage → 0.1.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.
@@ -0,0 +1,614 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ // Generated from crates/wasm by `pnpm --filter @ome-labs/wasm generate`. Do not edit.
4
+
5
+ import type {
6
+ ErrorKind,
7
+ Hex32,
8
+ Hex64,
9
+ HexBytes,
10
+ Joiner,
11
+ Manifest,
12
+ MemberPartials,
13
+ Point,
14
+ Secret,
15
+ VaultConfig,
16
+ } from "@ome-labs/api";
17
+
18
+ /**
19
+ * A vault as the bindings check proposals against it: its committee manifest and the config note read from the
20
+ * chain.
21
+ */
22
+ export type VaultInput = {
23
+ /**
24
+ * The committee manifest the keeper serves.
25
+ */
26
+ manifest: Manifest;
27
+ /**
28
+ * The vault's config note.
29
+ */
30
+ config: VaultConfig;
31
+ };
32
+
33
+ /**
34
+ * The chain a transaction is bound to, from the node.
35
+ */
36
+ export type Chain = {
37
+ /**
38
+ * L1 chain id, as a field.
39
+ */
40
+ chainId: Hex32;
41
+ /**
42
+ * Rollup version, as a field.
43
+ */
44
+ version: Hex32;
45
+ };
46
+
47
+ /**
48
+ * How a viewing share maps to a share of the address secret.
49
+ */
50
+ export type AddressContext = {
51
+ /**
52
+ * The vault address.
53
+ */
54
+ address: Hex32;
55
+ /**
56
+ * `1` or `-1`: the sign Aztec applies to the address secret.
57
+ */
58
+ sign: number;
59
+ /**
60
+ * `preaddress · G + Ivpk`, normalised to positive `y`.
61
+ */
62
+ addressPoint: Point;
63
+ };
64
+
65
+ /**
66
+ * A threshold ECDH batch to verify and combine: the keeper's `ecdh.batch` responses with what they answer.
67
+ */
68
+ export type CombineRequest = {
69
+ /**
70
+ * Committee epoch the partials are bound to.
71
+ */
72
+ epoch: number;
73
+ /**
74
+ * Vault preaddress.
75
+ */
76
+ preaddress: Hex32;
77
+ /**
78
+ * Group incoming viewing key `Ivpk`.
79
+ */
80
+ ivpk: Point;
81
+ /**
82
+ * Verification shares `Y_i` in member order.
83
+ */
84
+ verificationShares: Array<Point>;
85
+ /**
86
+ * Viewing threshold `t_v`.
87
+ */
88
+ threshold: number;
89
+ /**
90
+ * Input points, in the order the partials answer them.
91
+ */
92
+ inputs: Array<Point>;
93
+ /**
94
+ * Members' partials.
95
+ */
96
+ responses: Array<MemberPartials>;
97
+ };
98
+
99
+ /**
100
+ * Combined points.
101
+ */
102
+ export type CombineResult = {
103
+ /**
104
+ * `address_secret · input` for each input, in order.
105
+ */
106
+ points: Array<Point>;
107
+ /**
108
+ * Members whose response was malformed or carried an invalid proof.
109
+ */
110
+ invalidMembers: Array<number>;
111
+ };
112
+
113
+ /**
114
+ * Where a call runs.
115
+ */
116
+ export type CallKind = "private" | "public";
117
+
118
+ /**
119
+ * One call of a vault transaction.
120
+ */
121
+ export type Call = {
122
+ /**
123
+ * The function signature, when known; it must hash to `selector`.
124
+ */
125
+ signature: string | null;
126
+ /**
127
+ * Target contract.
128
+ */
129
+ to: Hex32;
130
+ /**
131
+ * Function selector.
132
+ */
133
+ selector: number;
134
+ /**
135
+ * Private or public.
136
+ */
137
+ kind: CallKind;
138
+ /**
139
+ * The call may not modify state.
140
+ */
141
+ isStatic: boolean;
142
+ /**
143
+ * Hide the vault as `msg_sender` (public calls only).
144
+ */
145
+ hideMsgSender: boolean;
146
+ /**
147
+ * Encoded arguments.
148
+ */
149
+ args: Array<Hex32>;
150
+ };
151
+
152
+ /**
153
+ * The calls a payload carries, and the PXE's execution data.
154
+ */
155
+ export type ExecutionRequest = {
156
+ /**
157
+ * At most five calls; none is a cancellation.
158
+ */
159
+ calls: Array<Call>;
160
+ /**
161
+ * Execution data the signatures do not cover.
162
+ */
163
+ extras: HexBytes;
164
+ };
165
+
166
+ /**
167
+ * What a member proposes.
168
+ */
169
+ export type Draft = {
170
+ /**
171
+ * The calls.
172
+ */
173
+ calls: Array<Call>;
174
+ /**
175
+ * Execution data the signatures do not cover.
176
+ */
177
+ extras: HexBytes;
178
+ /**
179
+ * Entrypoint nonce; cancelling burns it.
180
+ */
181
+ txNonce: Hex32;
182
+ /**
183
+ * Approval deadline, Unix seconds.
184
+ */
185
+ expiresAt: number;
186
+ /**
187
+ * Summary shown to the members.
188
+ */
189
+ summary: string;
190
+ /**
191
+ * Proposing member (1-based).
192
+ */
193
+ proposer: number;
194
+ };
195
+
196
+ /**
197
+ * A proposal ready to store with the keeper (`proposals.put`, `payloads.put`).
198
+ */
199
+ export type BuiltProposal = {
200
+ /**
201
+ * Proposal id.
202
+ */
203
+ id: Hex32;
204
+ /**
205
+ * The proposal's canonical encoding.
206
+ */
207
+ proposal: HexBytes;
208
+ /**
209
+ * The payload's canonical encoding.
210
+ */
211
+ payload: HexBytes;
212
+ /**
213
+ * Outer hash the approvals sign over.
214
+ */
215
+ outerHash: Hex32;
216
+ /**
217
+ * The message an approval signs.
218
+ */
219
+ approvalMessage: Hex32;
220
+ };
221
+
222
+ /**
223
+ * A decoded proposal.
224
+ */
225
+ export type ProposalInfo = {
226
+ /**
227
+ * Proposal id.
228
+ */
229
+ id: Hex32;
230
+ /**
231
+ * Config version it was made under.
232
+ */
233
+ configVersion: number;
234
+ /**
235
+ * Outer hash.
236
+ */
237
+ outerHash: Hex32;
238
+ /**
239
+ * Deadline, Unix seconds.
240
+ */
241
+ expiresAt: number;
242
+ /**
243
+ * Entrypoint nonce.
244
+ */
245
+ txNonce: Hex32;
246
+ /**
247
+ * Fee method; Ome proposals use only `0` (external).
248
+ */
249
+ feeMethod: number;
250
+ /**
251
+ * Hash of the referenced payload.
252
+ */
253
+ payloadHash: Hex32;
254
+ /**
255
+ * Length of the referenced payload.
256
+ */
257
+ payloadLen: number;
258
+ /**
259
+ * Summary.
260
+ */
261
+ summary: string;
262
+ /**
263
+ * Proposing member.
264
+ */
265
+ proposer: number;
266
+ };
267
+
268
+ /**
269
+ * A decoded approval.
270
+ */
271
+ export type ApprovalInfo = {
272
+ /**
273
+ * Proposal id.
274
+ */
275
+ proposal: Hex32;
276
+ /**
277
+ * Signer slot, 0-based.
278
+ */
279
+ slot: number;
280
+ /**
281
+ * Schnorr signature.
282
+ */
283
+ signature: Hex64;
284
+ };
285
+
286
+ /**
287
+ * A decoded rejection.
288
+ */
289
+ export type RejectionInfo = {
290
+ /**
291
+ * Proposal id.
292
+ */
293
+ proposal: Hex32;
294
+ /**
295
+ * Signer slot, 0-based.
296
+ */
297
+ slot: number;
298
+ /**
299
+ * Reason shown to the members.
300
+ */
301
+ reason: string;
302
+ /**
303
+ * Schnorr signature.
304
+ */
305
+ signature: Hex64;
306
+ };
307
+
308
+ /**
309
+ * Where a proposal stands.
310
+ */
311
+ export type TallyStatus = "pending" | "approved" | "blocked" | "expired";
312
+
313
+ /**
314
+ * A vote the tally refused.
315
+ */
316
+ export type RefusedVote = {
317
+ /**
318
+ * Position in the approvals or rejections given.
319
+ */
320
+ index: number;
321
+ /**
322
+ * Whether it was an approval.
323
+ */
324
+ approval: boolean;
325
+ /**
326
+ * Why.
327
+ */
328
+ reason: string;
329
+ };
330
+
331
+ /**
332
+ * The votes on a proposal.
333
+ */
334
+ export type TallyResult = {
335
+ /**
336
+ * Where it stands.
337
+ */
338
+ status: TallyStatus;
339
+ /**
340
+ * Counted approvals.
341
+ */
342
+ approvals: number;
343
+ /**
344
+ * Counted rejections.
345
+ */
346
+ rejections: number;
347
+ /**
348
+ * The spending threshold `k`.
349
+ */
350
+ needed: number;
351
+ /**
352
+ * Votes that did not verify.
353
+ */
354
+ refused: Array<RefusedVote>;
355
+ /**
356
+ * The 49-field auth witness, once approved.
357
+ */
358
+ witness: Array<Hex32> | null;
359
+ };
360
+
361
+ /**
362
+ * A proposed membership rotation: the new signers, spending threshold and committee from the reshare.
363
+ */
364
+ export type Rotation = {
365
+ /**
366
+ * New signer keys in slot order.
367
+ */
368
+ signers: Array<Point>;
369
+ /**
370
+ * New spending threshold `k`.
371
+ */
372
+ threshold: number;
373
+ /**
374
+ * New viewing threshold `t_v`.
375
+ */
376
+ viewingThreshold: number;
377
+ /**
378
+ * The verification shares the reshare produced.
379
+ */
380
+ verificationShares: Array<Point>;
381
+ };
382
+
383
+ /**
384
+ * A threshold choice members should make knowingly.
385
+ */
386
+ export type Warning = "single-signer" | "no-spare-signer" | "two-can-read" | "no-spare-viewer";
387
+
388
+ /**
389
+ * A committee dealt from one secret, for tests (`@ome-labs/wasm/testing`).
390
+ */
391
+ export type DealtCommittee = {
392
+ /**
393
+ * Group key: the secret times the generator.
394
+ */
395
+ groupKey: Point;
396
+ /**
397
+ * Members' viewing shares, in member order.
398
+ */
399
+ shares: Array<Hex32>;
400
+ /**
401
+ * Members' verification shares, in member order.
402
+ */
403
+ verificationShares: Array<Point>;
404
+ };
405
+
406
+ /** What every function throws: an `Error` named `OmeWasmError` with the API error kind. */
407
+ export interface OmeWasmError extends Error {
408
+ name: "OmeWasmError";
409
+ kind: ErrorKind;
410
+ }
411
+
412
+
413
+
414
+ /**
415
+ * An opened signing key. It signs only proposals `ome-protocol` accepts, and is wiped when freed.
416
+ */
417
+ export class UnlockedSigner {
418
+ private constructor();
419
+ free(): void;
420
+ [Symbol.dispose](): void;
421
+ /**
422
+ * Approves a proposal after checking it (as `checkProposal`); a rotation is refused here, see `approveRotation`.
423
+ * Returns the approval to store with the keeper.
424
+ */
425
+ approve(vault: VaultInput, chain: Chain, proposal: HexBytes, payload: HexBytes, now: number): HexBytes;
426
+ /**
427
+ * Approves a membership rotation the member reviewed: the payload must be the `rotate_membership` call for
428
+ * `rotation`, plus at most fee payment calls to one of `feePayers` (the fee payer contracts this member's own
429
+ * configuration trusts), and the rotation must pass the contract's rules and hold the vault's key.
430
+ */
431
+ approveRotation(vault: VaultInput, chain: Chain, proposal: HexBytes, payload: HexBytes, rotation: Rotation, feePayers: Hex32[], now: number): HexBytes;
432
+ /**
433
+ * Approves a signer swap: the payload must be one `rotate_membership` call that replaces one member's key and
434
+ * changes nothing else, plus at most fee payment calls to one of `feePayers`. Returns the approval to store with
435
+ * the keeper.
436
+ */
437
+ approveSignerSwap(vault: VaultInput, chain: Chain, proposal: HexBytes, payload: HexBytes, feePayers: Hex32[], now: number): HexBytes;
438
+ /**
439
+ * Opens a sealed signer.
440
+ */
441
+ static open(sealed: string, secret: Secret): UnlockedSigner;
442
+ /**
443
+ * The public key, as it appears in the vault's signer set.
444
+ */
445
+ publicKey(): Point;
446
+ /**
447
+ * Rejects a proposal with a reason shown to the other members. Returns the rejection to store with the keeper.
448
+ */
449
+ reject(vault: VaultInput, proposal: HexBytes, reason: string): HexBytes;
450
+ }
451
+
452
+ /**
453
+ * The address context of a preaddress and group incoming viewing key: the vault address and the sign Aztec applies.
454
+ */
455
+ export function addressContext(preaddress: Hex32, ivpk: Point): AddressContext;
456
+
457
+ /**
458
+ * Each member's public share of the address secret, `A_i`, from its verification share, in member order.
459
+ */
460
+ export function addressPublicShares(preaddress: Hex32, ivpk: Point, verificationShares: Point[]): Point[];
461
+
462
+ /**
463
+ * The entrypoint's app payload hash (the authwit's inner hash).
464
+ */
465
+ export function appPayloadHash(calls: Call[], txNonce: Hex32): Hex32;
466
+
467
+ /**
468
+ * What each signer signs to approve: `Poseidon2("ome.approval.v0", [vault, outerHash, configVersion, expiresAt])`.
469
+ */
470
+ export function approvalMessage(vault: Hex32, outerHash: Hex32, configVersion: number, expiresAt: number): Hex32;
471
+
472
+ /**
473
+ * Builds a proposal and its payload from a draft, computing the outer hash from the calls.
474
+ */
475
+ export function buildProposal(vault: VaultInput, chain: Chain, draft: Draft): BuiltProposal;
476
+
477
+ /**
478
+ * Checks a received proposal before review: the payload is the one referenced, hashes to the outer hash on this vault
479
+ * and chain, the config is current, the deadline has not passed and fees stay off the vault. Returns the calls.
480
+ */
481
+ export function checkProposal(vault: VaultInput, chain: Chain, proposal: HexBytes, payload: HexBytes, now: number): ExecutionRequest;
482
+
483
+ /**
484
+ * Checks a rotation against the vault as the contract would, and returns the config it would store.
485
+ */
486
+ export function checkRotation(vault: VaultInput, rotation: Rotation): VaultConfig;
487
+
488
+ /**
489
+ * The commitment to the viewing committee: `t_v` and the verification shares in member order.
490
+ */
491
+ export function committeeCommitment(viewingThreshold: number, shares: Point[]): Hex32;
492
+
493
+ /**
494
+ * The Feldman commitments of a committee's polynomial, `C_0 … C_{t_v - 1}`: the `committee_polynomial` argument of
495
+ * `rotate_membership`, which the contract checks every share against and `C_0` against the vault's `Ivpk`.
496
+ */
497
+ export function committeePolynomial(viewingThreshold: number, verificationShares: Point[]): Point[];
498
+
499
+ /**
500
+ * An approval's fields. The signature is not checked; see [`verify_approval`].
501
+ */
502
+ export function decodeApproval(approval: HexBytes): ApprovalInfo;
503
+
504
+ /**
505
+ * The newcomer a join request names, after checking that its keeper signed it. The member planning the rotation
506
+ * still confirms out of band that it came from the person they mean to add.
507
+ */
508
+ export function decodeJoinRequest(request: string): Joiner;
509
+
510
+ /**
511
+ * A proposal's fields.
512
+ */
513
+ export function decodeProposal(proposal: HexBytes): ProposalInfo;
514
+
515
+ /**
516
+ * A rejection's fields. The signature is not checked; see [`verify_rejection`].
517
+ */
518
+ export function decodeRejection(rejection: HexBytes): RejectionInfo;
519
+
520
+ /**
521
+ * The 49-field auth witness: signer keys, one signature per slot (`null` where the signer did not approve) and the
522
+ * deadline.
523
+ */
524
+ export function encodeWitness(signerKeys: Point[], signatures: (Hex64 | null)[], expiresAt: number): Hex32[];
525
+
526
+ /**
527
+ * The tagging secret for the vault's own unconstrained notes in committee epoch `epoch`, derived from that epoch's
528
+ * ceremony transcript (the founding DKG, then each reshare), so a member removed earlier cannot derive it.
529
+ */
530
+ export function epochTaggingSecret(vault: Hex32, epoch: number, transcript: Hex64): Point;
531
+
532
+ /**
533
+ * Generates a signing key and returns it sealed (the JSON document to store). A passphrase seals with Argon2id.
534
+ */
535
+ export function generateSigner(secret: Secret): string;
536
+
537
+ /**
538
+ * The outer hash the vault authorizes for `calls` with `txNonce` on `vault` and `chain`.
539
+ */
540
+ export function outerHash(vault: Hex32, chain: Chain, txNonce: Hex32, calls: Call[]): Hex32;
541
+
542
+ /**
543
+ * The risks of spending threshold `k`, viewing threshold `t_v` and `n` members. None blocks a vault.
544
+ */
545
+ export function policyWarnings(threshold: number, viewingThreshold: number, members: number): Warning[];
546
+
547
+ /**
548
+ * Aztec's preaddress `Poseidon2([publicKeysHash, partialAddress], 993442748)`.
549
+ */
550
+ export function preaddress(publicKeysHash: Hex32, partialAddress: Hex32): Hex32;
551
+
552
+ /**
553
+ * What a member signs to reject proposal `proposalId`.
554
+ */
555
+ export function rejectionMessage(vault: Hex32, proposalId: Hex32): Hex32;
556
+
557
+ /**
558
+ * The `rotate_membership` call that performs a rotation, to propose.
559
+ */
560
+ export function rotationCall(vault: VaultInput, rotation: Rotation): Call;
561
+
562
+ /**
563
+ * The public key of a sealed signer, readable without the secret.
564
+ */
565
+ export function sealedPublicKey(sealed: string): Point;
566
+
567
+ /**
568
+ * The key a passphrase derives for this sealed signer, checked by opening it. Keep it behind the platform's
569
+ * keychain or biometrics and unlock with `{ key }` without running Argon2id again.
570
+ */
571
+ export function sealingKey(sealed: string, passphrase: string): Hex32;
572
+
573
+ /**
574
+ * A function's selector from its signature, e.g. `transfer_private_to_private((Field),(Field),u128,Field)`.
575
+ */
576
+ export function selector(signature: string): number;
577
+
578
+ /**
579
+ * The commitment to the ordered signer keys stored in the config note.
580
+ */
581
+ export function signerSetCommitment(keys: Point[]): Hex32;
582
+
583
+ /**
584
+ * The signer slot a payload's `rotate_membership` call swaps, if it is a signer swap of the vault (one key replaced,
585
+ * the committee and thresholds unchanged); `null` for a payload that rotates nothing or reshares.
586
+ */
587
+ export function signerSwapSlot(vault: VaultInput, payload: HexBytes): number | null;
588
+
589
+ /**
590
+ * Counts the votes on a proposal at `now`: each slot's first valid vote counts, invalid ones are listed, and the
591
+ * witness is built once `k` members approved.
592
+ */
593
+ export function tally(vault: VaultInput, proposal: HexBytes, approvals: HexBytes[], rejections: HexBytes[], now: number): TallyResult;
594
+
595
+ /**
596
+ * Verifies every partial and combines `t_v` valid ones per input. Fails if an input lacks `t_v` valid partials.
597
+ */
598
+ export function verifyAndCombine(request: CombineRequest): CombineResult;
599
+
600
+ /**
601
+ * Throws unless `approval` is for `proposal` and signed by the key in its slot.
602
+ */
603
+ export function verifyApproval(vault: VaultInput, proposal: HexBytes, approval: HexBytes): void;
604
+
605
+ /**
606
+ * Throws unless `rejection` is for `proposal` and signed by the key in its slot.
607
+ */
608
+ export function verifyRejection(vault: VaultInput, proposal: HexBytes, rejection: HexBytes): void;
609
+
610
+ /**
611
+ * Throws unless the verification shares interpolate to `groupKey`: the reshared committee still holds the vault's
612
+ * viewing key.
613
+ */
614
+ export function verifyRotationShares(groupKey: Point, viewingThreshold: number, verificationShares: Point[]): void;