@openzeppelin/miden-multisig-client 0.17.0 → 0.18.0-rc.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 +171 -46
- package/dist/account/builder.d.ts +4 -4
- package/dist/account/builder.d.ts.map +1 -1
- package/dist/account/builder.js +17 -7
- package/dist/account/builder.js.map +1 -1
- package/dist/account/layout.d.ts +5 -5
- package/dist/account/layout.d.ts.map +1 -1
- package/dist/account/layout.js +5 -5
- package/dist/account/layout.js.map +1 -1
- package/dist/client.d.ts +18 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +79 -6
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/multisig/authArgErrors.d.ts +28 -31
- package/dist/multisig/authArgErrors.d.ts.map +1 -1
- package/dist/multisig/authArgErrors.js +42 -46
- package/dist/multisig/authArgErrors.js.map +1 -1
- package/dist/multisig/consumeNotesErrors.d.ts +13 -1
- package/dist/multisig/consumeNotesErrors.d.ts.map +1 -1
- package/dist/multisig/consumeNotesErrors.js +17 -0
- package/dist/multisig/consumeNotesErrors.js.map +1 -1
- package/dist/multisig/signing.d.ts +1 -1
- package/dist/multisig/signing.d.ts.map +1 -1
- package/dist/multisig/signing.js +8 -3
- package/dist/multisig/signing.js.map +1 -1
- package/dist/multisig.d.ts +145 -18
- package/dist/multisig.d.ts.map +1 -1
- package/dist/multisig.js +493 -162
- package/dist/multisig.js.map +1 -1
- package/dist/procedures.d.ts +7 -7
- package/dist/procedures.js +7 -7
- package/dist/proposal/factory.d.ts.map +1 -1
- package/dist/proposal/factory.js +7 -0
- package/dist/proposal/factory.js.map +1 -1
- package/dist/prover/workflow.d.ts +7 -3
- package/dist/prover/workflow.d.ts.map +1 -1
- package/dist/prover/workflow.js +7 -5
- package/dist/prover/workflow.js.map +1 -1
- package/dist/raw-client.d.ts +1 -0
- package/dist/raw-client.d.ts.map +1 -1
- package/dist/raw-client.js +10 -2
- package/dist/raw-client.js.map +1 -1
- package/dist/recovery/publicNoteBackfill.js +1 -1
- package/dist/recovery/publicNoteBackfill.js.map +1 -1
- package/dist/retry/classify.d.ts +3 -0
- package/dist/retry/classify.d.ts.map +1 -1
- package/dist/retry/classify.js +2 -2
- package/dist/retry/classify.js.map +1 -1
- package/dist/signer.d.ts +1 -0
- package/dist/signer.d.ts.map +1 -1
- package/dist/signer.js +1 -0
- package/dist/signer.js.map +1 -1
- package/dist/signers/index.d.ts +1 -0
- package/dist/signers/index.d.ts.map +1 -1
- package/dist/signers/index.js +1 -0
- package/dist/signers/index.js.map +1 -1
- package/dist/signers/ledger.d.ts +25 -0
- package/dist/signers/ledger.d.ts.map +1 -0
- package/dist/signers/ledger.js +96 -0
- package/dist/signers/ledger.js.map +1 -0
- package/dist/state/adopt.d.ts +45 -0
- package/dist/state/adopt.d.ts.map +1 -0
- package/dist/state/adopt.js +101 -0
- package/dist/state/adopt.js.map +1 -0
- package/dist/transaction/authArgs.d.ts +57 -0
- package/dist/transaction/authArgs.d.ts.map +1 -0
- package/dist/transaction/authArgs.js +108 -0
- package/dist/transaction/authArgs.js.map +1 -0
- package/dist/transaction/consumeNotes.d.ts +9 -5
- package/dist/transaction/consumeNotes.d.ts.map +1 -1
- package/dist/transaction/consumeNotes.js +8 -23
- package/dist/transaction/consumeNotes.js.map +1 -1
- package/dist/transaction/noteAuthentication.d.ts +39 -0
- package/dist/transaction/noteAuthentication.d.ts.map +1 -0
- package/dist/transaction/noteAuthentication.js +94 -0
- package/dist/transaction/noteAuthentication.js.map +1 -0
- package/dist/transaction/options.d.ts +25 -0
- package/dist/transaction/options.d.ts.map +1 -1
- package/dist/transaction/p2id.d.ts +3 -2
- package/dist/transaction/p2id.d.ts.map +1 -1
- package/dist/transaction/p2id.js +36 -27
- package/dist/transaction/p2id.js.map +1 -1
- package/dist/transaction/summary.d.ts +126 -22
- package/dist/transaction/summary.d.ts.map +1 -1
- package/dist/transaction/summary.js +164 -22
- package/dist/transaction/summary.js.map +1 -1
- package/dist/transaction/updateGuardian.d.ts +3 -3
- package/dist/transaction/updateGuardian.d.ts.map +1 -1
- package/dist/transaction/updateGuardian.js +5 -16
- package/dist/transaction/updateGuardian.js.map +1 -1
- package/dist/transaction/updateProcedureThreshold.d.ts +3 -3
- package/dist/transaction/updateProcedureThreshold.d.ts.map +1 -1
- package/dist/transaction/updateProcedureThreshold.js +6 -16
- package/dist/transaction/updateProcedureThreshold.js.map +1 -1
- package/dist/transaction/updateSigners.d.ts +3 -3
- package/dist/transaction/updateSigners.d.ts.map +1 -1
- package/dist/transaction/updateSigners.js +9 -16
- package/dist/transaction/updateSigners.js.map +1 -1
- package/dist/transaction.d.ts +3 -2
- package/dist/transaction.d.ts.map +1 -1
- package/dist/transaction.js +3 -2
- package/dist/transaction.js.map +1 -1
- package/dist/types/proposal.d.ts +37 -5
- package/dist/types/proposal.d.ts.map +1 -1
- package/dist/types/proposal.js +8 -0
- package/dist/types/proposal.js.map +1 -1
- package/dist/utils/eip712.d.ts +80 -0
- package/dist/utils/eip712.d.ts.map +1 -0
- package/dist/utils/eip712.js +49 -0
- package/dist/utils/eip712.js.map +1 -0
- package/dist/utils/signature.d.ts +4 -0
- package/dist/utils/signature.d.ts.map +1 -1
- package/dist/utils/signature.js +49 -1
- package/dist/utils/signature.js.map +1 -1
- package/package.json +11 -6
- package/src/account/builder.ts +18 -7
- package/src/account/layout.ts +5 -5
- package/src/client.ts +94 -6
- package/src/index.ts +24 -3
- package/src/multisig/authArgErrors.ts +47 -53
- package/src/multisig/consumeNotesErrors.ts +20 -1
- package/src/multisig/signing.ts +8 -2
- package/src/multisig.ts +614 -205
- package/src/procedures.ts +7 -7
- package/src/proposal/factory.ts +7 -0
- package/src/prover/workflow.ts +7 -10
- package/src/raw-client.ts +11 -7
- package/src/recovery/publicNoteBackfill.ts +1 -1
- package/src/retry/classify.ts +3 -3
- package/src/signer.ts +1 -0
- package/src/signers/index.ts +1 -0
- package/src/signers/ledger.ts +122 -0
- package/src/state/adopt.ts +132 -0
- package/src/transaction/authArgs.ts +142 -0
- package/src/transaction/consumeNotes.ts +23 -30
- package/src/transaction/noteAuthentication.ts +136 -0
- package/src/transaction/options.ts +27 -0
- package/src/transaction/p2id.ts +45 -34
- package/src/transaction/summary.ts +239 -30
- package/src/transaction/updateGuardian.ts +8 -22
- package/src/transaction/updateProcedureThreshold.ts +8 -20
- package/src/transaction/updateSigners.ts +11 -22
- package/src/transaction.ts +18 -1
- package/src/types/proposal.ts +36 -5
- package/src/utils/eip712.ts +57 -0
- package/src/utils/signature.ts +57 -0
- package/src/prover/test-node.d.ts +0 -6
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
//! Typed failures
|
|
2
|
-
//!
|
|
3
|
-
//!
|
|
4
|
-
//! change constructs these, and the proposal paths that do arrive in the PR that commits
|
|
5
|
-
//! the anchored fee faucet. Landing the codes first keeps them out of that PR's diff and
|
|
6
|
-
//! lets a caller pin `code` before the raiser exists — `public-api.test.ts` covers the
|
|
7
|
-
//! barrel so a dropped re-export is caught either way.
|
|
1
|
+
//! Typed failures a caller branches on rather than reports: each means the proposal or
|
|
2
|
+
//! request itself is unusable, as against a transport or WASM failure a retry might clear.
|
|
3
|
+
//! `public-api.test.ts` covers the barrel so a dropped re-export is caught.
|
|
8
4
|
|
|
9
5
|
/** Stable error identifiers for auth-arg recovery failures. */
|
|
10
6
|
export type AuthArgErrorCode =
|
|
11
|
-
| 'proposal_auth_arg_unresolvable'
|
|
12
7
|
| 'proposal_salt_malformed'
|
|
13
|
-
| '
|
|
8
|
+
| 'multisig_auth_args_missing'
|
|
9
|
+
| 'bound_block_not_declared';
|
|
14
10
|
|
|
15
11
|
/** How much of an untrusted value an error message will quote. */
|
|
16
12
|
const MAX_QUOTED_CHARS = 80;
|
|
@@ -56,11 +52,10 @@ function coerceForMessage(value: unknown): string {
|
|
|
56
52
|
* A proposal's recorded salt is not a readable 32-byte word, so no rebuild can
|
|
57
53
|
* use it.
|
|
58
54
|
*
|
|
59
|
-
* Coded
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* GUARDIAN able to strand a fully signed switch.
|
|
55
|
+
* Coded because `switch_guardian` recovery acts on it rather than reporting it:
|
|
56
|
+
* the salt is served by the GUARDIAN being switched away from, which can make it
|
|
57
|
+
* unreadable, and treating that as fatal would leave that GUARDIAN able to strand
|
|
58
|
+
* a fully signed switch.
|
|
64
59
|
*/
|
|
65
60
|
export class ProposalSaltMalformedError extends Error {
|
|
66
61
|
readonly code: AuthArgErrorCode = 'proposal_salt_malformed';
|
|
@@ -90,49 +85,48 @@ export class ProposalSaltMalformedError extends Error {
|
|
|
90
85
|
}
|
|
91
86
|
|
|
92
87
|
/**
|
|
93
|
-
* A
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* `switch_guardian` is the exception, and deliberately so: it rebuilds from the
|
|
100
|
-
* summary's own auth arg, which reproduces the signed word but not the fee
|
|
101
|
-
* preimage behind it, so it executes only on a zero-fee chain.
|
|
102
|
-
*
|
|
103
|
-
* Coded because one caller acts on it rather than reporting it:
|
|
104
|
-
* `switch_guardian` recovery falls back to the summary's own auth arg when it
|
|
105
|
-
* sees this or {@link ProposalSaltMalformedError}, and must not extend that
|
|
106
|
-
* treatment to an unreadable anchor or a WASM failure.
|
|
88
|
+
* A request built for `accountId` came back without the multisig auth args.
|
|
89
|
+
* `feeAwareTransactionRequestBuilder` only attaches them to an account it can
|
|
90
|
+
* classify as a multisig, so this means the account is not in the client's
|
|
91
|
+
* store or its code is not the guarded-multisig component this client knows.
|
|
92
|
+
* Raised at build time: the alternative is an abort inside the auth procedure
|
|
93
|
+
* while it pipes a preimage the advice map does not hold.
|
|
107
94
|
*/
|
|
108
|
-
export class
|
|
109
|
-
readonly code: AuthArgErrorCode = '
|
|
110
|
-
readonly
|
|
111
|
-
readonly signedAuthArgHex: string;
|
|
112
|
-
readonly saltHex: string;
|
|
113
|
-
readonly feeFaucetIdHex: string;
|
|
95
|
+
export class MultisigAuthArgsMissingError extends Error {
|
|
96
|
+
readonly code: AuthArgErrorCode = 'multisig_auth_args_missing';
|
|
97
|
+
readonly accountId: string;
|
|
114
98
|
|
|
115
|
-
constructor(
|
|
116
|
-
proposalId: string;
|
|
117
|
-
signedAuthArgHex: string;
|
|
118
|
-
saltHex: string;
|
|
119
|
-
feeFaucetIdHex: string;
|
|
120
|
-
}) {
|
|
99
|
+
constructor(accountId: string) {
|
|
121
100
|
super(
|
|
122
|
-
`
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
`${quoteUntrusted(details.feeFaucetIdHex)}, so the signed transaction summary cannot ` +
|
|
126
|
-
`be reproduced ` +
|
|
127
|
-
'from that salt, and the proposal cannot be executed. Recreate the proposal and ' +
|
|
128
|
-
'collect signatures again, and have the original dropped server-side — while ' +
|
|
129
|
-
'GUARDIAN keeps serving it, syncing this account keeps failing on it',
|
|
101
|
+
`Account ${quoteUntrusted(accountId)} received no multisig auth args: the client does ` +
|
|
102
|
+
'not hold it as a guarded-multisig account, so a request built for it cannot be ' +
|
|
103
|
+
'authenticated. Import or create the account in this client first',
|
|
130
104
|
);
|
|
131
|
-
this.name = '
|
|
132
|
-
this.
|
|
133
|
-
this.signedAuthArgHex = details.signedAuthArgHex;
|
|
134
|
-
this.saltHex = details.saltHex;
|
|
135
|
-
this.feeFaucetIdHex = details.feeFaucetIdHex;
|
|
105
|
+
this.name = 'MultisigAuthArgsMissingError';
|
|
106
|
+
this.accountId = accountId;
|
|
136
107
|
}
|
|
137
108
|
}
|
|
138
109
|
|
|
110
|
+
/**
|
|
111
|
+
* A multisig request does not list the block its auth args bind among the
|
|
112
|
+
* blocks it declares through `withBlockNumbers`. A proposal executes at the
|
|
113
|
+
* chain tip, where the auth procedure can read the bound block only from the
|
|
114
|
+
* transaction's partial blockchain, so such a request fails in the VM with
|
|
115
|
+
* `failed to lookup value in Merkle store` once the chain moves past that
|
|
116
|
+
* block. `feeAwareTransactionRequestBuilder` declares it; a request whose auth
|
|
117
|
+
* args are attached by hand has to call `withBlockNumbers([boundBlockNum])`.
|
|
118
|
+
*/
|
|
119
|
+
export class BoundBlockNotDeclaredError extends Error {
|
|
120
|
+
readonly code: AuthArgErrorCode = 'bound_block_not_declared';
|
|
121
|
+
readonly boundBlockNum: number;
|
|
122
|
+
|
|
123
|
+
constructor(boundBlockNum: number) {
|
|
124
|
+
super(
|
|
125
|
+
`The transaction request binds block ${boundBlockNum} in its multisig auth args but does ` +
|
|
126
|
+
'not declare it, so it cannot execute at a later chain tip. Build it with ' +
|
|
127
|
+
`feeAwareTransactionRequestBuilder or add withBlockNumbers([${boundBlockNum}])`,
|
|
128
|
+
);
|
|
129
|
+
this.name = 'BoundBlockNotDeclaredError';
|
|
130
|
+
this.boundBlockNum = boundBlockNum;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -8,7 +8,8 @@ export type ConsumeNotesErrorCode =
|
|
|
8
8
|
| 'consume_notes_note_binding_mismatch'
|
|
9
9
|
| 'consume_notes_unsupported_metadata_version'
|
|
10
10
|
| 'consume_notes_metadata_oversize'
|
|
11
|
-
| 'consume_notes_legacy_note_missing'
|
|
11
|
+
| 'consume_notes_legacy_note_missing'
|
|
12
|
+
| 'consume_notes_note_not_authenticated';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* v2 metadata's embedded `notes` array did not match its declared
|
|
@@ -72,3 +73,21 @@ export class LegacyConsumeNotesNoteMissingError extends Error {
|
|
|
72
73
|
this.noteId = noteId;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* A note a `consume_notes` proposal consumes could not be authenticated
|
|
79
|
+
* (its inclusion proof fetched from the node and imported into the local
|
|
80
|
+
* store). The signed summary commits to authenticated consumption, so an
|
|
81
|
+
* unauthenticated rebuild would never match it (issue #409).
|
|
82
|
+
*/
|
|
83
|
+
export class ConsumeNoteNotAuthenticatedError extends Error {
|
|
84
|
+
readonly code: ConsumeNotesErrorCode = 'consume_notes_note_not_authenticated';
|
|
85
|
+
readonly noteId: string;
|
|
86
|
+
readonly reason: string;
|
|
87
|
+
constructor(noteId: string, reason: string) {
|
|
88
|
+
super(`consume_notes: note ${noteId} could not be authenticated: ${reason}`);
|
|
89
|
+
this.name = 'ConsumeNoteNotAuthenticatedError';
|
|
90
|
+
this.noteId = noteId;
|
|
91
|
+
this.reason = reason;
|
|
92
|
+
}
|
|
93
|
+
}
|
package/src/multisig/signing.ts
CHANGED
|
@@ -5,12 +5,18 @@ export function toGuardianSignature(
|
|
|
5
5
|
scheme: SignatureScheme,
|
|
6
6
|
signatureHex: string,
|
|
7
7
|
publicKey?: string,
|
|
8
|
+
messageFormat?: 'eip712',
|
|
8
9
|
): ProposalSignature {
|
|
9
10
|
if (scheme === 'ecdsa') {
|
|
10
11
|
if (!publicKey) {
|
|
11
12
|
throw new Error('ECDSA signature requires publicKey');
|
|
12
13
|
}
|
|
13
|
-
return {
|
|
14
|
+
return {
|
|
15
|
+
scheme: 'ecdsa',
|
|
16
|
+
signature: signatureHex,
|
|
17
|
+
publicKey,
|
|
18
|
+
...(messageFormat ? { messageFormat } : {}),
|
|
19
|
+
};
|
|
14
20
|
}
|
|
15
21
|
return { scheme: 'falcon', signature: signatureHex };
|
|
16
22
|
}
|
|
@@ -20,5 +26,5 @@ export async function buildGuardianSignatureFromSigner(
|
|
|
20
26
|
commitment: string,
|
|
21
27
|
): Promise<ProposalSignature> {
|
|
22
28
|
const signatureHex = await signer.signCommitment(commitment);
|
|
23
|
-
return toGuardianSignature(signer.scheme, signatureHex, signer.publicKey);
|
|
29
|
+
return toGuardianSignature(signer.scheme, signatureHex, signer.publicKey, signer.proposalMessageFormat);
|
|
24
30
|
}
|