@ocap/mpc-hsm 0.0.0-stage → 1.33.7
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/esm/bip39-english-wordlist.d.mts +11 -0
- package/esm/bip39-english-wordlist.mjs +31 -0
- package/esm/constants.d.mts +140 -0
- package/esm/constants.mjs +142 -0
- package/esm/dkg.d.mts +279 -0
- package/esm/dkg.mjs +903 -0
- package/esm/index.d.mts +17 -0
- package/esm/index.mjs +18 -0
- package/esm/mta.d.mts +63 -0
- package/esm/mta.mjs +275 -0
- package/esm/ocap-clear-signing.d.mts +125 -0
- package/esm/ocap-clear-signing.mjs +1170 -0
- package/esm/offline-ceremony.d.mts +127 -0
- package/esm/offline-ceremony.mjs +481 -0
- package/esm/ot.d.mts +193 -0
- package/esm/ot.mjs +726 -0
- package/esm/personal-vault.d.mts +1292 -0
- package/esm/personal-vault.mjs +3615 -0
- package/esm/personal.d.mts +10 -0
- package/esm/personal.mjs +11 -0
- package/esm/presign.d.mts +242 -0
- package/esm/presign.mjs +951 -0
- package/esm/rlp-eip1559.d.mts +75 -0
- package/esm/rlp-eip1559.mjs +293 -0
- package/esm/secp256k1-scalar.d.mts +141 -0
- package/esm/secp256k1-scalar.mjs +474 -0
- package/esm/sign.d.mts +113 -0
- package/esm/sign.mjs +225 -0
- package/esm/steel-mnemonic.d.mts +55 -0
- package/esm/steel-mnemonic.mjs +247 -0
- package/esm/tweak.d.mts +100 -0
- package/esm/tweak.mjs +168 -0
- package/esm/ves-backup.d.mts +296 -0
- package/esm/ves-backup.mjs +1025 -0
- package/esm/x402-agent-guard.d.mts +111 -0
- package/esm/x402-agent-guard.mjs +780 -0
- package/lib/bip39-english-wordlist.cjs +33 -0
- package/lib/bip39-english-wordlist.d.cts +11 -0
- package/lib/constants.cjs +264 -0
- package/lib/constants.d.cts +140 -0
- package/lib/dkg.cjs +910 -0
- package/lib/dkg.d.cts +279 -0
- package/lib/index.cjs +420 -0
- package/lib/index.d.cts +17 -0
- package/lib/mta.cjs +280 -0
- package/lib/mta.d.cts +63 -0
- package/lib/ocap-clear-signing.cjs +1176 -0
- package/lib/ocap-clear-signing.d.cts +125 -0
- package/lib/offline-ceremony.cjs +487 -0
- package/lib/offline-ceremony.d.cts +127 -0
- package/lib/ot.cjs +744 -0
- package/lib/ot.d.cts +193 -0
- package/lib/personal-vault.cjs +3725 -0
- package/lib/personal-vault.d.cts +1292 -0
- package/lib/personal.cjs +338 -0
- package/lib/personal.d.cts +10 -0
- package/lib/presign.cjs +954 -0
- package/lib/presign.d.cts +242 -0
- package/lib/rlp-eip1559.cjs +303 -0
- package/lib/rlp-eip1559.d.cts +75 -0
- package/lib/secp256k1-scalar.cjs +527 -0
- package/lib/secp256k1-scalar.d.cts +141 -0
- package/lib/sign.cjs +233 -0
- package/lib/sign.d.cts +113 -0
- package/lib/steel-mnemonic.cjs +253 -0
- package/lib/steel-mnemonic.d.cts +55 -0
- package/lib/tweak.cjs +178 -0
- package/lib/tweak.d.cts +100 -0
- package/lib/ves-backup.cjs +1053 -0
- package/lib/ves-backup.d.cts +296 -0
- package/lib/x402-agent-guard.cjs +788 -0
- package/lib/x402-agent-guard.d.cts +111 -0
- package/package.json +80 -4
- package/README.md +0 -3
package/lib/ot.d.cts
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { RandomBytesFn, SchnorrPokProof } from "./secp256k1-scalar.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/ot.d.ts
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Active-secure IKNP / `KOS15` 1024-row (`768` gadget + `256` sacrifice) OT-Extension
|
|
7
|
+
* with exact inverted Base-OT role orientation (`design.md` §4.4):
|
|
8
|
+
*
|
|
9
|
+
* - **Extended-OT Receiver `B`** (who chooses choice bits `b_0..b_{1023}`) acts as the
|
|
10
|
+
* **Base-OT Sender**, holding `BaseOtSenderState` with 128 seed pairs `(k_{m,0}, k_{m,1})`.
|
|
11
|
+
* - **Extended-OT Sender `A`** (who inputs scalar `k_i`) samples correlation `Delta` (`128` bits)
|
|
12
|
+
* and acts as the **Base-OT Receiver**, holding `BaseOtReceiverState` with `Delta` and ONLY
|
|
13
|
+
* the 128 chosen seeds `k_{m, Delta_m}` (`k_{m, 1 - Delta_m}` is completely unknown to `A`).
|
|
14
|
+
*/
|
|
15
|
+
interface BaseOtSenderState {
|
|
16
|
+
readonly ownerSlotB: number;
|
|
17
|
+
readonly peerSlotA: number;
|
|
18
|
+
readonly ctxBaseOt: Uint8Array;
|
|
19
|
+
readonly seedPairs: ReadonlyArray<readonly [Uint8Array, Uint8Array]>;
|
|
20
|
+
readonly usedSessionKeys: Set<string>;
|
|
21
|
+
invalidated: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface BaseOtReceiverState {
|
|
24
|
+
readonly ownerSlotA: number;
|
|
25
|
+
readonly peerSlotB: number;
|
|
26
|
+
readonly ctxBaseOt: Uint8Array;
|
|
27
|
+
readonly deltaBytes16: Uint8Array;
|
|
28
|
+
readonly deltaBits128: Uint8Array;
|
|
29
|
+
readonly chosenSeeds: ReadonlyArray<Uint8Array>;
|
|
30
|
+
readonly usedSessionKeys: Set<string>;
|
|
31
|
+
invalidated: boolean;
|
|
32
|
+
}
|
|
33
|
+
interface BaseOtStep1Message {
|
|
34
|
+
readonly senderSlotB: number;
|
|
35
|
+
readonly receiverSlotA: number;
|
|
36
|
+
readonly sPointComp33: Uint8Array;
|
|
37
|
+
readonly pokS: SchnorrPokProof;
|
|
38
|
+
}
|
|
39
|
+
interface BaseOtSenderPendingSession {
|
|
40
|
+
readonly senderSlotB: number;
|
|
41
|
+
readonly receiverSlotA: number;
|
|
42
|
+
readonly ctxBaseOt: Uint8Array;
|
|
43
|
+
readonly yScalarBytes32: Uint8Array;
|
|
44
|
+
readonly sPointComp33: Uint8Array;
|
|
45
|
+
completed: boolean;
|
|
46
|
+
}
|
|
47
|
+
interface BaseOtStep2Message {
|
|
48
|
+
readonly senderSlotB: number;
|
|
49
|
+
readonly receiverSlotA: number;
|
|
50
|
+
readonly rPointsComp33: ReadonlyArray<Uint8Array>;
|
|
51
|
+
}
|
|
52
|
+
declare function wipeBaseOtSenderState(state: BaseOtSenderState): void;
|
|
53
|
+
declare function wipeBaseOtReceiverState(state: BaseOtReceiverState): void;
|
|
54
|
+
declare function baseOtSenderStep1(params: {
|
|
55
|
+
ctxBaseOt: Uint8Array;
|
|
56
|
+
senderSlotB: number;
|
|
57
|
+
receiverSlotA: number;
|
|
58
|
+
rng?: RandomBytesFn;
|
|
59
|
+
}): {
|
|
60
|
+
pending: BaseOtSenderPendingSession;
|
|
61
|
+
message: BaseOtStep1Message;
|
|
62
|
+
};
|
|
63
|
+
declare function baseOtReceiverStep2(params: {
|
|
64
|
+
ctxBaseOt: Uint8Array;
|
|
65
|
+
senderSlotB: number;
|
|
66
|
+
receiverSlotA: number;
|
|
67
|
+
step1Message: BaseOtStep1Message;
|
|
68
|
+
rng?: RandomBytesFn;
|
|
69
|
+
}): {
|
|
70
|
+
receiverState: BaseOtReceiverState;
|
|
71
|
+
message: BaseOtStep2Message;
|
|
72
|
+
};
|
|
73
|
+
declare function baseOtSenderStep3(params: {
|
|
74
|
+
pending: BaseOtSenderPendingSession;
|
|
75
|
+
step2Message: BaseOtStep2Message;
|
|
76
|
+
}): BaseOtSenderState;
|
|
77
|
+
/**
|
|
78
|
+
* Pure synchronous FIPS-197 AES-256 single-block encryption (`16B` plaintext -> `16B` ciphertext).
|
|
79
|
+
* Zeroizes expanded round keys immediately in `finally`.
|
|
80
|
+
*/
|
|
81
|
+
declare function aes256EncryptBlock(key32: Uint8Array, block16: Uint8Array): Uint8Array;
|
|
82
|
+
declare function expandColumnPrgAes256Ctr(seed32: Uint8Array, ctxOtExt: Uint8Array, mtaNonce: Uint8Array, columnIndex: number): Uint8Array;
|
|
83
|
+
declare function bytes16ToU128LE(bytes16: Uint8Array, offset?: number): bigint;
|
|
84
|
+
declare function u128ToBytes16LE(value: bigint): Uint8Array;
|
|
85
|
+
/**
|
|
86
|
+
* Eklundh recursive butterfly `128 x 1024` bit-matrix transpose (`7` log-stages per `128 x 128`
|
|
87
|
+
* sub-block, zero data-dependent branches).
|
|
88
|
+
*
|
|
89
|
+
* Input: `128` columns (`m = 0..127`), each `128` bytes (`1024` bits LSB-first).
|
|
90
|
+
* Output: `1024` rows (`l = 0..1023`), each `16` bytes (`128` bits LSB-first), where
|
|
91
|
+
* bit `m` of `rows[l]` equals bit `l` of `columns[m]`.
|
|
92
|
+
*/
|
|
93
|
+
declare function eklundhTranspose128x1024(columns: ReadonlyArray<Uint8Array>): Uint8Array[];
|
|
94
|
+
declare function gf128Mul(a: bigint, b: bigint): bigint;
|
|
95
|
+
declare function expandKos15ChiWeights(ctxOtExt: Uint8Array, mtaNonce: Uint8Array, xiSeed32: Uint8Array, culpritSlot?: number): bigint[];
|
|
96
|
+
interface OtExtStep1Message {
|
|
97
|
+
readonly mtaNonce: Uint8Array;
|
|
98
|
+
readonly uColumns: ReadonlyArray<Uint8Array>;
|
|
99
|
+
}
|
|
100
|
+
interface OtExtStep2Message {
|
|
101
|
+
readonly mtaNonce: Uint8Array;
|
|
102
|
+
readonly xiSeed32: Uint8Array;
|
|
103
|
+
}
|
|
104
|
+
interface OtExtStep3Message {
|
|
105
|
+
readonly mtaNonce: Uint8Array;
|
|
106
|
+
readonly xBytes16: Uint8Array;
|
|
107
|
+
readonly tChkBytes16: Uint8Array;
|
|
108
|
+
}
|
|
109
|
+
interface OtExtReceiverPendingState {
|
|
110
|
+
readonly ctxOtExt: Uint8Array;
|
|
111
|
+
readonly mtaNonce: Uint8Array;
|
|
112
|
+
readonly allChoiceBits1024: Uint8Array;
|
|
113
|
+
readonly tRows1024: Uint8Array[];
|
|
114
|
+
completed: boolean;
|
|
115
|
+
}
|
|
116
|
+
interface OtExtSenderPendingState {
|
|
117
|
+
readonly baseOtReceiver: BaseOtReceiverState;
|
|
118
|
+
readonly ctxOtExt: Uint8Array;
|
|
119
|
+
readonly mtaNonce: Uint8Array;
|
|
120
|
+
readonly xiSeed32: Uint8Array;
|
|
121
|
+
readonly qRows1024: Uint8Array[];
|
|
122
|
+
completed: boolean;
|
|
123
|
+
}
|
|
124
|
+
interface VerifiedCotReceiverRows {
|
|
125
|
+
readonly ctxOtExt: Uint8Array;
|
|
126
|
+
readonly mtaNonce: Uint8Array;
|
|
127
|
+
readonly gadgetChoiceBits768: Uint8Array;
|
|
128
|
+
readonly tRows768: ReadonlyArray<Uint8Array>;
|
|
129
|
+
}
|
|
130
|
+
interface VerifiedCotSenderRows {
|
|
131
|
+
readonly ctxOtExt: Uint8Array;
|
|
132
|
+
readonly mtaNonce: Uint8Array;
|
|
133
|
+
readonly deltaBytes16: Uint8Array;
|
|
134
|
+
readonly qRows768: ReadonlyArray<Uint8Array>;
|
|
135
|
+
}
|
|
136
|
+
declare function wipeVerifiedCotReceiverRows(rows: VerifiedCotReceiverRows): void;
|
|
137
|
+
declare function wipeVerifiedCotSenderRows(rows: VerifiedCotSenderRows): void;
|
|
138
|
+
/**
|
|
139
|
+
* Step 1 (Extended Receiver `B`, holding `BaseOtSenderState`):
|
|
140
|
+
* Appends `256` fresh CSPRNG sacrifice bits to the `768` gadget choice bits, expands
|
|
141
|
+
* `(t^{(0)}_m, t^{(1)}_m)`, emits `u^{col}_m = t^{(0)}_m ^ t^{(1)}_m ^ b`, and transposes `T_0..T_{1023}`.
|
|
142
|
+
*/
|
|
143
|
+
declare function otExtendReceiverStep1(params: {
|
|
144
|
+
baseOtSender: BaseOtSenderState;
|
|
145
|
+
ctxOtExt: Uint8Array;
|
|
146
|
+
mtaNonce: Uint8Array;
|
|
147
|
+
gadgetChoiceBits768: Uint8Array;
|
|
148
|
+
rng?: RandomBytesFn;
|
|
149
|
+
}): {
|
|
150
|
+
pendingReceiver: OtExtReceiverPendingState;
|
|
151
|
+
step1Message: OtExtStep1Message;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Step 2 (Extended Sender `A`, holding `BaseOtReceiverState`):
|
|
155
|
+
* Receives `B`'s committed columns `uColumns`, expands `z^{col}_m` from `k_{m, Delta_m}`,
|
|
156
|
+
* computes `q^{col}_m = z^{col}_m ^ (Delta_m * u^{col}_m)`, transposes `Q_0..Q_{1023}`, and
|
|
157
|
+
* samples coin-toss challenge `xiSeed32` WITHOUT touching `k_i` or deriving any row pads.
|
|
158
|
+
*/
|
|
159
|
+
declare function otExtendSenderStep2(params: {
|
|
160
|
+
baseOtReceiver: BaseOtReceiverState;
|
|
161
|
+
ctxOtExt: Uint8Array;
|
|
162
|
+
step1Message: OtExtStep1Message;
|
|
163
|
+
rng?: RandomBytesFn;
|
|
164
|
+
}): {
|
|
165
|
+
pendingSender: OtExtSenderPendingState;
|
|
166
|
+
step2Message: OtExtStep2Message;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Step 3 (Extended Receiver `B`):
|
|
170
|
+
* Computes `KOS15` correlation response `(x, T_chk)` over all `1024` rows (masked by the
|
|
171
|
+
* `256` sacrifice bits), wipes sacrifice rows `768..1023`, and returns the `768` gadget rows.
|
|
172
|
+
*/
|
|
173
|
+
declare function otExtendReceiverStep3(params: {
|
|
174
|
+
pendingReceiver: OtExtReceiverPendingState;
|
|
175
|
+
step2Message: OtExtStep2Message;
|
|
176
|
+
peerSenderSlotA?: number;
|
|
177
|
+
}): {
|
|
178
|
+
receiverRows: VerifiedCotReceiverRows;
|
|
179
|
+
step3Message: OtExtStep3Message;
|
|
180
|
+
};
|
|
181
|
+
/**
|
|
182
|
+
* Step 4 (Extended Sender `A`):
|
|
183
|
+
* Strictly verifies `KOS15` `GF(2^128)` correlation check `Q_chk == T_chk ^ (x * Delta)`
|
|
184
|
+
* **before** any pad `(r_{l,b}, r_hat_{l,b})` or MtA ciphertext `(u_l, u_hat_l, r_star_l)` can
|
|
185
|
+
* be computed. On mismatch, immediately zeroizes all `Q_l` AND permanently wipes/drops `Delta`
|
|
186
|
+
* (`BaseOtReceiverState`)!
|
|
187
|
+
*/
|
|
188
|
+
declare function otExtendSenderStep4VerifyBeforePads(params: {
|
|
189
|
+
pendingSender: OtExtSenderPendingState;
|
|
190
|
+
step3Message: OtExtStep3Message;
|
|
191
|
+
}): VerifiedCotSenderRows;
|
|
192
|
+
//#endregion
|
|
193
|
+
export { BaseOtReceiverState, BaseOtSenderPendingSession, BaseOtSenderState, BaseOtStep1Message, BaseOtStep2Message, OtExtReceiverPendingState, OtExtSenderPendingState, OtExtStep1Message, OtExtStep2Message, OtExtStep3Message, VerifiedCotReceiverRows, VerifiedCotSenderRows, aes256EncryptBlock, baseOtReceiverStep2, baseOtSenderStep1, baseOtSenderStep3, bytes16ToU128LE, eklundhTranspose128x1024, expandColumnPrgAes256Ctr, expandKos15ChiWeights, gf128Mul, otExtendReceiverStep1, otExtendReceiverStep3, otExtendSenderStep2, otExtendSenderStep4VerifyBeforePads, u128ToBytes16LE, wipeBaseOtReceiverState, wipeBaseOtSenderState, wipeVerifiedCotReceiverRows, wipeVerifiedCotSenderRows };
|