@obelyzk/sdk 1.0.1 → 1.2.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/dist/index.d.mts CHANGED
@@ -1,6 +1,8 @@
1
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.mjs';
2
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.mjs';
3
+ export { AgentFirewallSDK, AgentStatus, ClassifyResult, Decision, FirewallConfig, TransactionFeatures } from './firewall/index.mjs';
3
4
  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.mjs';
5
+ import 'starknet';
4
6
 
5
7
  /**
6
8
  * WebSocket Module
@@ -400,7 +402,7 @@ declare function verifyTransferProof(proof: TransferProof, senderPublicKey: ECPo
400
402
  *
401
403
  * @example
402
404
  * ```typescript
403
- * import { createStwoProverClient } from '@bitsage/sdk';
405
+ * import { createStwoProverClient } from '@obelyzk/sdk';
404
406
  *
405
407
  * const prover = createStwoProverClient({
406
408
  * baseUrl: 'https://prover.bitsage.network',
@@ -424,8 +426,8 @@ type ProofJobPriority = 'standard' | 'high' | 'critical' | 'emergency';
424
426
  type ProofJobStatus = 'queued' | 'assigned' | 'generating' | 'completed' | 'failed' | 'cancelled' | 'timeout';
425
427
  type ProofType = 'batch_payments' | 'ai_inference' | 'cross_chain_bridge' | 'defi_calculation' | 'game_state' | 'vrf_randomness' | 'kyc_verification' | 'supply_chain' | 'recursive_aggregation' | 'custom';
426
428
  interface StwoProverConfig {
427
- /** Base URL of the STWO prover service */
428
- baseUrl: string;
429
+ /** Base URL of the STWO prover service (default: https://prover.bitsage.network) */
430
+ baseUrl?: string;
429
431
  /** API key for authentication */
430
432
  apiKey?: string;
431
433
  /** Default GPU tier preference */
