@ocap/mpc-hsm 0.0.0-stage → 1.33.6

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/lib/mta.cjs ADDED
@@ -0,0 +1,280 @@
1
+ const require_constants = require('./constants.cjs');
2
+ const require_secp256k1_scalar = require('./secp256k1-scalar.cjs');
3
+ let _noble_hashes_sha3_js = require("@noble/hashes/sha3.js");
4
+
5
+ //#region src/mta.ts
6
+ /**
7
+ * Single-Row Dual-Pad `GadgetMtA` anchored to Presignature Round-1 `C_{k,i}` (`design.md` §4.4(3)):
8
+ *
9
+ * - Gadget vector `g_{0..767}`:
10
+ * - `g_l = 2^l mod n` for `0 <= l < 256`
11
+ * - `g_l = H_scalar("ARC-MPC-LHL-GADGET-V1", u32be(l))` for `256 <= l < 768`
12
+ * - Both pads `(r_{l,b}, r_hat_{l,b}) \in Z_n^2` derive from ONE single COT row
13
+ * `row_{l,b} = Q_l ^ (b * Delta)` via `SHAKE256("ARC-MPC-COT-ROW-V1", ctx_mta, u32be(l), u8(b), row)`
14
+ * squeezing a 96-byte fast-path buffer (with XOF continuation on `>= n`) for exact zero modulo bias.
15
+ * - Anchored to `C_alpha === C_{k,i}`: Receiver `B` strictly verifies byte-equality with Round-1
16
+ * `C_{k,i}`, checks `\alpha^* G + \rho^* H == \eta C_{k,i} + \hat{C}_\alpha`, and verifies all
17
+ * 768 linear checks `\eta t_l + \hat{t}_l === r^*_l + b_l \alpha^* (mod n)`.
18
+ * Note: Single-row selective-failure probing on `s` rows passes with probability `2^{-s}` while
19
+ * `\tilde{x}_B` never enters `GadgetMtA`, `b_B` / `\gamma_B` are single-use and wiped before `e_B`
20
+ * on any Round-2 abort, and `512` fresh per-peer CSPRNG LHL bits keep `b_B mod n` statistically
21
+ * uniform (`> 128`-bit LHL security margin).
22
+ */
23
+ let cachedGadgetVector = null;
24
+ function getGadgetVector768() {
25
+ if (cachedGadgetVector !== null) return cachedGadgetVector;
26
+ const vec = new Array(require_constants.OT_GADGET_BITS);
27
+ let pow2 = 1n;
28
+ for (let l = 0; l < require_constants.OT_BASE_PARTIAL_BITS; l++) {
29
+ vec[l] = pow2;
30
+ pow2 = require_secp256k1_scalar.mulModN(pow2, 2n);
31
+ }
32
+ for (let l = require_constants.OT_BASE_PARTIAL_BITS; l < require_constants.OT_GADGET_BITS; l++) vec[l] = require_secp256k1_scalar.H_scalar(require_constants.DST_LHL_GADGET_V1, require_secp256k1_scalar.u32be(l));
33
+ cachedGadgetVector = vec;
34
+ return vec;
35
+ }
36
+ /**
37
+ * Encodes Receiver `B`'s secret scalar `\beta \in Z_n^*` into `768` choice bits `b_{0..767}`
38
+ * using `512` fresh CSPRNG Leftover-Hash-Lemma bits `b_{256..767}` and exact binary decomposition
39
+ * of `\beta_{rem} = (\beta - \sum_{l=256}^{767} b_l g_l) mod n` in `b_{0..255}`.
40
+ */
41
+ function decomposeScalarWithLhlGadget(betaScalar, rng = require_secp256k1_scalar.defaultRandomBytes) {
42
+ require_secp256k1_scalar.assertScalarNonZero(betaScalar, "MtA receiver betaScalar");
43
+ const gadget = getGadgetVector768();
44
+ const choiceBits768 = new Uint8Array(require_constants.OT_GADGET_BITS);
45
+ const randomLhlBytes64 = rng(require_constants.OT_LHL_EXTRA_BITS >>> 3);
46
+ if (randomLhlBytes64.length !== 64) {
47
+ require_secp256k1_scalar.zeroizeBytes(randomLhlBytes64);
48
+ throw new require_constants.MpcProtocolError("INVALID_PARAMETER", "RNG must produce 64 bytes for LHL bits");
49
+ }
50
+ let highSum = 0n;
51
+ try {
52
+ for (let i = 0; i < require_constants.OT_LHL_EXTRA_BITS; i++) {
53
+ const bit = randomLhlBytes64[i >>> 3] >>> (i & 7) & 1;
54
+ const idx = require_constants.OT_BASE_PARTIAL_BITS + i;
55
+ choiceBits768[idx] = bit;
56
+ if (bit === 1) highSum = require_secp256k1_scalar.addModN(highSum, gadget[idx]);
57
+ }
58
+ } finally {
59
+ require_secp256k1_scalar.zeroizeBytes(randomLhlBytes64);
60
+ }
61
+ const betaRem = require_secp256k1_scalar.subModN(betaScalar, highSum);
62
+ for (let l = 0; l < require_constants.OT_BASE_PARTIAL_BITS; l++) choiceBits768[l] = Number(betaRem >> BigInt(l) & 1n);
63
+ return choiceBits768;
64
+ }
65
+ function recombineGadgetBitsModN(choiceBits768) {
66
+ if (choiceBits768.length !== require_constants.OT_GADGET_BITS) throw new require_constants.MpcProtocolError("INVALID_PARAMETER", `Expected ${require_constants.OT_GADGET_BITS} gadget bits`);
67
+ const gadget = getGadgetVector768();
68
+ let acc = 0n;
69
+ for (let l = 0; l < require_constants.OT_GADGET_BITS; l++) {
70
+ const bit = choiceBits768[l];
71
+ if (bit !== 0 && bit !== 1) throw new require_constants.MpcProtocolError("INVALID_PARAMETER", `Invalid gadget bit at ${l}`);
72
+ if (bit === 1) acc = require_secp256k1_scalar.addModN(acc, gadget[l]);
73
+ }
74
+ return acc;
75
+ }
76
+ const COT_ROW_TAG_BYTES = new TextEncoder().encode(require_constants.DST_COT_ROW_V1);
77
+ function buildCotRowHasherTemplate(ctxMta) {
78
+ const prefixLen = 4 + COT_ROW_TAG_BYTES.length + 4 + 4 + ctxMta.length;
79
+ const prefix = new Uint8Array(prefixLen);
80
+ const pView = new DataView(prefix.buffer);
81
+ let off = 0;
82
+ pView.setUint32(off, COT_ROW_TAG_BYTES.length, false);
83
+ off += 4;
84
+ prefix.set(COT_ROW_TAG_BYTES, off);
85
+ off += COT_ROW_TAG_BYTES.length;
86
+ pView.setUint32(off, 4, false);
87
+ off += 4;
88
+ pView.setUint32(off, ctxMta.length, false);
89
+ off += 4;
90
+ prefix.set(ctxMta, off);
91
+ const baseHasher = _noble_hashes_sha3_js.shake256.create({});
92
+ baseHasher.update(prefix);
93
+ const suffix = new Uint8Array(33);
94
+ const sView = new DataView(suffix.buffer);
95
+ sView.setUint32(0, 4, false);
96
+ sView.setUint32(8, 1, false);
97
+ sView.setUint32(13, 16, false);
98
+ const initial96 = new Uint8Array(96);
99
+ const extra32 = new Uint8Array(32);
100
+ return {
101
+ derive(rowIndex, bit, rowBytes16) {
102
+ if (rowBytes16.length !== 16) throw new require_constants.MpcProtocolError("INVALID_PARAMETER", "COT row must be 16 bytes");
103
+ sView.setUint32(4, rowIndex >>> 0, false);
104
+ suffix[12] = bit;
105
+ suffix.set(rowBytes16, 17);
106
+ const xof = baseHasher.clone();
107
+ try {
108
+ xof.update(suffix);
109
+ xof.xofInto(initial96);
110
+ let rPrimary = null;
111
+ let rHat = null;
112
+ for (let chunk = 0; chunk < 3 && rHat === null; chunk++) {
113
+ const candidate = require_secp256k1_scalar.bytesToBigIntBE(initial96.subarray(chunk * 32, (chunk + 1) * 32));
114
+ if (candidate < require_constants.SECP256K1_N) if (rPrimary === null) rPrimary = candidate;
115
+ else rHat = candidate;
116
+ }
117
+ while (rHat === null) {
118
+ xof.xofInto(extra32);
119
+ const candidate = require_secp256k1_scalar.bytesToBigIntBE(extra32);
120
+ if (candidate < require_constants.SECP256K1_N) if (rPrimary === null) rPrimary = candidate;
121
+ else rHat = candidate;
122
+ }
123
+ return [rPrimary, rHat];
124
+ } finally {
125
+ xof.destroy();
126
+ }
127
+ },
128
+ destroy() {
129
+ require_secp256k1_scalar.zeroizeBytes(suffix, initial96, extra32);
130
+ baseHasher.destroy();
131
+ }
132
+ };
133
+ }
134
+ /**
135
+ * Single-row `SHAKE256(96B)` dual-pad extractor (`(r_{l,bit}, r_hat_{l,bit}) \in Z_n^2`).
136
+ * Squeezes an initial 96-byte chunk (3 x 32B candidates for 2 scalars) and continues squeezing
137
+ * 32B blocks on the same XOF stream if any 256-bit block is `>= n` (exact unbiased over `Z_n^2`).
138
+ */
139
+ function deriveDualPadFromCotRow(ctxMta, rowIndex, bit, rowBytes16) {
140
+ const tpl = buildCotRowHasherTemplate(ctxMta);
141
+ try {
142
+ return tpl.derive(rowIndex, bit, rowBytes16);
143
+ } finally {
144
+ tpl.destroy();
145
+ }
146
+ }
147
+ function computeMtaEtaChallenge(ctxMta, senderSlotA, receiverSlotB, cAlphaComp33, cHatAlphaComp33, uPackedBytes, uHatPackedBytes) {
148
+ return require_secp256k1_scalar.H_scalar(require_constants.DST_MTA_ETA_V1, ctxMta, require_secp256k1_scalar.u32be(senderSlotA), require_secp256k1_scalar.u32be(receiverSlotB), cAlphaComp33, cHatAlphaComp33, uPackedBytes, uHatPackedBytes);
149
+ }
150
+ /**
151
+ * Sender `A` (slot `i`) executes single-row dual-pad `GadgetMtA` over verified `KOS15` rows,
152
+ * anchored to Round-1 Pedersen commitment `C_{k,i} = k_i G + \rho_{k,i} H`.
153
+ * Returns additive share `u_A \in Z_n` such that `u_A + v_B === k_i * \beta_j (mod n)`.
154
+ */
155
+ function gadgetMtaSenderCreateMessage(params) {
156
+ const { ctxMta, senderSlotA, receiverSlotB, verifiedSenderRows, alphaScalar, rhoAlphaScalar, expectedRound1CommitmentCk, rng = require_secp256k1_scalar.defaultRandomBytes } = params;
157
+ require_secp256k1_scalar.assertScalarNonZero(alphaScalar, "MtA alphaScalar");
158
+ require_secp256k1_scalar.assertScalarNonZero(rhoAlphaScalar, "MtA rhoAlphaScalar");
159
+ if (verifiedSenderRows.qRows768.length !== require_constants.OT_GADGET_BITS) throw new require_constants.MpcProtocolError("INVALID_PARAMETER", "Verified COT sender rows must have 768 rows");
160
+ const cAlphaComp33 = require_secp256k1_scalar.encodePointCompressed(require_secp256k1_scalar.pedersenCommit(alphaScalar, rhoAlphaScalar));
161
+ if (!require_secp256k1_scalar.constantTimeEqual(cAlphaComp33, expectedRound1CommitmentCk)) throw new require_constants.MpcProtocolError("MTA_COMMITMENT_MISMATCH", "Sender C_alpha does not match Round-1 C_{k,i}");
162
+ const alphaHat = require_secp256k1_scalar.sampleScalarNonZero(rng);
163
+ const rhoHat = require_secp256k1_scalar.sampleScalarNonZero(rng);
164
+ const cHatAlphaComp33 = require_secp256k1_scalar.encodePointCompressed(require_secp256k1_scalar.pedersenCommit(alphaHat, rhoHat));
165
+ const r0Vec = new Array(require_constants.OT_GADGET_BITS);
166
+ const rHat0Vec = new Array(require_constants.OT_GADGET_BITS);
167
+ const uPackedBytes = new Uint8Array(require_constants.OT_GADGET_BITS * 32);
168
+ const uHatPackedBytes = new Uint8Array(require_constants.OT_GADGET_BITS * 32);
169
+ const row1Buf = new Uint8Array(16);
170
+ const rowHasher = buildCotRowHasherTemplate(ctxMta);
171
+ try {
172
+ for (let l = 0; l < require_constants.OT_GADGET_BITS; l++) {
173
+ const row0 = verifiedSenderRows.qRows768[l];
174
+ for (let bIdx = 0; bIdx < 16; bIdx++) row1Buf[bIdx] = row0[bIdx] ^ verifiedSenderRows.deltaBytes16[bIdx];
175
+ const [r0, rHat0] = rowHasher.derive(l, 0, row0);
176
+ const [r1, rHat1] = rowHasher.derive(l, 1, row1Buf);
177
+ r0Vec[l] = r0;
178
+ rHat0Vec[l] = rHat0;
179
+ const uL = require_secp256k1_scalar.addModN(require_secp256k1_scalar.subModN(r0, r1), alphaScalar);
180
+ const uHatL = require_secp256k1_scalar.addModN(require_secp256k1_scalar.subModN(rHat0, rHat1), alphaHat);
181
+ uPackedBytes.set(require_secp256k1_scalar.scalarToBytes32(uL), l * 32);
182
+ uHatPackedBytes.set(require_secp256k1_scalar.scalarToBytes32(uHatL), l * 32);
183
+ }
184
+ } finally {
185
+ require_secp256k1_scalar.zeroizeBytes(row1Buf);
186
+ rowHasher.destroy();
187
+ }
188
+ const eta = computeMtaEtaChallenge(ctxMta, senderSlotA, receiverSlotB, cAlphaComp33, cHatAlphaComp33, uPackedBytes, uHatPackedBytes);
189
+ const alphaStar = require_secp256k1_scalar.addModN(require_secp256k1_scalar.mulModN(eta, alphaScalar), alphaHat);
190
+ const rhoStar = require_secp256k1_scalar.addModN(require_secp256k1_scalar.mulModN(eta, rhoAlphaScalar), rhoHat);
191
+ const rStarPackedBytes = new Uint8Array(require_constants.OT_GADGET_BITS * 32);
192
+ const gadget = getGadgetVector768();
193
+ let sumGR0 = 0n;
194
+ for (let l = 0; l < require_constants.OT_GADGET_BITS; l++) {
195
+ const r0 = r0Vec[l];
196
+ const rHat0 = rHat0Vec[l];
197
+ const rStarL = require_secp256k1_scalar.addModN(require_secp256k1_scalar.mulModN(eta, r0), rHat0);
198
+ rStarPackedBytes.set(require_secp256k1_scalar.scalarToBytes32(rStarL), l * 32);
199
+ sumGR0 = require_secp256k1_scalar.addModN(sumGR0, require_secp256k1_scalar.mulModN(gadget[l], r0));
200
+ r0Vec[l] = 0n;
201
+ rHat0Vec[l] = 0n;
202
+ }
203
+ return {
204
+ senderShareModN: require_secp256k1_scalar.negModN(sumGR0),
205
+ payload: {
206
+ senderSlotA,
207
+ receiverSlotB,
208
+ cAlphaComp33,
209
+ cHatAlphaComp33,
210
+ uPackedBytes,
211
+ uHatPackedBytes,
212
+ alphaStarBytes32: require_secp256k1_scalar.scalarToBytes32(alphaStar),
213
+ rhoStarBytes32: require_secp256k1_scalar.scalarToBytes32(rhoStar),
214
+ rStarPackedBytes
215
+ }
216
+ };
217
+ }
218
+ /**
219
+ * Receiver `B` (slot `j`) verifies `C_alpha === C_{k,i}` (Round-1 commitment binding),
220
+ * checks the Pedersen linear combination `\alpha^* G + \rho^* H == \eta C_{k,i} + \hat{C}_\alpha`,
221
+ * verifies all 768 single-row dual-pad equations `\eta t_l + \hat{t}_l == r^*_l + b_l \alpha^* (mod n)`,
222
+ * and outputs additive share `v_B \in Z_n`.
223
+ */
224
+ function gadgetMtaReceiverVerifyAndFinish(params) {
225
+ const { ctxMta, senderSlotA, receiverSlotB, verifiedReceiverRows, expectedRound1CommitmentCk, payload } = params;
226
+ if (payload.senderSlotA !== senderSlotA || payload.receiverSlotB !== receiverSlotB) throw new require_constants.MpcProtocolError("MTA_CONSISTENCY_CHECK_FAILED", "MtA payload slot header mismatch", senderSlotA);
227
+ if (!require_secp256k1_scalar.constantTimeEqual(payload.cAlphaComp33, expectedRound1CommitmentCk)) throw new require_constants.MpcProtocolError("MTA_COMMITMENT_MISMATCH", `MtA C_alpha mismatch against Round-1 C_{k,${senderSlotA}}`, senderSlotA);
228
+ const expectedPackedLen = require_constants.OT_GADGET_BITS * 32;
229
+ if (payload.uPackedBytes.length !== expectedPackedLen || payload.uHatPackedBytes.length !== expectedPackedLen || payload.rStarPackedBytes.length !== expectedPackedLen) throw new require_constants.MpcProtocolError("MTA_CONSISTENCY_CHECK_FAILED", "Invalid MtA vector byte length", senderSlotA);
230
+ let cKiPoint;
231
+ let cHatPoint;
232
+ let alphaStar;
233
+ let rhoStar;
234
+ try {
235
+ cKiPoint = require_secp256k1_scalar.decodePointCompressed(expectedRound1CommitmentCk, false);
236
+ cHatPoint = require_secp256k1_scalar.decodePointCompressed(payload.cHatAlphaComp33, false);
237
+ alphaStar = require_secp256k1_scalar.bytes32ToScalarStrict(payload.alphaStarBytes32);
238
+ rhoStar = require_secp256k1_scalar.bytes32ToScalarStrict(payload.rhoStarBytes32);
239
+ } catch (err) {
240
+ throw new require_constants.MpcProtocolError("MTA_CONSISTENCY_CHECK_FAILED", `Invalid MtA point/scalar from slot ${senderSlotA}: ${err.message}`, senderSlotA);
241
+ }
242
+ const eta = computeMtaEtaChallenge(ctxMta, senderSlotA, receiverSlotB, payload.cAlphaComp33, payload.cHatAlphaComp33, payload.uPackedBytes, payload.uHatPackedBytes);
243
+ const lhsPedersen = require_secp256k1_scalar.pedersenCommit(alphaStar, rhoStar);
244
+ const rhsPedersen = require_secp256k1_scalar.mulPoint(cKiPoint, eta).add(cHatPoint);
245
+ if (!lhsPedersen.equals(rhsPedersen)) throw new require_constants.MpcProtocolError("MTA_CONSISTENCY_CHECK_FAILED", `MtA Pedersen linear check failed against sender slot ${senderSlotA}`, senderSlotA);
246
+ const gadget = getGadgetVector768();
247
+ let receiverShareAcc = 0n;
248
+ const rowHasher = buildCotRowHasherTemplate(ctxMta);
249
+ try {
250
+ for (let l = 0; l < require_constants.OT_GADGET_BITS; l++) {
251
+ const bBit = verifiedReceiverRows.gadgetChoiceBits768[l];
252
+ let uL;
253
+ let uHatL;
254
+ let rStarL;
255
+ try {
256
+ uL = require_secp256k1_scalar.bytes32ToScalarStrict(payload.uPackedBytes.subarray(l * 32, (l + 1) * 32));
257
+ uHatL = require_secp256k1_scalar.bytes32ToScalarStrict(payload.uHatPackedBytes.subarray(l * 32, (l + 1) * 32));
258
+ rStarL = require_secp256k1_scalar.bytes32ToScalarStrict(payload.rStarPackedBytes.subarray(l * 32, (l + 1) * 32));
259
+ } catch {
260
+ throw new require_constants.MpcProtocolError("MTA_CONSISTENCY_CHECK_FAILED", `Out-of-range scalar in MtA row ${l} from sender slot ${senderSlotA}`, senderSlotA);
261
+ }
262
+ const [rLb, rHatLb] = rowHasher.derive(l, bBit, verifiedReceiverRows.tRows768[l]);
263
+ const tL = bBit === 1 ? require_secp256k1_scalar.addModN(rLb, uL) : rLb;
264
+ const tHatL = bBit === 1 ? require_secp256k1_scalar.addModN(rHatLb, uHatL) : rHatLb;
265
+ if (require_secp256k1_scalar.addModN(require_secp256k1_scalar.mulModN(eta, tL), tHatL) !== (bBit === 1 ? require_secp256k1_scalar.addModN(rStarL, alphaStar) : rStarL)) throw new require_constants.MpcProtocolError("MTA_CONSISTENCY_CHECK_FAILED", `MtA row ${l} consistency check failed against sender slot ${senderSlotA}`, senderSlotA);
266
+ receiverShareAcc = require_secp256k1_scalar.addModN(receiverShareAcc, require_secp256k1_scalar.mulModN(gadget[l], tL));
267
+ }
268
+ } finally {
269
+ rowHasher.destroy();
270
+ }
271
+ return receiverShareAcc;
272
+ }
273
+
274
+ //#endregion
275
+ exports.decomposeScalarWithLhlGadget = decomposeScalarWithLhlGadget;
276
+ exports.deriveDualPadFromCotRow = deriveDualPadFromCotRow;
277
+ exports.gadgetMtaReceiverVerifyAndFinish = gadgetMtaReceiverVerifyAndFinish;
278
+ exports.gadgetMtaSenderCreateMessage = gadgetMtaSenderCreateMessage;
279
+ exports.getGadgetVector768 = getGadgetVector768;
280
+ exports.recombineGadgetBitsModN = recombineGadgetBitsModN;
package/lib/mta.d.cts ADDED
@@ -0,0 +1,63 @@
1
+ import { RandomBytesFn } from "./secp256k1-scalar.cjs";
2
+ import { VerifiedCotReceiverRows, VerifiedCotSenderRows } from "./ot.cjs";
3
+
4
+ //#region src/mta.d.ts
5
+ declare function getGadgetVector768(): ReadonlyArray<bigint>;
6
+ /**
7
+ * Encodes Receiver `B`'s secret scalar `\beta \in Z_n^*` into `768` choice bits `b_{0..767}`
8
+ * using `512` fresh CSPRNG Leftover-Hash-Lemma bits `b_{256..767}` and exact binary decomposition
9
+ * of `\beta_{rem} = (\beta - \sum_{l=256}^{767} b_l g_l) mod n` in `b_{0..255}`.
10
+ */
11
+ declare function decomposeScalarWithLhlGadget(betaScalar: bigint, rng?: RandomBytesFn): Uint8Array;
12
+ declare function recombineGadgetBitsModN(choiceBits768: Uint8Array): bigint;
13
+ /**
14
+ * Single-row `SHAKE256(96B)` dual-pad extractor (`(r_{l,bit}, r_hat_{l,bit}) \in Z_n^2`).
15
+ * Squeezes an initial 96-byte chunk (3 x 32B candidates for 2 scalars) and continues squeezing
16
+ * 32B blocks on the same XOF stream if any 256-bit block is `>= n` (exact unbiased over `Z_n^2`).
17
+ */
18
+ declare function deriveDualPadFromCotRow(ctxMta: Uint8Array, rowIndex: number, bit: 0 | 1, rowBytes16: Uint8Array): readonly [bigint, bigint];
19
+ interface GadgetMtaPayload {
20
+ readonly senderSlotA: number;
21
+ readonly receiverSlotB: number;
22
+ readonly cAlphaComp33: Uint8Array;
23
+ readonly cHatAlphaComp33: Uint8Array;
24
+ readonly uPackedBytes: Uint8Array;
25
+ readonly uHatPackedBytes: Uint8Array;
26
+ readonly alphaStarBytes32: Uint8Array;
27
+ readonly rhoStarBytes32: Uint8Array;
28
+ readonly rStarPackedBytes: Uint8Array;
29
+ }
30
+ /**
31
+ * Sender `A` (slot `i`) executes single-row dual-pad `GadgetMtA` over verified `KOS15` rows,
32
+ * anchored to Round-1 Pedersen commitment `C_{k,i} = k_i G + \rho_{k,i} H`.
33
+ * Returns additive share `u_A \in Z_n` such that `u_A + v_B === k_i * \beta_j (mod n)`.
34
+ */
35
+ declare function gadgetMtaSenderCreateMessage(params: {
36
+ ctxMta: Uint8Array;
37
+ senderSlotA: number;
38
+ receiverSlotB: number;
39
+ verifiedSenderRows: VerifiedCotSenderRows;
40
+ alphaScalar: bigint;
41
+ rhoAlphaScalar: bigint;
42
+ expectedRound1CommitmentCk: Uint8Array;
43
+ rng?: RandomBytesFn;
44
+ }): {
45
+ senderShareModN: bigint;
46
+ payload: GadgetMtaPayload;
47
+ };
48
+ /**
49
+ * Receiver `B` (slot `j`) verifies `C_alpha === C_{k,i}` (Round-1 commitment binding),
50
+ * checks the Pedersen linear combination `\alpha^* G + \rho^* H == \eta C_{k,i} + \hat{C}_\alpha`,
51
+ * verifies all 768 single-row dual-pad equations `\eta t_l + \hat{t}_l == r^*_l + b_l \alpha^* (mod n)`,
52
+ * and outputs additive share `v_B \in Z_n`.
53
+ */
54
+ declare function gadgetMtaReceiverVerifyAndFinish(params: {
55
+ ctxMta: Uint8Array;
56
+ senderSlotA: number;
57
+ receiverSlotB: number;
58
+ verifiedReceiverRows: VerifiedCotReceiverRows;
59
+ expectedRound1CommitmentCk: Uint8Array;
60
+ payload: GadgetMtaPayload;
61
+ }): bigint;
62
+ //#endregion
63
+ export { GadgetMtaPayload, decomposeScalarWithLhlGadget, deriveDualPadFromCotRow, gadgetMtaReceiverVerifyAndFinish, gadgetMtaSenderCreateMessage, getGadgetVector768, recombineGadgetBitsModN };