@obelyzk/sdk 0.5.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 +481 -0
- package/bin/bitsage-demo.ts +12 -0
- package/dist/chunk-3D3DPNVV.mjs +700 -0
- package/dist/chunk-CGPFHXUF.mjs +701 -0
- package/dist/chunk-F3E66KH7.mjs +683 -0
- package/dist/chunk-KRCKY3II.mjs +5857 -0
- package/dist/chunk-LXJT3QK6.mjs +5950 -0
- package/dist/chunk-O2PF7VJA.mjs +700 -0
- package/dist/index.d.mts +868 -0
- package/dist/index.d.ts +868 -0
- package/dist/index.js +7445 -0
- package/dist/index.mjs +853 -0
- package/dist/obelysk/index.d.mts +567 -0
- package/dist/obelysk/index.d.ts +567 -0
- package/dist/obelysk/index.js +1760 -0
- package/dist/obelysk/index.mjs +1449 -0
- package/dist/privacy/index.d.mts +408 -0
- package/dist/privacy/index.d.ts +408 -0
- package/dist/privacy/index.js +735 -0
- package/dist/privacy/index.mjs +44 -0
- package/dist/react/index.d.mts +1367 -0
- package/dist/react/index.d.ts +1367 -0
- package/dist/react/index.js +8442 -0
- package/dist/react/index.mjs +2600 -0
- package/dist/tee-BKXj7gQs.d.mts +4749 -0
- package/dist/tee-BKXj7gQs.d.ts +4749 -0
- package/dist/tee-BslKx4iU.d.mts +4749 -0
- package/dist/tee-BslKx4iU.d.ts +4749 -0
- package/dist/tee-CiR0hpfm.d.mts +4794 -0
- package/dist/tee-CiR0hpfm.d.ts +4794 -0
- package/package.json +101 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,868 @@
|
|
|
1
|
+
import { W as WsConfig, a as WebSocketClient, b as WsEvent, P as PrivacyKeyPair, E as ECPoint, c as ElGamalCiphertext, A as AEHint, d as EncryptedBalance, S as SchnorrProof, T as TransferProof } from './tee-CiR0hpfm.js';
|
|
2
|
+
export { cv as AccountHints, cz as AuditReport, ag as BatchClient, aS as BatchJobResponse, aV as BatchOperation, aU as BatchOperationType, bZ as BatchStatus, aT as BatchStatusResponse, aX as BatchVerifyRequest, aY as BatchVerifyResponse, B as BitSageClient, bH as BurnEvent, au as CAPABILITY_FLAGS, c6 as ChallengeParams, c7 as ChallengeStatus, cL as CheckpointStatus, C as ClientConfig, c4 as CompressedProof, c3 as CompressionStats, cK as ComputeCheckpoint, I as ContractClient, _ as ContractConfig, aa as ContractRegistry, bN as CreateProposalParams, co as DAILY_CAPS, D as DEFAULT_CONFIG, K as DEFAULT_CONTRACT_CONFIG, cP as DEFAULT_DISCOUNT_TIERS, cQ as DEFAULT_FEE_DISTRIBUTION, y as DEFAULT_HTTP_CONFIG, z as DEFAULT_WS_CONFIG, bs as DKGShare, ch as DailyStats, ae as DashboardClient, bP as DelegationInfo, cD as DiscountTiers, b7 as DisputeRecord, cR as DisputeStatus, bI as EcosystemEmissionStatus, c5 as EnclaveInfo, cT as ExecutionMetrics, ab as ExternalTokens, v as FaucetClaimResponse, F as FaucetStatus, cE as FeeDistribution, az as GOVERNANCE_CONFIG, cp as GPU_MULTIPLIERS, aW as GasEstimate, ax as GovernanceClient, bx as GovernanceClientConfig, bB as GovernanceProposal, bC as GovernanceRights, bD as GovernanceStats, by as GovernanceTransactionResult, ce as GpuAttestation, aI as GpuMetrics, aJ as GpuMetricsResponse, bY as GpuTeeProofParams, G as GpuTier, cq as HALVENING_SCHEDULE, aL as HistoryPeriod, b2 as HolderTier, H as HttpClient, U as HttpConfig, aO as JobAnalytics, J as JobId, cH as JobPaymentRecord, t as JobResult, i as JobStatus, s as JobStatusResponse, h as JobType, V as JobUpdateEvent, a3 as LOCAL_CONTRACTS, bg as LeaderboardEntry, bf as LeaderboardMetric, L as ListJobsParams, u as ListJobsResponse, a2 as MAINNET_CONTRACTS, a7 as MAINNET_TOKENS, ai as MAX_BATCH_SIZE, an as MIN_STAKE, bK as MilestoneStatus, ac as MiningClient, aF as MiningClientConfig, ck as MiningConfig, cm as MiningGpuTier, cj as MiningPoolStatus, bq as MixingOutput, bp as MixingTransaction, cy as MultiAssetBalance, bu as MultiAssetBalances, N as Network, o as NetworkStats, Y as NetworkStatsEvent, aR as NetworkWorkersResponse, cF as OTCConfig, a9 as PRAGMA_ORACLE, cC as PaymentQuote, cG as PaymentStats, cI as PaymentStatus, cB as PaymentToken, aj as PaymentsClient, aZ as PaymentsClientConfig, bM as PendingTransfer, be as PerformanceData, bE as PoolBalances, bk as PrivacyAsset, av as PrivacyClient, bi as PrivacyClientConfig, cM as PrivacyCreditDeposit, cN as PrivacyCreditUsage, bj as PrivacyTransactionResult, bl as PrivateAccount, bv as PrivateSwapParams, bm as PrivateTransferParams, bn as PrivateTransferWithAuditParams, cA as PrivateWorkerPayment, n as ProofDetails, b_ as ProofJobSpec, bX as ProofMetadata, c0 as ProofPriority, bU as ProofSource, c1 as ProofSubmission, b$ as ProofType, k as ProofVerificationStatus, Z as ProofVerifiedEvent, bz as ProposalStatus, bA as ProposalType, c2 as ProverMetrics, br as RagequitProof, bL as RateLimitInfo, aP as RecentJob, bh as RegisterWorkerParams, aM as RewardHistoryEntry, aN as RewardHistoryResponse, cl as RewardResult, aK as RewardsInfo, cw as RingMember, cx as RingSignature, a1 as SEPOLIA_CONTRACTS, a6 as SEPOLIA_TOKENS, ao as SLASH_PERCENTAGES, cn as STAKE_TIER_THRESHOLDS, cu as SameEncryption3Proof, e as SdkError, bG as SecurityBudget, b3 as SlashReason, b6 as SlashRecord, p as StakeInfo, cg as StakeTier, al as StakingClient, a_ as StakingClientConfig, b5 as StakingConfig, a$ as StakingTransactionResult, bw as StealthAddress, bo as SteganographicTransaction, aA as StwoClient, bR as StwoClientConfig, bV as StwoTeeType, bS as StwoTransactionResult, q as SubmitJobRequest, r as SubmitJobResponse, bW as TeeAttestation, cc as TeeChallengeParams, cd as TeeChallengeStatus, aD as TeeClient, c8 as TeeClientConfig, cb as TeeJobResult, cS as TeeQuote, ca as TeeResultParams, c9 as TeeTransactionResult, b0 as TeeType, bt as ThresholdDecryptionRequest, bJ as TokenFlowSummary, $ as TransactionReceipt, cO as TransactionResult, a0 as TxStatus, ap as UNSTAKE_LOCKUP_SECS, b9 as UnstakeRequest, aC as VERIFICATION_CONFIG, aG as ValidatorStatus, aH as ValidatorStatusResponse, cJ as VerificationSource, bT as VerificationStatus, bF as VestingStatus, bO as VoteDirection, bQ as VoterInfo, f as WalletConfig, l as WorkerCapabilities, bc as WorkerCapabilitiesExtended, g as WorkerId, m as WorkerInfo, ci as WorkerMiningStats, bd as WorkerProfile, b4 as WorkerStake, j as WorkerStatus, aQ as WorkerSummary, cf as WorkerTeeStatus, b1 as WorkerTier, b8 as WorkerTierBenefits, X as WorkerUpdateEvent, as as WorkersClient, ba as WorkersClientConfig, bb as WorkersTransactionResult, ah as createBatchClient, af as createDashboardClient, ay as createGovernanceClient, ad as createMiningClient, ak as createPaymentsClient, aw as createPrivacyClient, am as createStakingClient, aB as createStwoClient, aE as createTeeClient, at as createWorkersClient, O as fromFelt, a4 as getContractsForNetwork, cs as getDailyCapForTier, ct as getGpuMultiplier, x as getGpuTier, w as getMinStake, ar as getMinStakeForTier, cr as getStakeTierFromAmount, a8 as getTokensForNetwork, a5 as isContractConfigured, aq as isWorkerEligible, R as joinU256, Q as splitU256, M as toFelt } from './tee-CiR0hpfm.js';
|
|
3
|
+
export { AssetId, BalanceProof, CURVE_ORDER, ConfidentialOrder, ConfidentialSwapClient, ConfidentialSwapConfig, CreateOrderRequest, CreateOrderResponse, ElGamalKeyPair, FIELD_PRIME, GENERATOR_G, GENERATOR_H, ElGamalCiphertext as ObelyskCiphertext, EncryptionProof as ObelyskEncryptionProof, default as ObelyskPrivacy, RangeProof, RateProof, SwapHistoryEntry, SwapProofBundle, TakeOrderResponse, addMod, ecAdd, ecDouble, ecMul, invMod, isIdentity, mulMod, poseidonHash, powMod, randomScalar, subMod } from './privacy/index.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* WebSocket Module
|
|
7
|
+
* Re-exports WebSocket client with additional convenience methods
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Create a WebSocket client with default configuration
|
|
12
|
+
*/
|
|
13
|
+
declare function createWebSocketClient(config?: Partial<WsConfig>): WebSocketClient;
|
|
14
|
+
/**
|
|
15
|
+
* WebSocket hook result for React integration
|
|
16
|
+
*/
|
|
17
|
+
interface UseWebSocketResult<T extends WsEvent> {
|
|
18
|
+
/** Latest event */
|
|
19
|
+
event: T | null;
|
|
20
|
+
/** Connection status */
|
|
21
|
+
isConnected: boolean;
|
|
22
|
+
/** Error if any */
|
|
23
|
+
error: Error | null;
|
|
24
|
+
/** Unsubscribe function */
|
|
25
|
+
unsubscribe: () => void;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Privacy Key Management
|
|
30
|
+
* Handles generation, derivation, and secure storage of privacy keys
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/** Key storage configuration */
|
|
34
|
+
interface KeyStorageConfig {
|
|
35
|
+
/** Storage key prefix */
|
|
36
|
+
prefix?: string;
|
|
37
|
+
/** Use secure storage (Web Crypto) */
|
|
38
|
+
useSecureStorage?: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** Derived key info */
|
|
41
|
+
interface DerivedKeyInfo {
|
|
42
|
+
/** Public key */
|
|
43
|
+
publicKey: ECPoint;
|
|
44
|
+
/** Key derivation path */
|
|
45
|
+
derivationPath: string;
|
|
46
|
+
/** Key index */
|
|
47
|
+
index: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Privacy Key Manager
|
|
51
|
+
*
|
|
52
|
+
* Handles all privacy key operations:
|
|
53
|
+
* - Secure key generation using Web Crypto
|
|
54
|
+
* - Deterministic derivation from wallet signatures
|
|
55
|
+
* - Encrypted local storage
|
|
56
|
+
* - Key rotation support
|
|
57
|
+
*
|
|
58
|
+
* SECURITY: Private keys are never exposed as strings.
|
|
59
|
+
* All cryptographic operations are performed via WASM.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* // Generate fresh keypair
|
|
64
|
+
* const keyPair = await PrivacyKeyManager.generate();
|
|
65
|
+
*
|
|
66
|
+
* // Derive from wallet signature (deterministic)
|
|
67
|
+
* const signature = await wallet.signMessage('BitSage Privacy Key Derivation');
|
|
68
|
+
* const derived = await PrivacyKeyManager.deriveFromSignature(signature);
|
|
69
|
+
*
|
|
70
|
+
* // Store encrypted
|
|
71
|
+
* await PrivacyKeyManager.store(keyPair, 'user-password');
|
|
72
|
+
*
|
|
73
|
+
* // Retrieve later
|
|
74
|
+
* const retrieved = await PrivacyKeyManager.retrieve('user-password');
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
declare class PrivacyKeyManager {
|
|
78
|
+
private static readonly STORAGE_KEY;
|
|
79
|
+
private static readonly SALT_KEY;
|
|
80
|
+
private static readonly KEY_VERSION;
|
|
81
|
+
/**
|
|
82
|
+
* Check if WASM crypto is available
|
|
83
|
+
*/
|
|
84
|
+
static isWasmAvailable(): boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Generate a fresh privacy keypair
|
|
87
|
+
*
|
|
88
|
+
* Uses Web Crypto API for secure random generation
|
|
89
|
+
*
|
|
90
|
+
* @returns New privacy keypair
|
|
91
|
+
*/
|
|
92
|
+
static generate(): Promise<PrivacyKeyPair>;
|
|
93
|
+
/**
|
|
94
|
+
* Derive privacy keypair from wallet signature
|
|
95
|
+
*
|
|
96
|
+
* This creates a deterministic keypair that can be recovered
|
|
97
|
+
* by signing the same message again.
|
|
98
|
+
*
|
|
99
|
+
* @param signature - Wallet signature of derivation message
|
|
100
|
+
* @returns Derived privacy keypair
|
|
101
|
+
*/
|
|
102
|
+
static deriveFromSignature(signature: string): Promise<PrivacyKeyPair>;
|
|
103
|
+
/**
|
|
104
|
+
* Derive multiple keypairs from a master signature
|
|
105
|
+
*
|
|
106
|
+
* @param signature - Master signature
|
|
107
|
+
* @param count - Number of keys to derive
|
|
108
|
+
* @returns Array of derived keys with paths
|
|
109
|
+
*/
|
|
110
|
+
static deriveMultiple(signature: string, count: number): Promise<DerivedKeyInfo[]>;
|
|
111
|
+
/**
|
|
112
|
+
* Store keypair encrypted in local storage
|
|
113
|
+
*
|
|
114
|
+
* @param keyPair - Keypair to store
|
|
115
|
+
* @param password - Encryption password
|
|
116
|
+
* @param config - Storage configuration
|
|
117
|
+
*/
|
|
118
|
+
static store(keyPair: PrivacyKeyPair, password: string, config?: KeyStorageConfig): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Retrieve and decrypt keypair from local storage
|
|
121
|
+
*
|
|
122
|
+
* @param password - Decryption password
|
|
123
|
+
* @param config - Storage configuration
|
|
124
|
+
* @returns Keypair or null if not found
|
|
125
|
+
*/
|
|
126
|
+
static retrieve(password: string, config?: KeyStorageConfig): Promise<PrivacyKeyPair | null>;
|
|
127
|
+
/**
|
|
128
|
+
* Check if a keypair is stored
|
|
129
|
+
*
|
|
130
|
+
* @param config - Storage configuration
|
|
131
|
+
* @returns Whether a keypair exists
|
|
132
|
+
*/
|
|
133
|
+
static hasStoredKey(config?: KeyStorageConfig): boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Clear stored keypair
|
|
136
|
+
*
|
|
137
|
+
* @param config - Storage configuration
|
|
138
|
+
*/
|
|
139
|
+
static clear(config?: KeyStorageConfig): void;
|
|
140
|
+
/**
|
|
141
|
+
* Export public key as hex string
|
|
142
|
+
*
|
|
143
|
+
* @param publicKey - Public key to export
|
|
144
|
+
* @returns Hex string representation
|
|
145
|
+
*/
|
|
146
|
+
static exportPublicKey(publicKey: ECPoint): string;
|
|
147
|
+
/**
|
|
148
|
+
* Import public key from hex string
|
|
149
|
+
*
|
|
150
|
+
* @param hex - Hex string (uncompressed format: 04 + x + y)
|
|
151
|
+
* @returns Public key
|
|
152
|
+
*/
|
|
153
|
+
static importPublicKey(hex: string): ECPoint;
|
|
154
|
+
/**
|
|
155
|
+
* Derive public key from private key
|
|
156
|
+
*
|
|
157
|
+
* NOTE: This is a placeholder - actual implementation uses WASM.
|
|
158
|
+
* For production, this calls into the WASM crypto module.
|
|
159
|
+
*/
|
|
160
|
+
private static derivePublicKey;
|
|
161
|
+
/**
|
|
162
|
+
* Derive encryption key from password using PBKDF2
|
|
163
|
+
*/
|
|
164
|
+
private static deriveEncryptionKey;
|
|
165
|
+
/**
|
|
166
|
+
* Convert ArrayBuffer or Uint8Array to base64 string
|
|
167
|
+
*/
|
|
168
|
+
private static arrayBufferToBase64;
|
|
169
|
+
/**
|
|
170
|
+
* Convert base64 string to ArrayBuffer
|
|
171
|
+
*/
|
|
172
|
+
private static base64ToArrayBuffer;
|
|
173
|
+
/**
|
|
174
|
+
* Convert ArrayBuffer to BigInt
|
|
175
|
+
*/
|
|
176
|
+
private static arrayBufferToBigInt;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Get the standard derivation message for wallet signing
|
|
180
|
+
*/
|
|
181
|
+
declare function getPrivacyDerivationMessage(address: string, nonce?: number): string;
|
|
182
|
+
/**
|
|
183
|
+
* Validate a public key point (basic validation)
|
|
184
|
+
*/
|
|
185
|
+
declare function isValidPublicKey(publicKey: ECPoint): boolean;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Privacy Encryption Helpers
|
|
189
|
+
* ElGamal encryption, decryption, and homomorphic operations
|
|
190
|
+
*/
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Encryption helper class
|
|
194
|
+
*
|
|
195
|
+
* Provides utilities for:
|
|
196
|
+
* - ElGamal encryption/decryption
|
|
197
|
+
* - Homomorphic operations (add encrypted values)
|
|
198
|
+
* - Proof generation helpers
|
|
199
|
+
*
|
|
200
|
+
* NOTE: Most cryptographic operations should use WASM in production.
|
|
201
|
+
* These TypeScript implementations are for prototyping and fallback.
|
|
202
|
+
*/
|
|
203
|
+
declare class EncryptionHelper {
|
|
204
|
+
/**
|
|
205
|
+
* Encrypt an amount using ElGamal
|
|
206
|
+
*
|
|
207
|
+
* @param amount - Amount to encrypt (plaintext)
|
|
208
|
+
* @param publicKey - Recipient's public key
|
|
209
|
+
* @param randomness - Random value for encryption (optional)
|
|
210
|
+
* @returns ElGamal ciphertext
|
|
211
|
+
*/
|
|
212
|
+
static encrypt(amount: bigint, publicKey: ECPoint, randomness?: bigint): ElGamalCiphertext;
|
|
213
|
+
/**
|
|
214
|
+
* Decrypt a ciphertext using private key
|
|
215
|
+
*
|
|
216
|
+
* NOTE: This performs ECDLP which is only feasible for small values.
|
|
217
|
+
* In production, use AE hints for fast decryption.
|
|
218
|
+
*
|
|
219
|
+
* @param ciphertext - ElGamal ciphertext
|
|
220
|
+
* @param privateKey - Decryption private key
|
|
221
|
+
* @param maxValue - Maximum expected value (for baby-step giant-step)
|
|
222
|
+
* @returns Decrypted amount or null if ECDLP fails
|
|
223
|
+
*/
|
|
224
|
+
static decrypt(ciphertext: ElGamalCiphertext, privateKey: Uint8Array, maxValue?: bigint): bigint | null;
|
|
225
|
+
/**
|
|
226
|
+
* Decrypt using AE hint (fast method)
|
|
227
|
+
*
|
|
228
|
+
* @param ciphertext - ElGamal ciphertext
|
|
229
|
+
* @param hint - AE hint for fast decryption
|
|
230
|
+
* @param privateKey - Private key
|
|
231
|
+
* @returns Decrypted amount
|
|
232
|
+
*/
|
|
233
|
+
static decryptWithHint(ciphertext: ElGamalCiphertext, hint: AEHint, privateKey: Uint8Array): bigint;
|
|
234
|
+
/**
|
|
235
|
+
* Add two encrypted values homomorphically
|
|
236
|
+
*
|
|
237
|
+
* @param a - First ciphertext
|
|
238
|
+
* @param b - Second ciphertext
|
|
239
|
+
* @returns Sum ciphertext (encrypts a + b)
|
|
240
|
+
*/
|
|
241
|
+
static homomorphicAdd(a: ElGamalCiphertext, b: ElGamalCiphertext): ElGamalCiphertext;
|
|
242
|
+
/**
|
|
243
|
+
* Subtract encrypted values homomorphically
|
|
244
|
+
*
|
|
245
|
+
* @param a - First ciphertext
|
|
246
|
+
* @param b - Second ciphertext
|
|
247
|
+
* @returns Difference ciphertext (encrypts a - b)
|
|
248
|
+
*/
|
|
249
|
+
static homomorphicSub(a: ElGamalCiphertext, b: ElGamalCiphertext): ElGamalCiphertext;
|
|
250
|
+
/**
|
|
251
|
+
* Multiply encrypted value by scalar
|
|
252
|
+
*
|
|
253
|
+
* @param ciphertext - Input ciphertext
|
|
254
|
+
* @param scalar - Scalar multiplier
|
|
255
|
+
* @returns Scaled ciphertext (encrypts amount * scalar)
|
|
256
|
+
*/
|
|
257
|
+
static homomorphicMul(ciphertext: ElGamalCiphertext, scalar: bigint): ElGamalCiphertext;
|
|
258
|
+
/**
|
|
259
|
+
* Create zero ciphertext (encrypts 0)
|
|
260
|
+
*
|
|
261
|
+
* @param publicKey - Public key for encryption
|
|
262
|
+
* @param randomness - Optional randomness
|
|
263
|
+
* @returns Ciphertext encrypting zero
|
|
264
|
+
*/
|
|
265
|
+
static encryptZero(publicKey: ECPoint, randomness?: bigint): ElGamalCiphertext;
|
|
266
|
+
/**
|
|
267
|
+
* Re-randomize a ciphertext (changes randomness without changing plaintext)
|
|
268
|
+
*
|
|
269
|
+
* @param ciphertext - Input ciphertext
|
|
270
|
+
* @param publicKey - Public key
|
|
271
|
+
* @param newRandomness - New random value
|
|
272
|
+
* @returns Re-randomized ciphertext
|
|
273
|
+
*/
|
|
274
|
+
static reRandomize(ciphertext: ElGamalCiphertext, publicKey: ECPoint, newRandomness?: bigint): ElGamalCiphertext;
|
|
275
|
+
/**
|
|
276
|
+
* Create an empty encrypted balance
|
|
277
|
+
*
|
|
278
|
+
* @param publicKey - Account public key
|
|
279
|
+
* @returns Empty encrypted balance
|
|
280
|
+
*/
|
|
281
|
+
static createEmptyBalance(publicKey: ECPoint): EncryptedBalance;
|
|
282
|
+
/**
|
|
283
|
+
* Compute balance after settling pending operations
|
|
284
|
+
*
|
|
285
|
+
* @param balance - Current encrypted balance
|
|
286
|
+
* @returns Settled balance ciphertext
|
|
287
|
+
*/
|
|
288
|
+
static settleBalance(balance: EncryptedBalance): ElGamalCiphertext;
|
|
289
|
+
/**
|
|
290
|
+
* Generate a random scalar in the curve order
|
|
291
|
+
*/
|
|
292
|
+
static generateRandomScalar(): bigint;
|
|
293
|
+
/**
|
|
294
|
+
* Generate AE hint for fast decryption
|
|
295
|
+
*
|
|
296
|
+
* @param amount - Plaintext amount
|
|
297
|
+
* @param privateKey - Private key
|
|
298
|
+
* @param ciphertext - Corresponding ciphertext
|
|
299
|
+
* @returns AE hint
|
|
300
|
+
*/
|
|
301
|
+
static generateAEHint(amount: bigint, privateKey: Uint8Array, ciphertext: ElGamalCiphertext): AEHint;
|
|
302
|
+
/**
|
|
303
|
+
* Create a Schnorr proof of knowledge of discrete log
|
|
304
|
+
*
|
|
305
|
+
* Proves knowledge of x such that P = x * G
|
|
306
|
+
*
|
|
307
|
+
* @param privateKey - Secret x
|
|
308
|
+
* @param publicPoint - Public P = x * G
|
|
309
|
+
* @param context - Context string for challenge
|
|
310
|
+
* @returns Schnorr proof
|
|
311
|
+
*/
|
|
312
|
+
static createSchnorrProof(privateKey: Uint8Array, publicPoint: ECPoint, context: string): SchnorrProof;
|
|
313
|
+
/**
|
|
314
|
+
* Verify a Schnorr proof
|
|
315
|
+
*
|
|
316
|
+
* @param proof - Schnorr proof
|
|
317
|
+
* @param publicPoint - Claimed public point
|
|
318
|
+
* @param context - Context string
|
|
319
|
+
* @returns Whether proof is valid
|
|
320
|
+
*/
|
|
321
|
+
static verifySchnorrProof(proof: SchnorrProof, publicPoint: ECPoint, context: string): boolean;
|
|
322
|
+
/**
|
|
323
|
+
* Create a nullifier for a transfer
|
|
324
|
+
*
|
|
325
|
+
* @param privateKey - Sender's private key
|
|
326
|
+
* @param txData - Transaction data
|
|
327
|
+
* @returns Nullifier
|
|
328
|
+
*/
|
|
329
|
+
static createNullifier(privateKey: Uint8Array, txData: string): bigint;
|
|
330
|
+
/**
|
|
331
|
+
* Scalar multiplication: P = k * G
|
|
332
|
+
*
|
|
333
|
+
* NOTE: Placeholder - use WASM in production
|
|
334
|
+
*/
|
|
335
|
+
static scalarMul(point: ECPoint, scalar: bigint): ECPoint;
|
|
336
|
+
/**
|
|
337
|
+
* Point addition: P = P1 + P2
|
|
338
|
+
*
|
|
339
|
+
* NOTE: Placeholder - use WASM in production
|
|
340
|
+
*/
|
|
341
|
+
static pointAdd(p1: ECPoint, p2: ECPoint): ECPoint;
|
|
342
|
+
/**
|
|
343
|
+
* Point negation: -P
|
|
344
|
+
*/
|
|
345
|
+
static pointNeg(point: ECPoint): ECPoint;
|
|
346
|
+
/**
|
|
347
|
+
* Check if two points are equal
|
|
348
|
+
*/
|
|
349
|
+
static pointEquals(p1: ECPoint, p2: ECPoint): boolean;
|
|
350
|
+
/**
|
|
351
|
+
* Check if point is the identity (point at infinity)
|
|
352
|
+
*/
|
|
353
|
+
static isIdentity(point: ECPoint): boolean;
|
|
354
|
+
private static privateKeyToScalar;
|
|
355
|
+
private static bytesToBigInt;
|
|
356
|
+
private static computeChallenge;
|
|
357
|
+
private static hashString;
|
|
358
|
+
private static hashBigInt;
|
|
359
|
+
private static hashPoint;
|
|
360
|
+
/**
|
|
361
|
+
* Solve ECDLP using baby-step giant-step
|
|
362
|
+
* Only works for small values
|
|
363
|
+
*/
|
|
364
|
+
private static solveECDLP;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Create a transfer proof
|
|
368
|
+
*
|
|
369
|
+
* @param sender - Sender's keypair
|
|
370
|
+
* @param recipient - Recipient's public key
|
|
371
|
+
* @param amount - Transfer amount
|
|
372
|
+
* @param senderBalance - Sender's current balance
|
|
373
|
+
* @returns Transfer proof and new ciphertexts
|
|
374
|
+
*/
|
|
375
|
+
declare function createTransferProof(senderPrivateKey: Uint8Array, senderPublicKey: ECPoint, recipientPublicKey: ECPoint, amount: bigint, _senderBalance: EncryptedBalance): {
|
|
376
|
+
proof: TransferProof;
|
|
377
|
+
senderNewBalance: ElGamalCiphertext;
|
|
378
|
+
recipientAmount: ElGamalCiphertext;
|
|
379
|
+
nullifier: bigint;
|
|
380
|
+
};
|
|
381
|
+
/**
|
|
382
|
+
* Verify a transfer proof
|
|
383
|
+
*
|
|
384
|
+
* @param proof - Transfer proof
|
|
385
|
+
* @param senderPublicKey - Sender's public key
|
|
386
|
+
* @returns Whether proof is valid
|
|
387
|
+
*/
|
|
388
|
+
declare function verifyTransferProof(proof: TransferProof, senderPublicKey: ECPoint, _context: string): boolean;
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* STWO GPU Prover Client
|
|
392
|
+
*
|
|
393
|
+
* Enables GPU-accelerated proof generation for:
|
|
394
|
+
* - Batch payment aggregation
|
|
395
|
+
* - AI/ML inference verification
|
|
396
|
+
* - Cross-chain bridge proofs
|
|
397
|
+
* - Complex DeFi calculations
|
|
398
|
+
* - Gaming state verification
|
|
399
|
+
* - And more...
|
|
400
|
+
*
|
|
401
|
+
* @example
|
|
402
|
+
* ```typescript
|
|
403
|
+
* import { createStwoProverClient } from '@bitsage/sdk';
|
|
404
|
+
*
|
|
405
|
+
* const prover = createStwoProverClient({
|
|
406
|
+
* baseUrl: 'https://prover.bitsage.network',
|
|
407
|
+
* apiKey: 'your-api-key',
|
|
408
|
+
* });
|
|
409
|
+
*
|
|
410
|
+
* // Submit a proof generation job
|
|
411
|
+
* const job = await prover.submitProofJob({
|
|
412
|
+
* proofType: 'batch_payments',
|
|
413
|
+
* inputs: paymentData,
|
|
414
|
+
* priority: 'high',
|
|
415
|
+
* });
|
|
416
|
+
*
|
|
417
|
+
* // Wait for completion
|
|
418
|
+
* const result = await prover.waitForProof(job.jobId);
|
|
419
|
+
* console.log('Proof generated:', result.proofHash);
|
|
420
|
+
* ```
|
|
421
|
+
*/
|
|
422
|
+
type GpuTier = 'H100' | 'H200' | 'B200' | 'A100' | '4090' | 'auto';
|
|
423
|
+
type ProofJobPriority = 'standard' | 'high' | 'critical' | 'emergency';
|
|
424
|
+
type ProofJobStatus = 'queued' | 'assigned' | 'generating' | 'completed' | 'failed' | 'cancelled' | 'timeout';
|
|
425
|
+
type ProofType = 'batch_payments' | 'ai_inference' | 'cross_chain_bridge' | 'defi_calculation' | 'game_state' | 'vrf_randomness' | 'kyc_verification' | 'supply_chain' | 'recursive_aggregation' | 'custom';
|
|
426
|
+
interface StwoProverConfig {
|
|
427
|
+
/** Base URL of the STWO prover service */
|
|
428
|
+
baseUrl: string;
|
|
429
|
+
/** API key for authentication */
|
|
430
|
+
apiKey?: string;
|
|
431
|
+
/** Default GPU tier preference */
|
|
432
|
+
defaultGpuTier?: GpuTier;
|
|
433
|
+
/** Default priority for jobs */
|
|
434
|
+
defaultPriority?: ProofJobPriority;
|
|
435
|
+
/** Request timeout in milliseconds */
|
|
436
|
+
timeout?: number;
|
|
437
|
+
/** Enable TEE for privacy */
|
|
438
|
+
requireTee?: boolean;
|
|
439
|
+
}
|
|
440
|
+
interface ProofJobRequest {
|
|
441
|
+
/** Type of proof to generate */
|
|
442
|
+
proofType: ProofType;
|
|
443
|
+
/** Public inputs for the circuit */
|
|
444
|
+
publicInputs: bigint[];
|
|
445
|
+
/** Private inputs (only sent if TEE enabled) */
|
|
446
|
+
privateInputs?: bigint[];
|
|
447
|
+
/** Custom circuit ID (for custom proof types) */
|
|
448
|
+
circuitId?: string;
|
|
449
|
+
/** Priority level */
|
|
450
|
+
priority?: ProofJobPriority;
|
|
451
|
+
/** GPU tier requirement */
|
|
452
|
+
gpuTier?: GpuTier;
|
|
453
|
+
/** Deadline timestamp (unix seconds) */
|
|
454
|
+
deadline?: number;
|
|
455
|
+
/** Require TEE for privacy */
|
|
456
|
+
requireTee?: boolean;
|
|
457
|
+
/** Maximum cost in USDC (will reject if exceeds) */
|
|
458
|
+
maxCostUsdc?: number;
|
|
459
|
+
/** Callback URL for completion notification */
|
|
460
|
+
callbackUrl?: string;
|
|
461
|
+
/** Metadata for tracking */
|
|
462
|
+
metadata?: Record<string, string>;
|
|
463
|
+
}
|
|
464
|
+
interface ProofJobResponse {
|
|
465
|
+
/** Unique job identifier */
|
|
466
|
+
jobId: string;
|
|
467
|
+
/** Current status */
|
|
468
|
+
status: ProofJobStatus;
|
|
469
|
+
/** Estimated cost in USDC */
|
|
470
|
+
estimatedCostUsdc: number;
|
|
471
|
+
/** Estimated time to completion in seconds */
|
|
472
|
+
estimatedTimeSecs: number;
|
|
473
|
+
/** Position in queue (if queued) */
|
|
474
|
+
queuePosition?: number;
|
|
475
|
+
/** Assigned GPU info */
|
|
476
|
+
assignedGpu?: {
|
|
477
|
+
tier: GpuTier;
|
|
478
|
+
workerId: string;
|
|
479
|
+
teeEnabled: boolean;
|
|
480
|
+
};
|
|
481
|
+
/** Timestamp when job was created */
|
|
482
|
+
createdAt: number;
|
|
483
|
+
}
|
|
484
|
+
interface ProofGenerationStatus {
|
|
485
|
+
/** Job identifier */
|
|
486
|
+
jobId: string;
|
|
487
|
+
/** Current status */
|
|
488
|
+
status: ProofJobStatus;
|
|
489
|
+
/** Progress in basis points (0-10000 = 0-100%) */
|
|
490
|
+
progressBps: number;
|
|
491
|
+
/** Estimated time remaining in seconds */
|
|
492
|
+
estimatedTimeRemainingSecs: number;
|
|
493
|
+
/** Current phase description */
|
|
494
|
+
currentPhase: string;
|
|
495
|
+
/** GPU utilization percentage */
|
|
496
|
+
gpuUtilization?: number;
|
|
497
|
+
/** Memory used in MB */
|
|
498
|
+
memoryUsedMb?: number;
|
|
499
|
+
/** Error message if failed */
|
|
500
|
+
errorMessage?: string;
|
|
501
|
+
/** Retry count */
|
|
502
|
+
retryCount: number;
|
|
503
|
+
}
|
|
504
|
+
interface ProofResult {
|
|
505
|
+
/** Job identifier */
|
|
506
|
+
jobId: string;
|
|
507
|
+
/** Proof hash */
|
|
508
|
+
proofHash: string;
|
|
509
|
+
/** Serialized proof data (hex encoded) */
|
|
510
|
+
proofData: string;
|
|
511
|
+
/** Public input hash */
|
|
512
|
+
publicInputHash: string;
|
|
513
|
+
/** Proof size in bytes */
|
|
514
|
+
proofSizeBytes: number;
|
|
515
|
+
/** Generation time in milliseconds */
|
|
516
|
+
generationTimeMs: number;
|
|
517
|
+
/** Actual cost in USDC */
|
|
518
|
+
costUsdc: number;
|
|
519
|
+
/** GPU that generated the proof */
|
|
520
|
+
gpuTier: GpuTier;
|
|
521
|
+
/** TEE attestation if applicable */
|
|
522
|
+
teeAttestation?: {
|
|
523
|
+
teeType: 'IntelTDX' | 'AMDSEVSNP' | 'NvidiaCC';
|
|
524
|
+
enclaveMeasurement: string;
|
|
525
|
+
quoteHash: string;
|
|
526
|
+
};
|
|
527
|
+
/** Verification status on-chain */
|
|
528
|
+
verificationStatus: 'pending' | 'verified' | 'failed';
|
|
529
|
+
/** Transaction hash if submitted on-chain */
|
|
530
|
+
txHash?: string;
|
|
531
|
+
}
|
|
532
|
+
interface BatchProofRequest {
|
|
533
|
+
/** Array of individual proof requests */
|
|
534
|
+
proofs: ProofJobRequest[];
|
|
535
|
+
/** Aggregate into single recursive proof */
|
|
536
|
+
aggregate?: boolean;
|
|
537
|
+
/** Priority for the batch */
|
|
538
|
+
priority?: ProofJobPriority;
|
|
539
|
+
/** Maximum total cost in USDC */
|
|
540
|
+
maxTotalCostUsdc?: number;
|
|
541
|
+
}
|
|
542
|
+
interface BatchProofResponse {
|
|
543
|
+
/** Batch identifier */
|
|
544
|
+
batchId: string;
|
|
545
|
+
/** Individual job IDs */
|
|
546
|
+
jobIds: string[];
|
|
547
|
+
/** Total estimated cost */
|
|
548
|
+
estimatedTotalCostUsdc: number;
|
|
549
|
+
/** Estimated time for entire batch */
|
|
550
|
+
estimatedTimeSecs: number;
|
|
551
|
+
/** Status of the batch */
|
|
552
|
+
status: 'queued' | 'processing' | 'completed' | 'partial_failure' | 'failed';
|
|
553
|
+
}
|
|
554
|
+
interface ProverMetrics {
|
|
555
|
+
/** Available GPU capacity */
|
|
556
|
+
availableGpus: {
|
|
557
|
+
tier: GpuTier;
|
|
558
|
+
count: number;
|
|
559
|
+
teeEnabled: number;
|
|
560
|
+
}[];
|
|
561
|
+
/** Current queue depth */
|
|
562
|
+
queueDepth: number;
|
|
563
|
+
/** Average wait time in seconds */
|
|
564
|
+
avgWaitTimeSecs: number;
|
|
565
|
+
/** Proofs generated in last hour */
|
|
566
|
+
proofsLastHour: number;
|
|
567
|
+
/** Network-wide utilization percentage */
|
|
568
|
+
networkUtilization: number;
|
|
569
|
+
/** Current pricing per proof type */
|
|
570
|
+
pricing: {
|
|
571
|
+
proofType: ProofType;
|
|
572
|
+
baseCostUsdc: number;
|
|
573
|
+
perConstraintUsdc: number;
|
|
574
|
+
}[];
|
|
575
|
+
}
|
|
576
|
+
interface ProofCostEstimate {
|
|
577
|
+
/** Estimated cost in USDC */
|
|
578
|
+
costUsdc: number;
|
|
579
|
+
/** Estimated time in seconds */
|
|
580
|
+
timeSecs: number;
|
|
581
|
+
/** Recommended GPU tier */
|
|
582
|
+
recommendedGpuTier: GpuTier;
|
|
583
|
+
/** Cost breakdown */
|
|
584
|
+
breakdown: {
|
|
585
|
+
baseCost: number;
|
|
586
|
+
constraintCost: number;
|
|
587
|
+
prioritySurcharge: number;
|
|
588
|
+
teeSurcharge: number;
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
declare const DEFAULT_PROVER_CONFIG: Partial<StwoProverConfig>;
|
|
592
|
+
declare class StwoProverClient {
|
|
593
|
+
private config;
|
|
594
|
+
constructor(config: StwoProverConfig);
|
|
595
|
+
/**
|
|
596
|
+
* Load an ONNX model on the prover server.
|
|
597
|
+
* Must be called before submitting proving jobs for that model.
|
|
598
|
+
*/
|
|
599
|
+
loadModel(request: {
|
|
600
|
+
modelPath: string;
|
|
601
|
+
description?: string;
|
|
602
|
+
}): Promise<ZkmlModelInfo>;
|
|
603
|
+
/**
|
|
604
|
+
* Submit a proof generation job to the GPU network
|
|
605
|
+
*/
|
|
606
|
+
submitProofJob(request: ProofJobRequest): Promise<ProofJobResponse>;
|
|
607
|
+
/**
|
|
608
|
+
* Get the current status of a proof generation job
|
|
609
|
+
*/
|
|
610
|
+
getJobStatus(jobId: string): Promise<ProofGenerationStatus>;
|
|
611
|
+
/**
|
|
612
|
+
* Get the completed proof result
|
|
613
|
+
*/
|
|
614
|
+
getProofResult(jobId: string): Promise<ProofResult>;
|
|
615
|
+
/**
|
|
616
|
+
* Cancel a pending proof job.
|
|
617
|
+
*
|
|
618
|
+
* @experimental prove-server does not currently implement a cancel endpoint.
|
|
619
|
+
* This method is provided for forward-compatibility with the coordinator API.
|
|
620
|
+
*/
|
|
621
|
+
cancelJob(jobId: string): Promise<boolean>;
|
|
622
|
+
/**
|
|
623
|
+
* Wait for a proof to complete (polling)
|
|
624
|
+
*/
|
|
625
|
+
waitForProof(jobId: string, options?: {
|
|
626
|
+
pollIntervalMs?: number;
|
|
627
|
+
timeoutMs?: number;
|
|
628
|
+
onProgress?: (status: ProofGenerationStatus) => void;
|
|
629
|
+
}): Promise<ProofResult>;
|
|
630
|
+
/**
|
|
631
|
+
* Submit multiple proofs as a batch (with optional aggregation).
|
|
632
|
+
*
|
|
633
|
+
* @experimental Not supported by prove-server. Requires coordinator API.
|
|
634
|
+
*/
|
|
635
|
+
submitBatch(request: BatchProofRequest): Promise<BatchProofResponse>;
|
|
636
|
+
/**
|
|
637
|
+
* Get batch status
|
|
638
|
+
*/
|
|
639
|
+
getBatchStatus(batchId: string): Promise<BatchProofResponse>;
|
|
640
|
+
/**
|
|
641
|
+
* Wait for entire batch to complete
|
|
642
|
+
*/
|
|
643
|
+
waitForBatch(batchId: string, options?: {
|
|
644
|
+
pollIntervalMs?: number;
|
|
645
|
+
timeoutMs?: number;
|
|
646
|
+
onProgress?: (completed: number, total: number) => void;
|
|
647
|
+
}): Promise<ProofResult[]>;
|
|
648
|
+
/**
|
|
649
|
+
* Estimate cost before submitting a job.
|
|
650
|
+
*
|
|
651
|
+
* @experimental Not supported by prove-server. Requires coordinator API.
|
|
652
|
+
*/
|
|
653
|
+
estimateCost(request: ProofJobRequest): Promise<ProofCostEstimate>;
|
|
654
|
+
/**
|
|
655
|
+
* Estimate batch cost
|
|
656
|
+
*/
|
|
657
|
+
estimateBatchCost(request: BatchProofRequest): Promise<{
|
|
658
|
+
totalCostUsdc: number;
|
|
659
|
+
individualCosts: ProofCostEstimate[];
|
|
660
|
+
aggregationSavings: number;
|
|
661
|
+
}>;
|
|
662
|
+
/**
|
|
663
|
+
* Get current network metrics and pricing.
|
|
664
|
+
*
|
|
665
|
+
* @experimental Not supported by prove-server. Requires coordinator API.
|
|
666
|
+
*/
|
|
667
|
+
getMetrics(): Promise<ProverMetrics>;
|
|
668
|
+
/**
|
|
669
|
+
* Get queue depth for planning.
|
|
670
|
+
*
|
|
671
|
+
* @experimental Not supported by prove-server. Requires coordinator API.
|
|
672
|
+
*/
|
|
673
|
+
getQueueDepth(): Promise<{
|
|
674
|
+
total: number;
|
|
675
|
+
byPriority: Record<ProofJobPriority, number>;
|
|
676
|
+
estimatedClearTimeSecs: number;
|
|
677
|
+
}>;
|
|
678
|
+
/**
|
|
679
|
+
* Generate proof for batch payments (optimized)
|
|
680
|
+
*/
|
|
681
|
+
proveBatchPayments(payments: Array<{
|
|
682
|
+
sender: string;
|
|
683
|
+
recipient: string;
|
|
684
|
+
amount: bigint;
|
|
685
|
+
asset: string;
|
|
686
|
+
}>, options?: {
|
|
687
|
+
priority?: ProofJobPriority;
|
|
688
|
+
requireTee?: boolean;
|
|
689
|
+
}): Promise<ProofResult>;
|
|
690
|
+
/**
|
|
691
|
+
* Generate proof for AI/ML inference
|
|
692
|
+
*/
|
|
693
|
+
proveInference(modelId: string, inputs: bigint[], outputs: bigint[], options?: {
|
|
694
|
+
priority?: ProofJobPriority;
|
|
695
|
+
requireTee?: boolean;
|
|
696
|
+
}): Promise<ProofResult>;
|
|
697
|
+
/**
|
|
698
|
+
* Generate VRF randomness proof
|
|
699
|
+
*/
|
|
700
|
+
proveRandomness(seed: bigint, count: number, options?: {
|
|
701
|
+
priority?: ProofJobPriority;
|
|
702
|
+
}): Promise<{
|
|
703
|
+
proof: ProofResult;
|
|
704
|
+
randomValues: bigint[];
|
|
705
|
+
}>;
|
|
706
|
+
/**
|
|
707
|
+
* Generate cross-chain bridge proof
|
|
708
|
+
*/
|
|
709
|
+
proveBridge(sourceChain: string, txHash: string, blockHeaders: string[], options?: {
|
|
710
|
+
priority?: ProofJobPriority;
|
|
711
|
+
}): Promise<ProofResult>;
|
|
712
|
+
/**
|
|
713
|
+
* Aggregate multiple proofs into one (recursive proving)
|
|
714
|
+
*/
|
|
715
|
+
aggregateProofs(proofHashes: string[], options?: {
|
|
716
|
+
priority?: ProofJobPriority;
|
|
717
|
+
}): Promise<ProofResult>;
|
|
718
|
+
private fetch;
|
|
719
|
+
private sleep;
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Create a new STWO Prover Client
|
|
723
|
+
*/
|
|
724
|
+
declare function createStwoProverClient(config: StwoProverConfig): StwoProverClient;
|
|
725
|
+
interface ZkmlLoadModelRequest {
|
|
726
|
+
/** Path to ONNX model on the prover server filesystem */
|
|
727
|
+
modelPath: string;
|
|
728
|
+
/** Optional description for on-chain registration */
|
|
729
|
+
description?: string;
|
|
730
|
+
}
|
|
731
|
+
interface ZkmlModelInfo {
|
|
732
|
+
/** Model identifier (hex) */
|
|
733
|
+
modelId: string;
|
|
734
|
+
/** Poseidon hash of weight matrices (hex) */
|
|
735
|
+
weightCommitment: string;
|
|
736
|
+
/** Number of model layers */
|
|
737
|
+
numLayers: number;
|
|
738
|
+
/** Input shape [rows, cols] */
|
|
739
|
+
inputShape: [number, number];
|
|
740
|
+
}
|
|
741
|
+
interface ZkmlProveRequest {
|
|
742
|
+
/** Model ID (must be loaded first) */
|
|
743
|
+
modelId: string;
|
|
744
|
+
/** Flat array of f32 input values (optional — random if omitted) */
|
|
745
|
+
input?: number[];
|
|
746
|
+
/** Use GPU acceleration */
|
|
747
|
+
gpu?: boolean;
|
|
748
|
+
/** Security level: "auto" | "tee" | "zk-only" */
|
|
749
|
+
security?: string;
|
|
750
|
+
}
|
|
751
|
+
type ZkmlJobStatus = 'queued' | 'proving' | 'completed' | 'failed';
|
|
752
|
+
interface ZkmlProveStatus {
|
|
753
|
+
/** Job identifier */
|
|
754
|
+
jobId: string;
|
|
755
|
+
/** Current status */
|
|
756
|
+
status: ZkmlJobStatus;
|
|
757
|
+
/** Progress in basis points (0-10000) */
|
|
758
|
+
progressBps: number;
|
|
759
|
+
/** Elapsed seconds since submission */
|
|
760
|
+
elapsedSecs: number;
|
|
761
|
+
}
|
|
762
|
+
interface ZkmlProveResult {
|
|
763
|
+
/** Combined felt252 calldata for on-chain verify_model() */
|
|
764
|
+
calldata: string[];
|
|
765
|
+
/** Poseidon(inputs || outputs) */
|
|
766
|
+
ioCommitment: string;
|
|
767
|
+
/** Poseidon hash of weight matrices */
|
|
768
|
+
weightCommitment: string;
|
|
769
|
+
/** Running Poseidon hash of intermediate layer values */
|
|
770
|
+
layerChainCommitment: string;
|
|
771
|
+
/** Estimated gas for on-chain verification */
|
|
772
|
+
estimatedGas: number;
|
|
773
|
+
/** Number of matmul sumcheck proofs */
|
|
774
|
+
numMatmulProofs: number;
|
|
775
|
+
/** Number of proven layers */
|
|
776
|
+
numLayers: number;
|
|
777
|
+
/** Proving time in milliseconds */
|
|
778
|
+
proveTimeMs: number;
|
|
779
|
+
/** TEE attestation hash (null if zk-only) */
|
|
780
|
+
teeAttestationHash: string | null;
|
|
781
|
+
}
|
|
782
|
+
declare module './stwo-prover' {
|
|
783
|
+
interface StwoProverClient {
|
|
784
|
+
/** Load an ONNX model on the prover server */
|
|
785
|
+
loadZkmlModel(req: ZkmlLoadModelRequest): Promise<ZkmlModelInfo>;
|
|
786
|
+
/** Submit a ZKML proving job (returns immediately with job_id) */
|
|
787
|
+
submitZkmlProve(req: ZkmlProveRequest): Promise<{
|
|
788
|
+
jobId: string;
|
|
789
|
+
status: ZkmlJobStatus;
|
|
790
|
+
}>;
|
|
791
|
+
/** Poll status of a ZKML proving job */
|
|
792
|
+
getZkmlProveStatus(jobId: string): Promise<ZkmlProveStatus>;
|
|
793
|
+
/** Get the completed proof result */
|
|
794
|
+
getZkmlProveResult(jobId: string): Promise<ZkmlProveResult>;
|
|
795
|
+
/** Submit, poll until complete, and return the result */
|
|
796
|
+
proveZkml(req: ZkmlProveRequest, opts?: {
|
|
797
|
+
pollIntervalMs?: number;
|
|
798
|
+
timeoutMs?: number;
|
|
799
|
+
onProgress?: (status: ZkmlProveStatus) => void;
|
|
800
|
+
}): Promise<ZkmlProveResult>;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
declare const PROOF_TYPES: {
|
|
804
|
+
BATCH_PAYMENTS: ProofType;
|
|
805
|
+
AI_INFERENCE: ProofType;
|
|
806
|
+
CROSS_CHAIN_BRIDGE: ProofType;
|
|
807
|
+
DEFI_CALCULATION: ProofType;
|
|
808
|
+
GAME_STATE: ProofType;
|
|
809
|
+
VRF_RANDOMNESS: ProofType;
|
|
810
|
+
KYC_VERIFICATION: ProofType;
|
|
811
|
+
SUPPLY_CHAIN: ProofType;
|
|
812
|
+
RECURSIVE_AGGREGATION: ProofType;
|
|
813
|
+
CUSTOM: ProofType;
|
|
814
|
+
};
|
|
815
|
+
declare const GPU_TIERS: {
|
|
816
|
+
H100: GpuTier;
|
|
817
|
+
H200: GpuTier;
|
|
818
|
+
B200: GpuTier;
|
|
819
|
+
A100: GpuTier;
|
|
820
|
+
RTX_4090: GpuTier;
|
|
821
|
+
AUTO: GpuTier;
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* BitSage and OBELYSK Branding
|
|
826
|
+
*
|
|
827
|
+
* ASCII art logos and banners for console output.
|
|
828
|
+
*
|
|
829
|
+
* @packageDocumentation
|
|
830
|
+
*/
|
|
831
|
+
/**
|
|
832
|
+
* BitSage ASCII logo (plain text, no color codes)
|
|
833
|
+
*/
|
|
834
|
+
declare const BITSAGE_LOGO = "\n \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\n \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\n \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557\n \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D\n \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\n \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n";
|
|
835
|
+
/**
|
|
836
|
+
* BitSage tagline
|
|
837
|
+
*/
|
|
838
|
+
declare const BITSAGE_TAGLINE = "The Economic Heart of Decentralized Compute";
|
|
839
|
+
/**
|
|
840
|
+
* Full BitSage banner with box
|
|
841
|
+
*/
|
|
842
|
+
declare const BITSAGE_BANNER = "\n\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557\n\u2551 \u2551\n\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2551\n\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551\u255A\u2550\u2550\u2588\u2588\u2554\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D \u2551\n\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2557 \u2551\n\u2551 \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551 \u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u255D \u2551\n\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2551\n\u2551 \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u2551\n\u2551 \u2551\n\u2551 The Economic Heart of Decentralized Compute \u2551\n\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n";
|
|
843
|
+
/**
|
|
844
|
+
* OBELYSK ASCII logo (plain text, no color codes)
|
|
845
|
+
*/
|
|
846
|
+
declare const OBELYSK_LOGO = "\n \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557\n \u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u255A\u2588\u2588\u2557 \u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u255D\n \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2554\u255D\n \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551 \u255A\u2588\u2588\u2554\u255D \u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2588\u2588\u2557\n \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2557\n \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\n";
|
|
847
|
+
/**
|
|
848
|
+
* OBELYSK tagline
|
|
849
|
+
*/
|
|
850
|
+
declare const OBELYSK_TAGLINE = "Verifiable GPU Compute \u2022 ZK Proofs \u2022 TEE Attestation";
|
|
851
|
+
/**
|
|
852
|
+
* Full OBELYSK banner with box
|
|
853
|
+
*/
|
|
854
|
+
declare const OBELYSK_BANNER = "\n\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557\n\u2551 \u2551\n\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2557 \u2588\u2588\u2557 \u2551\n\u2551 \u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u255A\u2588\u2588\u2557 \u2588\u2588\u2554\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2551 \u2588\u2588\u2554\u255D \u2551\n\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u255A\u2588\u2588\u2588\u2588\u2554\u255D \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2554\u255D \u2551\n\u2551 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551 \u255A\u2588\u2588\u2554\u255D \u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2588\u2588\u2557 \u2551\n\u2551 \u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2557 \u2551\n\u2551 \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D \u2551\n\u2551 \u2551\n\u2551 Verifiable GPU Compute \u2022 ZK Proofs \u2022 TEE Attestation \u2551\n\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n";
|
|
855
|
+
/**
|
|
856
|
+
* Print BitSage banner to console
|
|
857
|
+
*/
|
|
858
|
+
declare function printBitsageBanner(): void;
|
|
859
|
+
/**
|
|
860
|
+
* Print OBELYSK banner to console
|
|
861
|
+
*/
|
|
862
|
+
declare function printObelyskanBanner(): void;
|
|
863
|
+
/**
|
|
864
|
+
* Get version banner for SDK
|
|
865
|
+
*/
|
|
866
|
+
declare function getVersionBanner(version: string): string;
|
|
867
|
+
|
|
868
|
+
export { AEHint, BITSAGE_BANNER, BITSAGE_LOGO, BITSAGE_TAGLINE, type BatchProofRequest, type BatchProofResponse, DEFAULT_PROVER_CONFIG, ECPoint, ElGamalCiphertext, EncryptedBalance, EncryptionHelper, GPU_TIERS, OBELYSK_BANNER, OBELYSK_LOGO, OBELYSK_TAGLINE, PROOF_TYPES, PrivacyKeyManager, PrivacyKeyPair, type ProofCostEstimate, type ProofGenerationStatus, type ProofJobPriority, type ProofJobRequest, type ProofJobResponse, type ProofJobStatus, type ProofResult, SchnorrProof, type GpuTier as StwoGpuTier, type ProofType as StwoProofType, StwoProverClient, type StwoProverConfig, type ProverMetrics as StwoProverMetrics, TransferProof, type UseWebSocketResult, WebSocketClient, WsConfig, WsEvent, createStwoProverClient, createTransferProof, createWebSocketClient, getPrivacyDerivationMessage, getVersionBanner, isValidPublicKey, printBitsageBanner, printObelyskanBanner, verifyTransferProof };
|