@@ -591,7 +593,7 @@ interface ProofCostEstimate {
591
593
  declare const DEFAULT_PROVER_CONFIG: Partial<StwoProverConfig>;
592
594
  declare class StwoProverClient {
593
595
  private config;
594
- constructor(config: StwoProverConfig);
596
+ constructor(config?: Partial<StwoProverConfig>);
595
597
  /**
596
598
  * Load an ONNX model on the prover server.
597
599
  * Must be called before submitting proving jobs for that model.
@@ -721,16 +723,20 @@ declare class StwoProverClient {
721
723
  /**
722
724
  * Create a new STWO Prover Client
723
725
  */
724
- declare function createStwoProverClient(config: StwoProverConfig): StwoProverClient;
726
+ declare function createStwoProverClient(config?: Partial<StwoProverConfig>): StwoProverClient;
725
727
  interface ZkmlLoadModelRequest {
726
728
  /** Path to ONNX model on the prover server filesystem */
727
- modelPath: string;
729
+ modelPath?: string;
730
+ /** Path to HuggingFace model directory on the prover */
731
+ model_dir?: string;
728
732
  /** Optional description for on-chain registration */
729
733
  description?: string;
730
734
  }
731
735
  interface ZkmlModelInfo {
732
736
  /** Model identifier (hex) */
733
737
  modelId: string;
738
+ /** Human-readable model name (e.g., "smollm2-135m") */
739
+ name: string;
734
740
  /** Poseidon hash of weight matrices (hex) */
735
741
  weightCommitment: string;
736
742
  /** Number of model layers */
@@ -739,7 +745,7 @@ interface ZkmlModelInfo {
739
745
  inputShape: [number, number];
740
746
  }
741
747
  interface ZkmlProveRequest {
742
- /** Model ID (must be loaded first) */
748
+ /** Model ID or name (e.g., "smollm2-135m" or "0x1cb4f9...") */
743
749
  modelId: string;
744
750
  /** Flat array of f32 input values (optional — random if omitted) */
745
751
  input?: number[];
@@ -781,7 +787,9 @@ interface ZkmlProveResult {
781
787
  }
782
788
  declare module './stwo-prover' {
783
789
  interface StwoProverClient {
784
- /** Load an ONNX model on the prover server */
790
+ /** List all loaded models on the prover */
791
+ listZkmlModels(): Promise<ZkmlModelInfo[]>;
792
+ /** Load a model on the prover server (ONNX or HuggingFace) */
785
793
  loadZkmlModel(req: ZkmlLoadModelRequest): Promise<ZkmlModelInfo>;
786
794
  /** Submit a ZKML proving job (returns immediately with job_id) */
787
795
  submitZkmlProve(req: ZkmlProveRequest): Promise<{
@@ -798,8 +806,46 @@ declare module './stwo-prover' {
798
806
  timeoutMs?: number;
799
807
  onProgress?: (status: ZkmlProveStatus) => void;
800
808
  }): Promise<ZkmlProveResult>;
809
+ /** Full attestation: prove + on-chain verification in one call */
810
+ attest(req: ZkmlAttestRequest): Promise<ZkmlAttestResult>;
801
811
  }
802
812
  }
813
+ interface ZkmlAttestRequest {
814
+ /** Model name or hex ID */
815
+ modelId: string;
816
+ /** Flat input array */
817
+ input: number[];
818
+ /** GPU acceleration (default: true) */
819
+ gpu?: boolean;
820
+ /** Submit on-chain (default: true) */
821
+ submitOnchain?: boolean;
822
+ }
823
+ interface ZkmlAttestResult {
824
+ /** Proof identifier */
825
+ proofId: string;
826
+ /** IO commitment (Poseidon hash of inputs + outputs) */
827
+ ioCommitment: string;
828
+ /** Weight commitment (Poseidon Merkle root of all weights) */
829
+ weightCommitment: string;
830
+ /** Number of computation nodes proven */
831
+ numProvenLayers: number;
832
+ /** Proof generation time in ms */
833
+ proveTimeMs: number;
834
+ /** Number of calldata felts */
835
+ calldataFelts: number;
836
+ /** Estimated gas for on-chain verification */
837
+ estimatedGas: number;
838
+ /** On-chain verification status */
839
+ onchain: {
840
+ submitted: boolean;
841
+ txHashes: string[];
842
+ network: string;
843
+ contract: string;
844
+ verified: boolean;
845
+ explorerUrl: string | null;
846
+ error: string | null;
847
+ };
848
+ }
803
849
  declare const PROOF_TYPES: {
804
850
  BATCH_PAYMENTS: ProofType;
805
851
  AI_INFERENCE: ProofType;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
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
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 { AgentFirewallSDK, AgentStatus, ClassifyResult, Decision, FirewallConfig, TransactionFeatures } from './firewall/index.js';
3
4
  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';
5
+ import 'starknet';
4
6
 
5
7
  /**
6
8
  * WebSocket Module
@@ -400,7 +402,7 @@ declare function verifyTransferProof(proof: TransferProof, senderPublicKey: ECPo
400
402
  *
401
403
  * @example
402
404
  * ```typescript
403
- * import { createStwoProverClient } from '@bitsage/sdk';
405
+ * import { createStwoProverClient } from '@obelyzk/sdk';
404
406
  *
405
407
  * const prover = createStwoProverClient({
406
408
  * baseUrl: 'https://prover.bitsage.network',
@@ -424,8 +426,8 @@ type ProofJobPriority = 'standard' | 'high' | 'critical' | 'emergency';
424
426
  type ProofJobStatus = 'queued' | 'assigned' | 'generating' | 'completed' | 'failed' | 'cancelled' | 'timeout';
425
427
  type ProofType = 'batch_payments' | 'ai_inference' | 'cross_chain_bridge' | 'defi_calculation' | 'game_state' | 'vrf_randomness' | 'kyc_verification' | 'supply_chain' | 'recursive_aggregation' | 'custom';
426
428
  interface StwoProverConfig {
427
- /** Base URL of the STWO prover service */
428
- baseUrl: string;
429
+ /** Base URL of the STWO prover service (default: https://prover.bitsage.network) */
430
+ baseUrl?: string;
429
431
  /** API key for authentication */
430
432
  apiKey?: string;
431
433
  /** Default GPU tier preference */
@@ -591,7 +593,7 @@ interface ProofCostEstimate {
591
593
  declare const DEFAULT_PROVER_CONFIG: Partial<StwoProverConfig>;
592
594
  declare class StwoProverClient {
593
595
  private config;
594
- constructor(config: StwoProverConfig);
596
+ constructor(config?: Partial<StwoProverConfig>);
595
597
  /**
596
598
  * Load an ONNX model on the prover server.
597
599
  * Must be called before submitting proving jobs for that model.
@@ -721,16 +723,20 @@ declare class StwoProverClient {
721
723
  /**
722
724
  * Create a new STWO Prover Client
723
725
  */
724
- declare function createStwoProverClient(config: StwoProverConfig): StwoProverClient;
726
+ declare function createStwoProverClient(config?: Partial<StwoProverConfig>): StwoProverClient;
725
727
  interface ZkmlLoadModelRequest {
726
728
  /** Path to ONNX model on the prover server filesystem */
727
- modelPath: string;
729
+ modelPath?: string;
730
+ /** Path to HuggingFace model directory on the prover */
731
+ model_dir?: string;
728
732
  /** Optional description for on-chain registration */
729
733
  description?: string;
730
734
  }
731
735
  interface ZkmlModelInfo {
732
736
  /** Model identifier (hex) */
733
737
  modelId: string;
738
+ /** Human-readable model name (e.g., "smollm2-135m") */
739
+ name: string;
734
740
  /** Poseidon hash of weight matrices (hex) */
735
741
  weightCommitment: string;
736
742
  /** Number of model layers */
@@ -739,7 +745,7 @@ interface ZkmlModelInfo {
739
745
  inputShape: [number, number];
740
746
  }
741
747
  interface ZkmlProveRequest {
742
- /** Model ID (must be loaded first) */
748
+ /** Model ID or name (e.g., "smollm2-135m" or "0x1cb4f9...") */
743
749
  modelId: string;
744
750
  /** Flat array of f32 input values (optional — random if omitted) */
745
751
  input?: number[];
@@ -781,7 +787,9 @@ interface ZkmlProveResult {
781
787
  }
782
788
  declare module './stwo-prover' {
783
789
  interface StwoProverClient {
784
- /** Load an ONNX model on the prover server */
790
+ /** List all loaded models on the prover */
791
+ listZkmlModels(): Promise<ZkmlModelInfo[]>;
792
+ /** Load a model on the prover server (ONNX or HuggingFace) */
785
793
  loadZkmlModel(req: ZkmlLoadModelRequest): Promise<ZkmlModelInfo>;
786
794
  /** Submit a ZKML proving job (returns immediately with job_id) */
787
795
  submitZkmlProve(req: ZkmlProveRequest): Promise<{
@@ -798,8 +806,46 @@ declare module './stwo-prover' {
798
806
  timeoutMs?: number;
799
807
  onProgress?: (status: ZkmlProveStatus) => void;
800
808
  }): Promise<ZkmlProveResult>;
809
+ /** Full attestation: prove + on-chain verification in one call */
810
+ attest(req: ZkmlAttestRequest): Promise<ZkmlAttestResult>;
801
811
  }
802
812
  }
813
+ interface ZkmlAttestRequest {
814
+ /** Model name or hex ID */
815
+ modelId: string;
816
+ /** Flat input array */
817
+ input: number[];
818
+ /** GPU acceleration (default: true) */
819
+ gpu?: boolean;
820
+ /** Submit on-chain (default: true) */
821
+ submitOnchain?: boolean;
822
+ }
823
+ interface ZkmlAttestResult {
824
+ /** Proof identifier */
825
+ proofId: string;
826
+ /** IO commitment (Poseidon hash of inputs + outputs) */
827
+ ioCommitment: string;
828
+ /** Weight commitment (Poseidon Merkle root of all weights) */
829
+ weightCommitment: string;
830
+ /** Number of computation nodes proven */
831
+ numProvenLayers: number;
832
+ /** Proof generation time in ms */
833
+ proveTimeMs: number;
834
+ /** Number of calldata felts */
835
+ calldataFelts: number;
836
+ /** Estimated gas for on-chain verification */
837
+ estimatedGas: number;
838
+ /** On-chain verification status */
839
+ onchain: {
840
+ submitted: boolean;
841
+ txHashes: string[];
842
+ network: string;
843
+ contract: string;
844
+ verified: boolean;
845
+ explorerUrl: string | null;
846
+ error: string | null;
847
+ };
848
+ }
803
849
  declare const PROOF_TYPES: {
804
850
  BATCH_PAYMENTS: ProofType;
805
851
  AI_INFERENCE: ProofType;
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ AgentFirewallSDK: () => AgentFirewallSDK,
23
24
  AssetId: () => AssetId,
24
25
  BITSAGE_BANNER: () => BITSAGE_BANNER,
25
26
  BITSAGE_LOGO: () => BITSAGE_LOGO,
@@ -6086,6 +6087,7 @@ var StwoProverClient = class {
6086
6087
  });
6087
6088
  return {
6088
6089
  modelId: response.model_id,
6090
+ name: response.name || response.model_id,
6089
6091
  weightCommitment: response.weight_commitment,
6090
6092
  numLayers: response.num_layers,
6091
6093
  inputShape: response.input_shape
@@ -6511,18 +6513,28 @@ var StwoProverClient = class {
6511
6513
  }
6512
6514
  };
6513
6515
  function createStwoProverClient(config) {
6514
- return new StwoProverClient(config);
6516
+ return new StwoProverClient(config ?? {});
6515
6517
  }
6518
+ StwoProverClient.prototype.listZkmlModels = async function() {
6519
+ const response = await this.fetch("/api/v1/models");
6520
+ return response.map((m) => ({
6521
+ modelId: m.model_id,
6522
+ name: m.name || "",
6523
+ weightCommitment: m.weight_commitment,
6524
+ numLayers: m.num_layers,
6525
+ inputShape: m.input_shape
6526
+ }));
6527
+ };
6516
6528
  StwoProverClient.prototype.loadZkmlModel = async function(req) {
6517
- const response = await this.fetch("/api/v1/models", {
6529
+ const endpoint = req.model_dir ? "/api/v1/models/hf" : "/api/v1/models";
6530
+ const body = req.model_dir ? { model_dir: req.model_dir, description: req.description } : { model_path: req.modelPath, description: req.description };
6531
+ const response = await this.fetch(endpoint, {
6518
6532
  method: "POST",
6519
- body: JSON.stringify({
6520
- model_path: req.modelPath,
6521
- description: req.description
6522
- })
6533
+ body: JSON.stringify(body)
6523
6534
  });
6524
6535
  return {
6525
6536
  modelId: response.model_id,
6537
+ name: response.name || "",
6526
6538
  weightCommitment: response.weight_commitment,
6527
6539
  numLayers: response.num_layers,
6528
6540
  inputShape: response.input_shape
@@ -6581,6 +6593,35 @@ StwoProverClient.prototype.proveZkml = async function(req, opts) {
6581
6593
  }
6582
6594
  throw new Error(`ZKML proving timed out after ${timeout}ms`);
6583
6595
  };
6596
+ StwoProverClient.prototype.attest = async function(req) {
6597
+ const response = await this.fetch("/api/v1/attest", {
6598
+ method: "POST",
6599
+ body: JSON.stringify({
6600
+ model_id: req.modelId,
6601
+ input: req.input,
6602
+ gpu: req.gpu ?? true,
6603
+ submit_onchain: req.submitOnchain ?? true
6604
+ })
6605
+ });
6606
+ return {
6607
+ proofId: response.proof_id,
6608
+ ioCommitment: response.io_commitment,
6609
+ weightCommitment: response.weight_commitment,
6610
+ numProvenLayers: response.num_proven_layers,
6611
+ proveTimeMs: response.prove_time_ms,
6612
+ calldataFelts: response.calldata_felts,
6613
+ estimatedGas: response.estimated_gas,
6614
+ onchain: {
6615
+ submitted: response.onchain?.submitted ?? false,
6616
+ txHashes: response.onchain?.tx_hashes ?? [],
6617
+ network: response.onchain?.network ?? "starknet-sepolia",
6618
+ contract: response.onchain?.contract ?? "",
6619
+ verified: response.onchain?.verified ?? false,
6620
+ explorerUrl: response.onchain?.explorer_url ?? null,
6621
+ error: response.onchain?.error ?? null
6622
+ }
6623
+ };
6624
+ };
6584
6625
  var PROOF_TYPES = {
6585
6626
  BATCH_PAYMENTS: "batch_payments",
6586
6627
  AI_INFERENCE: "ai_inference",
@@ -6602,6 +6643,209 @@ var GPU_TIERS = {
6602
6643
  AUTO: "auto"
6603
6644
  };
6604
6645
 
6646
+ // src/firewall/client.ts
6647
+ var import_starknet = require("starknet");
6648
+ var AgentFirewallSDK = class {
6649
+ config;
6650
+ provider;
6651
+ constructor(config) {
6652
+ this.config = config;
6653
+ this.provider = new import_starknet.RpcProvider({ nodeUrl: config.rpcUrl });
6654
+ }
6655
+ // ── Classification ─────────────────────────────────────────────────
6656
+ /**
6657
+ * Classify a transaction through the ZKML classifier.
6658
+ *
6659
+ * Sends the transaction features to the prove-server, which runs
6660
+ * the MLP classifier and generates a GKR+STARK proof. Returns the
6661
+ * proven threat score and decision.
6662
+ *
6663
+ * Does NOT submit anything on-chain — use `evaluateAction()` for
6664
+ * the full flow including on-chain submission.
6665
+ */
6666
+ async classify(tx) {
6667
+ const headers = {
6668
+ "Content-Type": "application/json"
6669
+ };
6670
+ if (this.config.apiKey) {
6671
+ headers["Authorization"] = `Bearer ${this.config.apiKey}`;
6672
+ }
6673
+ const body = {
6674
+ target: tx.target,
6675
+ value: tx.value || "0",
6676
+ selector: tx.selector || "0x0",
6677
+ calldata: tx.calldata || "0x",
6678
+ agent_trust_score: tx.agentTrustScore || 0,
6679
+ agent_strikes: tx.agentStrikes || 0,
6680
+ agent_age_blocks: tx.agentAgeBlocks || 0,
6681
+ target_verified: tx.targetVerified || false,
6682
+ target_is_proxy: tx.targetIsProxy || false,
6683
+ target_has_source: tx.targetHasSource || false,
6684
+ target_interaction_count: tx.targetInteractionCount || 0,
6685
+ tx_frequency: tx.txFrequency || 0,
6686
+ unique_targets_24h: tx.uniqueTargets24h || 0,
6687
+ avg_value_24h: tx.avgValue24h || 0,
6688
+ max_value_24h: tx.maxValue24h || 0
6689
+ };
6690
+ const response = await fetch(`${this.config.proverUrl}/api/v1/classify`, {
6691
+ method: "POST",
6692
+ headers,
6693
+ body: JSON.stringify(body)
6694
+ });
6695
+ if (!response.ok) {
6696
+ const error = await response.json().catch(() => ({ error: response.statusText }));
6697
+ throw new Error(`Classification failed (${response.status}): ${error.error || response.statusText}`);
6698
+ }
6699
+ const data = await response.json();
6700
+ return {
6701
+ requestId: data.request_id,
6702
+ decision: data.decision,
6703
+ threatScore: data.threat_score,
6704
+ scores: data.scores,
6705
+ ioCommitment: data.io_commitment,
6706
+ policyCommitment: data.policy_commitment,
6707
+ proveTimeMs: data.prove_time_ms
6708
+ };
6709
+ }
6710
+ // ── Agent Management ───────────────────────────────────────────────
6711
+ /**
6712
+ * Register a new agent on the firewall contract.
6713
+ * The calling account becomes the agent owner.
6714
+ */
6715
+ async registerAgent(agentId) {
6716
+ this.requireAccount();
6717
+ const tx = await this.config.account.execute({
6718
+ contractAddress: this.config.firewallContract,
6719
+ entrypoint: "register_agent",
6720
+ calldata: import_starknet.CallData.compile({ agent_id: agentId })
6721
+ });
6722
+ await this.provider.waitForTransaction(tx.transaction_hash);
6723
+ return tx.transaction_hash;
6724
+ }
6725
+ /** Deactivate an agent (owner or contract admin). */
6726
+ async deactivateAgent(agentId) {
6727
+ this.requireAccount();
6728
+ const tx = await this.config.account.execute({
6729
+ contractAddress: this.config.firewallContract,
6730
+ entrypoint: "deactivate_agent",
6731
+ calldata: import_starknet.CallData.compile({ agent_id: agentId })
6732
+ });
6733
+ await this.provider.waitForTransaction(tx.transaction_hash);
6734
+ return tx.transaction_hash;
6735
+ }
6736
+ /** Reactivate an agent and reset strikes (agent owner only). */
6737
+ async reactivateAgent(agentId) {
6738
+ this.requireAccount();
6739
+ const tx = await this.config.account.execute({
6740
+ contractAddress: this.config.firewallContract,
6741
+ entrypoint: "reactivate_agent",
6742
+ calldata: import_starknet.CallData.compile({ agent_id: agentId })
6743
+ });
6744
+ await this.provider.waitForTransaction(tx.transaction_hash);
6745
+ return tx.transaction_hash;
6746
+ }
6747
+ // ── Queries ────────────────────────────────────────────────────────
6748
+ /** Get the full status of an agent. */
6749
+ async getAgentStatus(agentId) {
6750
+ const contract = new import_starknet.Contract(
6751
+ FIREWALL_ABI,
6752
+ this.config.firewallContract,
6753
+ this.provider
6754
+ );
6755
+ const [registered, active, trustScore, strikes, trusted] = await Promise.all([
6756
+ contract.is_agent_registered(agentId),
6757
+ contract.is_agent_active(agentId),
6758
+ contract.get_trust_score(agentId),
6759
+ contract.get_strikes(agentId),
6760
+ contract.is_trusted(agentId)
6761
+ ]);
6762
+ return {
6763
+ registered,
6764
+ active,
6765
+ trustScore: Number(trustScore),
6766
+ strikes: Number(strikes),
6767
+ trusted
6768
+ };
6769
+ }
6770
+ /** Check if a specific action has been approved. */
6771
+ async isActionApproved(actionId) {
6772
+ const contract = new import_starknet.Contract(
6773
+ FIREWALL_ABI,
6774
+ this.config.firewallContract,
6775
+ this.provider
6776
+ );
6777
+ return contract.is_action_approved(actionId);
6778
+ }
6779
+ /** Check if an agent is trusted. */
6780
+ async isAgentTrusted(agentId) {
6781
+ const contract = new import_starknet.Contract(
6782
+ FIREWALL_ABI,
6783
+ this.config.firewallContract,
6784
+ this.provider
6785
+ );
6786
+ return contract.is_trusted(agentId);
6787
+ }
6788
+ // ── Helpers ────────────────────────────────────────────────────────
6789
+ requireAccount() {
6790
+ if (!this.config.account) {
6791
+ throw new Error(
6792
+ "Account required for write operations. Pass `account` in FirewallConfig."
6793
+ );
6794
+ }
6795
+ }
6796
+ };
6797
+ var FIREWALL_ABI = [
6798
+ {
6799
+ name: "is_agent_registered",
6800
+ type: "function",
6801
+ inputs: [{ name: "agent_id", type: "felt" }],
6802
+ outputs: [{ type: "felt" }],
6803
+ state_mutability: "view"
6804
+ },
6805
+ {
6806
+ name: "is_agent_active",
6807
+ type: "function",
6808
+ inputs: [{ name: "agent_id", type: "felt" }],
6809
+ outputs: [{ type: "felt" }],
6810
+ state_mutability: "view"
6811
+ },
6812
+ {
6813
+ name: "get_trust_score",
6814
+ type: "function",
6815
+ inputs: [{ name: "agent_id", type: "felt" }],
6816
+ outputs: [{ type: "felt" }],
6817
+ state_mutability: "view"
6818
+ },
6819
+ {
6820
+ name: "get_strikes",
6821
+ type: "function",
6822
+ inputs: [{ name: "agent_id", type: "felt" }],
6823
+ outputs: [{ type: "felt" }],
6824
+ state_mutability: "view"
6825
+ },
6826
+ {
6827
+ name: "is_trusted",
6828
+ type: "function",
6829
+ inputs: [{ name: "agent_id", type: "felt" }],
6830
+ outputs: [{ type: "felt" }],
6831
+ state_mutability: "view"
6832
+ },
6833
+ {
6834
+ name: "is_action_approved",
6835
+ type: "function",
6836
+ inputs: [{ name: "action_id", type: "felt" }],
6837
+ outputs: [{ type: "felt" }],
6838
+ state_mutability: "view"
6839
+ },
6840
+ {
6841
+ name: "get_action_decision",
6842
+ type: "function",
6843
+ inputs: [{ name: "action_id", type: "felt" }],
6844
+ outputs: [{ type: "felt" }],
6845
+ state_mutability: "view"
6846
+ }
6847
+ ];
6848
+
6605
6849
  // src/branding.ts
6606
6850
  var BITSAGE_LOGO = `
6607
6851
  \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
@@ -7341,6 +7585,7 @@ var ConfidentialSwapClient = class {
7341
7585
  };
7342
7586
  // Annotate the CommonJS export names for ESM import in node:
7343
7587
  0 && (module.exports = {
7588
+ AgentFirewallSDK,
7344
7589
  AssetId,
7345
7590
  BITSAGE_BANNER,
7346
7591
  BITSAGE_LOGO,
package/dist/index.mjs CHANGED
@@ -65,6 +65,9 @@ import {
65
65
  toFelt,
66
66
  verifyTransferProof
67
67
  } from "./chunk-LXJT3QK6.mjs";
68
+ import {
69
+ AgentFirewallSDK
70
+ } from "./chunk-BHUXKNDT.mjs";
68
71
  import {
69
72
  AssetId,
70
73
  CURVE_ORDER,
@@ -84,7 +87,8 @@ import {
84
87
  powMod,
85
88
  randomScalar,
86
89
  subMod
87
- } from "./chunk-CGPFHXUF.mjs";
90
+ } from "./chunk-MDF4P52S.mjs";
91
+ import "./chunk-Y6FXYEAI.mjs";
88
92
 
89
93
  // src/types.ts
90
94
  function getMinStake(tier) {
@@ -165,6 +169,7 @@ var StwoProverClient = class {
165
169
  });
166
170
  return {
167
171
  modelId: response.model_id,
172
+ name: response.name || response.model_id,
168
173
  weightCommitment: response.weight_commitment,
169
174
  numLayers: response.num_layers,
170
175
  inputShape: response.input_shape
@@ -590,18 +595,28 @@ var StwoProverClient = class {
590
595
  }
591
596
  };
592
597
  function createStwoProverClient(config) {
593
- return new StwoProverClient(config);
598
+ return new StwoProverClient(config ?? {});
594
599
  }
600
+ StwoProverClient.prototype.listZkmlModels = async function() {
601
+ const response = await this.fetch("/api/v1/models");
602
+ return response.map((m) => ({
603
+ modelId: m.model_id,
604
+ name: m.name || "",
605
+ weightCommitment: m.weight_commitment,
606
+ numLayers: m.num_layers,
607
+ inputShape: m.input_shape
608
+ }));
609
+ };
595
610
  StwoProverClient.prototype.loadZkmlModel = async function(req) {
596
- const response = await this.fetch("/api/v1/models", {
611
+ const endpoint = req.model_dir ? "/api/v1/models/hf" : "/api/v1/models";
612
+ const body = req.model_dir ? { model_dir: req.model_dir, description: req.description } : { model_path: req.modelPath, description: req.description };
613
+ const response = await this.fetch(endpoint, {
597
614
  method: "POST",
598
- body: JSON.stringify({
599
- model_path: req.modelPath,
600
- description: req.description
601
- })
615
+ body: JSON.stringify(body)
602
616
  });
603
617
  return {
604
618
  modelId: response.model_id,
619
+ name: response.name || "",
605
620
  weightCommitment: response.weight_commitment,
606
621
  numLayers: response.num_layers,
607
622
  inputShape: response.input_shape
@@ -660,6 +675,35 @@ StwoProverClient.prototype.proveZkml = async function(req, opts) {
660
675
  }
661
676
  throw new Error(`ZKML proving timed out after ${timeout}ms`);
662
677
  };
678
+ StwoProverClient.prototype.attest = async function(req) {
679
+ const response = await this.fetch("/api/v1/attest", {
680
+ method: "POST",
681
+ body: JSON.stringify({
682
+ model_id: req.modelId,
683
+ input: req.input,
684
+ gpu: req.gpu ?? true,
685
+ submit_onchain: req.submitOnchain ?? true
686
+ })
687
+ });
688
+ return {
689
+ proofId: response.proof_id,
690
+ ioCommitment: response.io_commitment,
691
+ weightCommitment: response.weight_commitment,
692
+ numProvenLayers: response.num_proven_layers,
693
+ proveTimeMs: response.prove_time_ms,
694
+ calldataFelts: response.calldata_felts,
695
+ estimatedGas: response.estimated_gas,
696
+ onchain: {
697
+ submitted: response.onchain?.submitted ?? false,
698
+ txHashes: response.onchain?.tx_hashes ?? [],
699
+ network: response.onchain?.network ?? "starknet-sepolia",
700
+ contract: response.onchain?.contract ?? "",
701
+ verified: response.onchain?.verified ?? false,
702
+ explorerUrl: response.onchain?.explorer_url ?? null,
703
+ error: response.onchain?.error ?? null
704
+ }
705
+ };
706
+ };
663
707
  var PROOF_TYPES = {
664
708
  BATCH_PAYMENTS: "batch_payments",
665
709
  AI_INFERENCE: "ai_inference",
@@ -749,6 +793,7 @@ function getVersionBanner(version) {
749
793
  `;
750
794
  }
751
795
  export {
796
+ AgentFirewallSDK,
752
797
  AssetId,
753
798
  BITSAGE_BANNER,
754
799
  BITSAGE_LOGO,