@arcium-hq/client 0.9.2 → 0.9.4

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.
Files changed (92) hide show
  1. package/build/index.cjs +166 -11
  2. package/build/index.mjs +166 -12
  3. package/build/types/arcis/arcisModule.d.ts +26 -0
  4. package/build/types/arcis/arcisModule.d.ts.map +1 -0
  5. package/build/types/arcis/arcisType.d.ts +76 -0
  6. package/build/types/arcis/arcisType.d.ts.map +1 -0
  7. package/build/types/arcis/packer.d.ts +63 -0
  8. package/build/types/arcis/packer.d.ts.map +1 -0
  9. package/build/types/arcis/packing.d.ts +33 -0
  10. package/build/types/arcis/packing.d.ts.map +1 -0
  11. package/build/types/callback.d.ts +21 -0
  12. package/build/types/callback.d.ts.map +1 -0
  13. package/build/types/constants.d.ts +101 -0
  14. package/build/types/constants.d.ts.map +1 -0
  15. package/build/types/cryptography/aes128Cipher.d.ts +14 -0
  16. package/build/types/cryptography/aes128Cipher.d.ts.map +1 -0
  17. package/build/types/cryptography/aes192Cipher.d.ts +14 -0
  18. package/build/types/cryptography/aes192Cipher.d.ts.map +1 -0
  19. package/build/types/cryptography/aes256Cipher.d.ts +14 -0
  20. package/build/types/cryptography/aes256Cipher.d.ts.map +1 -0
  21. package/build/types/cryptography/aesCtrCipher.d.ts +36 -0
  22. package/build/types/cryptography/aesCtrCipher.d.ts.map +1 -0
  23. package/build/types/cryptography/arcisEd25519.d.ts +8 -0
  24. package/build/types/cryptography/arcisEd25519.d.ts.map +1 -0
  25. package/build/types/cryptography/cSplRescueCipher.d.ts +29 -0
  26. package/build/types/cryptography/cSplRescueCipher.d.ts.map +1 -0
  27. package/build/types/cryptography/cryptography.d.ts +38 -0
  28. package/build/types/cryptography/cryptography.d.ts.map +1 -0
  29. package/build/types/cryptography/hkdf.d.ts +37 -0
  30. package/build/types/cryptography/hkdf.d.ts.map +1 -0
  31. package/build/types/cryptography/hmac.d.ts +22 -0
  32. package/build/types/cryptography/hmac.d.ts.map +1 -0
  33. package/build/types/cryptography/rescueCipher.d.ts +29 -0
  34. package/build/types/cryptography/rescueCipher.d.ts.map +1 -0
  35. package/build/types/cryptography/rescueCipherCommon.d.ts +45 -0
  36. package/build/types/cryptography/rescueCipherCommon.d.ts.map +1 -0
  37. package/build/types/cryptography/rescueDesc.d.ts +80 -0
  38. package/build/types/cryptography/rescueDesc.d.ts.map +1 -0
  39. package/build/types/cryptography/rescuePrimeHash.d.ts +23 -0
  40. package/build/types/cryptography/rescuePrimeHash.d.ts.map +1 -0
  41. package/build/types/ctUtils.d.ts +50 -0
  42. package/build/types/ctUtils.d.ts.map +1 -0
  43. package/build/{index.d.ts → types/idl/arcium.d.ts} +156 -909
  44. package/build/types/idl/arcium.d.ts.map +1 -0
  45. package/build/types/idl/arcium_staking.d.ts +4589 -0
  46. package/build/types/idl/arcium_staking.d.ts.map +1 -0
  47. package/build/types/idl/index.d.ts +15 -0
  48. package/build/types/idl/index.d.ts.map +1 -0
  49. package/build/types/index.d.ts +33 -0
  50. package/build/types/index.d.ts.map +1 -0
  51. package/build/types/localEnv.d.ts +15 -0
  52. package/build/types/localEnv.d.ts.map +1 -0
  53. package/build/types/matrix.d.ts +39 -0
  54. package/build/types/matrix.d.ts.map +1 -0
  55. package/build/types/onchain.d.ts +223 -0
  56. package/build/types/onchain.d.ts.map +1 -0
  57. package/build/types/pda.d.ts +89 -0
  58. package/build/types/pda.d.ts.map +1 -0
  59. package/build/types/utils.d.ts +65 -0
  60. package/build/types/utils.d.ts.map +1 -0
  61. package/package.json +6 -6
  62. package/src/arcis/arcisModule.ts +39 -0
  63. package/src/arcis/arcisType.ts +303 -0
  64. package/src/arcis/packer.ts +152 -0
  65. package/src/arcis/packing.ts +115 -0
  66. package/src/callback.ts +101 -0
  67. package/src/constants.ts +104 -0
  68. package/src/cryptography/aes128Cipher.ts +16 -0
  69. package/src/cryptography/aes192Cipher.ts +16 -0
  70. package/src/cryptography/aes256Cipher.ts +16 -0
  71. package/src/cryptography/aesCtrCipher.ts +84 -0
  72. package/src/cryptography/arcisEd25519.ts +96 -0
  73. package/src/cryptography/cSplRescueCipher.ts +41 -0
  74. package/src/cryptography/cryptography.ts +82 -0
  75. package/src/cryptography/hkdf.ts +58 -0
  76. package/src/cryptography/hmac.ts +66 -0
  77. package/src/cryptography/rescueCipher.ts +41 -0
  78. package/src/cryptography/rescueCipherCommon.ts +211 -0
  79. package/src/cryptography/rescueDesc.ts +492 -0
  80. package/src/cryptography/rescuePrimeHash.ts +72 -0
  81. package/src/ctUtils.ts +124 -0
  82. package/src/idl/arcium.json +12424 -0
  83. package/src/idl/arcium.ts +12430 -0
  84. package/src/idl/arcium_staking.json +4582 -0
  85. package/src/idl/arcium_staking.ts +4588 -0
  86. package/src/idl/index.ts +20 -0
  87. package/src/index.ts +32 -0
  88. package/src/localEnv.ts +39 -0
  89. package/src/matrix.ts +215 -0
  90. package/src/onchain.ts +1020 -0
  91. package/src/pda.ts +203 -0
  92. package/src/utils.ts +126 -0
package/build/index.cjs CHANGED
@@ -1884,7 +1884,7 @@ function createPacker(fields, typeName = 'Packer') {
1884
1884
  var address = "Arcj82pX7HxYKLR92qvgZUAd7vGS1k4hQvAFcPATFdEQ";
1885
1885
  var metadata = {
1886
1886
  name: "arcium",
1887
- version: "0.9.2",
1887
+ version: "0.9.4",
1888
1888
  spec: "0.1.0",
1889
1889
  description: "The Arcium program"
1890
1890
  };
@@ -4899,6 +4899,40 @@ var instructions = [
4899
4899
  ]
4900
4900
  }
4901
4901
  },
4902
+ {
4903
+ name: "cluster_acc",
4904
+ pda: {
4905
+ seeds: [
4906
+ {
4907
+ kind: "const",
4908
+ value: [
4909
+ 67,
4910
+ 108,
4911
+ 117,
4912
+ 115,
4913
+ 116,
4914
+ 101,
4915
+ 114
4916
+ ]
4917
+ },
4918
+ {
4919
+ kind: "arg",
4920
+ path: "cluster_offset"
4921
+ }
4922
+ ]
4923
+ }
4924
+ },
4925
+ {
4926
+ name: "address_lookup_table",
4927
+ docs: [
4928
+ "Seeds are checked in the CPI to LUT program, so no need to check them here."
4929
+ ],
4930
+ writable: true
4931
+ },
4932
+ {
4933
+ name: "lut_program",
4934
+ address: "AddressLookupTab1e1111111111111111111111111"
4935
+ },
4902
4936
  {
4903
4937
  name: "original_mxe_program"
4904
4938
  },
@@ -6538,9 +6572,6 @@ var instructions = [
6538
6572
  },
6539
6573
  {
6540
6574
  name: "program_data",
6541
- docs: [
6542
- "The seeds constraint is only applied in non-testing builds."
6543
- ],
6544
6575
  pda: {
6545
6576
  seeds: [
6546
6577
  {
@@ -8378,6 +8409,123 @@ var instructions = [
8378
8409
  }
8379
8410
  ]
8380
8411
  },
8412
+ {
8413
+ name: "register_account_in_lut",
8414
+ discriminator: [
8415
+ 55,
8416
+ 38,
8417
+ 119,
8418
+ 20,
8419
+ 35,
8420
+ 231,
8421
+ 184,
8422
+ 236
8423
+ ],
8424
+ accounts: [
8425
+ {
8426
+ name: "signer",
8427
+ writable: true,
8428
+ signer: true
8429
+ },
8430
+ {
8431
+ name: "mxe",
8432
+ pda: {
8433
+ seeds: [
8434
+ {
8435
+ kind: "const",
8436
+ value: [
8437
+ 77,
8438
+ 88,
8439
+ 69,
8440
+ 65,
8441
+ 99,
8442
+ 99,
8443
+ 111,
8444
+ 117,
8445
+ 110,
8446
+ 116
8447
+ ]
8448
+ },
8449
+ {
8450
+ kind: "account",
8451
+ path: "mxe_program"
8452
+ }
8453
+ ]
8454
+ }
8455
+ },
8456
+ {
8457
+ name: "mxe_program"
8458
+ },
8459
+ {
8460
+ name: "address_lookup_table",
8461
+ writable: true,
8462
+ pda: {
8463
+ seeds: [
8464
+ {
8465
+ kind: "account",
8466
+ path: "mxe"
8467
+ },
8468
+ {
8469
+ kind: "account",
8470
+ path: "mxe.lut_offset_slot",
8471
+ account: "MXEAccount"
8472
+ }
8473
+ ],
8474
+ program: {
8475
+ kind: "const",
8476
+ value: [
8477
+ 2,
8478
+ 119,
8479
+ 166,
8480
+ 175,
8481
+ 151,
8482
+ 51,
8483
+ 155,
8484
+ 122,
8485
+ 200,
8486
+ 141,
8487
+ 24,
8488
+ 146,
8489
+ 201,
8490
+ 4,
8491
+ 70,
8492
+ 245,
8493
+ 0,
8494
+ 2,
8495
+ 48,
8496
+ 146,
8497
+ 102,
8498
+ 246,
8499
+ 46,
8500
+ 83,
8501
+ 193,
8502
+ 24,
8503
+ 36,
8504
+ 73,
8505
+ 130,
8506
+ 0,
8507
+ 0,
8508
+ 0
8509
+ ]
8510
+ }
8511
+ }
8512
+ },
8513
+ {
8514
+ name: "lut_program",
8515
+ address: "AddressLookupTab1e1111111111111111111111111"
8516
+ },
8517
+ {
8518
+ name: "system_program",
8519
+ address: "11111111111111111111111111111111"
8520
+ }
8521
+ ],
8522
+ args: [
8523
+ {
8524
+ name: "account",
8525
+ type: "pubkey"
8526
+ }
8527
+ ]
8528
+ },
8381
8529
  {
8382
8530
  name: "remove_permissioned_recovery_peers",
8383
8531
  docs: [
@@ -11173,11 +11321,6 @@ var errors = [
11173
11321
  name: "RecoveryActiveComputationExists",
11174
11322
  msg: "Cannot close recovery with active computation"
11175
11323
  },
11176
- {
11177
- code: 6712,
11178
- name: "RecoveryExecutionNotSuccess",
11179
- msg: "Callback requires successful execution status"
11180
- },
11181
11324
  {
11182
11325
  code: 6713,
11183
11326
  name: "BackupClusterNotSet",
@@ -12208,7 +12351,7 @@ var types = [
12208
12351
  name: "AcccountAccessInfo"
12209
12352
  }
12210
12353
  },
12211
- 13
12354
+ 15
12212
12355
  ]
12213
12356
  }
12214
12357
  },
@@ -12217,7 +12360,7 @@ var types = [
12217
12360
  type: {
12218
12361
  array: [
12219
12362
  "u8",
12220
- 6
12363
+ 2
12221
12364
  ]
12222
12365
  }
12223
12366
  }
@@ -15099,6 +15242,17 @@ async function initMxePart2(provider, clusterOffset, mxeProgramId, recoveryPeers
15099
15242
  .transaction();
15100
15243
  return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
15101
15244
  }
15245
+ async function claimComputationRent(provider, clusterOffset, computationOffset, confirmOptions) {
15246
+ const program = getArciumProgram(provider);
15247
+ const tx = await program.methods
15248
+ .claimComputationRent(computationOffset, clusterOffset)
15249
+ .accountsPartial({
15250
+ signer: provider.publicKey,
15251
+ comp: getComputationAccAddress(clusterOffset, computationOffset),
15252
+ })
15253
+ .transaction();
15254
+ return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
15255
+ }
15102
15256
 
15103
15257
  /**
15104
15258
  * Read local Arcium environment information from environment variables.
@@ -15228,6 +15382,7 @@ exports.RescuePrimeHash = RescuePrimeHash;
15228
15382
  exports.arcisEd25519 = arcisEd25519;
15229
15383
  exports.awaitComputationFinalization = awaitComputationFinalization;
15230
15384
  exports.buildFinalizeCompDefTx = buildFinalizeCompDefTx;
15385
+ exports.claimComputationRent = claimComputationRent;
15231
15386
  exports.createPacker = createPacker;
15232
15387
  exports.deserializeLE = deserializeLE;
15233
15388
  exports.finalizeKeyRecoveryExecution = finalizeKeyRecoveryExecution;
package/build/index.mjs CHANGED
@@ -1865,7 +1865,7 @@ function createPacker(fields, typeName = 'Packer') {
1865
1865
  var address = "Arcj82pX7HxYKLR92qvgZUAd7vGS1k4hQvAFcPATFdEQ";
1866
1866
  var metadata = {
1867
1867
  name: "arcium",
1868
- version: "0.9.2",
1868
+ version: "0.9.4",
1869
1869
  spec: "0.1.0",
1870
1870
  description: "The Arcium program"
1871
1871
  };
@@ -4880,6 +4880,40 @@ var instructions = [
4880
4880
  ]
4881
4881
  }
4882
4882
  },
4883
+ {
4884
+ name: "cluster_acc",
4885
+ pda: {
4886
+ seeds: [
4887
+ {
4888
+ kind: "const",
4889
+ value: [
4890
+ 67,
4891
+ 108,
4892
+ 117,
4893
+ 115,
4894
+ 116,
4895
+ 101,
4896
+ 114
4897
+ ]
4898
+ },
4899
+ {
4900
+ kind: "arg",
4901
+ path: "cluster_offset"
4902
+ }
4903
+ ]
4904
+ }
4905
+ },
4906
+ {
4907
+ name: "address_lookup_table",
4908
+ docs: [
4909
+ "Seeds are checked in the CPI to LUT program, so no need to check them here."
4910
+ ],
4911
+ writable: true
4912
+ },
4913
+ {
4914
+ name: "lut_program",
4915
+ address: "AddressLookupTab1e1111111111111111111111111"
4916
+ },
4883
4917
  {
4884
4918
  name: "original_mxe_program"
4885
4919
  },
@@ -6519,9 +6553,6 @@ var instructions = [
6519
6553
  },
6520
6554
  {
6521
6555
  name: "program_data",
6522
- docs: [
6523
- "The seeds constraint is only applied in non-testing builds."
6524
- ],
6525
6556
  pda: {
6526
6557
  seeds: [
6527
6558
  {
@@ -8359,6 +8390,123 @@ var instructions = [
8359
8390
  }
8360
8391
  ]
8361
8392
  },
8393
+ {
8394
+ name: "register_account_in_lut",
8395
+ discriminator: [
8396
+ 55,
8397
+ 38,
8398
+ 119,
8399
+ 20,
8400
+ 35,
8401
+ 231,
8402
+ 184,
8403
+ 236
8404
+ ],
8405
+ accounts: [
8406
+ {
8407
+ name: "signer",
8408
+ writable: true,
8409
+ signer: true
8410
+ },
8411
+ {
8412
+ name: "mxe",
8413
+ pda: {
8414
+ seeds: [
8415
+ {
8416
+ kind: "const",
8417
+ value: [
8418
+ 77,
8419
+ 88,
8420
+ 69,
8421
+ 65,
8422
+ 99,
8423
+ 99,
8424
+ 111,
8425
+ 117,
8426
+ 110,
8427
+ 116
8428
+ ]
8429
+ },
8430
+ {
8431
+ kind: "account",
8432
+ path: "mxe_program"
8433
+ }
8434
+ ]
8435
+ }
8436
+ },
8437
+ {
8438
+ name: "mxe_program"
8439
+ },
8440
+ {
8441
+ name: "address_lookup_table",
8442
+ writable: true,
8443
+ pda: {
8444
+ seeds: [
8445
+ {
8446
+ kind: "account",
8447
+ path: "mxe"
8448
+ },
8449
+ {
8450
+ kind: "account",
8451
+ path: "mxe.lut_offset_slot",
8452
+ account: "MXEAccount"
8453
+ }
8454
+ ],
8455
+ program: {
8456
+ kind: "const",
8457
+ value: [
8458
+ 2,
8459
+ 119,
8460
+ 166,
8461
+ 175,
8462
+ 151,
8463
+ 51,
8464
+ 155,
8465
+ 122,
8466
+ 200,
8467
+ 141,
8468
+ 24,
8469
+ 146,
8470
+ 201,
8471
+ 4,
8472
+ 70,
8473
+ 245,
8474
+ 0,
8475
+ 2,
8476
+ 48,
8477
+ 146,
8478
+ 102,
8479
+ 246,
8480
+ 46,
8481
+ 83,
8482
+ 193,
8483
+ 24,
8484
+ 36,
8485
+ 73,
8486
+ 130,
8487
+ 0,
8488
+ 0,
8489
+ 0
8490
+ ]
8491
+ }
8492
+ }
8493
+ },
8494
+ {
8495
+ name: "lut_program",
8496
+ address: "AddressLookupTab1e1111111111111111111111111"
8497
+ },
8498
+ {
8499
+ name: "system_program",
8500
+ address: "11111111111111111111111111111111"
8501
+ }
8502
+ ],
8503
+ args: [
8504
+ {
8505
+ name: "account",
8506
+ type: "pubkey"
8507
+ }
8508
+ ]
8509
+ },
8362
8510
  {
8363
8511
  name: "remove_permissioned_recovery_peers",
8364
8512
  docs: [
@@ -11154,11 +11302,6 @@ var errors = [
11154
11302
  name: "RecoveryActiveComputationExists",
11155
11303
  msg: "Cannot close recovery with active computation"
11156
11304
  },
11157
- {
11158
- code: 6712,
11159
- name: "RecoveryExecutionNotSuccess",
11160
- msg: "Callback requires successful execution status"
11161
- },
11162
11305
  {
11163
11306
  code: 6713,
11164
11307
  name: "BackupClusterNotSet",
@@ -12189,7 +12332,7 @@ var types = [
12189
12332
  name: "AcccountAccessInfo"
12190
12333
  }
12191
12334
  },
12192
- 13
12335
+ 15
12193
12336
  ]
12194
12337
  }
12195
12338
  },
@@ -12198,7 +12341,7 @@ var types = [
12198
12341
  type: {
12199
12342
  array: [
12200
12343
  "u8",
12201
- 6
12344
+ 2
12202
12345
  ]
12203
12346
  }
12204
12347
  }
@@ -15080,6 +15223,17 @@ async function initMxePart2(provider, clusterOffset, mxeProgramId, recoveryPeers
15080
15223
  .transaction();
15081
15224
  return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
15082
15225
  }
15226
+ async function claimComputationRent(provider, clusterOffset, computationOffset, confirmOptions) {
15227
+ const program = getArciumProgram(provider);
15228
+ const tx = await program.methods
15229
+ .claimComputationRent(computationOffset, clusterOffset)
15230
+ .accountsPartial({
15231
+ signer: provider.publicKey,
15232
+ comp: getComputationAccAddress(clusterOffset, computationOffset),
15233
+ })
15234
+ .transaction();
15235
+ return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
15236
+ }
15083
15237
 
15084
15238
  /**
15085
15239
  * Read local Arcium environment information from environment variables.
@@ -15185,4 +15339,4 @@ async function awaitComputationFinalization(provider, computationOffset, mxeProg
15185
15339
  : new Error(timeoutMsg);
15186
15340
  }
15187
15341
 
15188
- export { ARCIUM_ADDR, ARCIUM_IDL, Aes128Cipher, Aes192Cipher, Aes256Cipher, ArcisModule, ArcisType, ArcisValueField, CSplRescueCipher, CURVE25519_BASE_FIELD, CURVE25519_SCALAR_FIELD, CURVE25519_SCALAR_FIELD_MODULUS, IntegerInfo, Matrix, RescueCipher, RescueDesc, RescuePrimeHash, arcisEd25519, awaitComputationFinalization, buildFinalizeCompDefTx, createPacker, deserializeLE, finalizeKeyRecoveryExecution, generateRandomFieldElem, getArciumAccountBaseSeed, getArciumEnv, getArciumProgram, getArciumProgramId, getArxNodeAccAddress, getCircuitState, getClockAccAddress, getClusterAccAddress, getCompDefAccAddress, getCompDefAccOffset, getComputationAccAddress, getComputationsInMempool, getExecutingPoolAccAddress, getExecutingPoolAccInfo, getFeePoolAccAddress, getLookupTableAddress, getMXEAccAddress, getMXEArcisEd25519VerifyingKey, getMXEPublicKey, getMempoolAccAddress, getMempoolAccInfo, getMempoolPriorityFeeStats, getMxeRecoveryAccAddress, getRawCircuitAccAddress, getRecoveryClusterAccAddress, initKeyRecoveryExecution, initMxePart1, initMxePart2, isNullRef, positiveModulo, queueKeyRecoveryInit, randMatrix, recoverMxe, serializeLE, sha256, submitKeyRecoveryShare, toVec, uploadCircuit };
15342
+ export { ARCIUM_ADDR, ARCIUM_IDL, Aes128Cipher, Aes192Cipher, Aes256Cipher, ArcisModule, ArcisType, ArcisValueField, CSplRescueCipher, CURVE25519_BASE_FIELD, CURVE25519_SCALAR_FIELD, CURVE25519_SCALAR_FIELD_MODULUS, IntegerInfo, Matrix, RescueCipher, RescueDesc, RescuePrimeHash, arcisEd25519, awaitComputationFinalization, buildFinalizeCompDefTx, claimComputationRent, createPacker, deserializeLE, finalizeKeyRecoveryExecution, generateRandomFieldElem, getArciumAccountBaseSeed, getArciumEnv, getArciumProgram, getArciumProgramId, getArxNodeAccAddress, getCircuitState, getClockAccAddress, getClusterAccAddress, getCompDefAccAddress, getCompDefAccOffset, getComputationAccAddress, getComputationsInMempool, getExecutingPoolAccAddress, getExecutingPoolAccInfo, getFeePoolAccAddress, getLookupTableAddress, getMXEAccAddress, getMXEArcisEd25519VerifyingKey, getMXEPublicKey, getMempoolAccAddress, getMempoolAccInfo, getMempoolPriorityFeeStats, getMxeRecoveryAccAddress, getRawCircuitAccAddress, getRecoveryClusterAccAddress, initKeyRecoveryExecution, initMxePart1, initMxePart2, isNullRef, positiveModulo, queueKeyRecoveryInit, randMatrix, recoverMxe, serializeLE, sha256, submitKeyRecoveryShare, toVec, uploadCircuit };
@@ -0,0 +1,26 @@
1
+ import { ArcisType } from "./arcisType.js";
2
+ /**
3
+ * Container for circuit type definitions.
4
+ * Loaded from generated JSON files by build tools -- not typically used directly.
5
+ * @internal
6
+ */
7
+ export declare class ArcisModule {
8
+ /** Map of type name to parsed ArcisType. */
9
+ types: {
10
+ [typeName: string]: ArcisType;
11
+ };
12
+ constructor(types: {
13
+ [typeName: string]: ArcisType;
14
+ });
15
+ /**
16
+ * Parse module from JSON object (as produced by the Arcium compiler).
17
+ * @param json - Raw JSON object with type name keys.
18
+ */
19
+ static fromJson(json: unknown): ArcisModule;
20
+ /**
21
+ * Load module from a JSON file on disk.
22
+ * @param path - Absolute or relative path to the JSON file.
23
+ */
24
+ static loadFromFile(path: string): ArcisModule;
25
+ }
26
+ //# sourceMappingURL=arcisModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arcisModule.d.ts","sourceRoot":"","sources":["../../../src/arcis/arcisModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAGzC;;;;GAIG;AACH,qBAAa,WAAW;IACpB,4CAA4C;IAC5C,KAAK,EAAE;QAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;KAAC,CAAC;gBAE3B,KAAK,EAAE;QAAC,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAA;KAAC;IAIlD;;;OAGG;WACW,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW;IASlD;;;OAGG;WACW,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW;CAKxD"}
@@ -0,0 +1,76 @@
1
+ import { DataSize } from "./packing.js";
2
+ /**
3
+ * Field definition for circuit input/output packing.
4
+ * Pass an array of these to {@link createPacker} to create a type-safe packer.
5
+ *
6
+ * @example
7
+ * import { FieldInfo } from '@arcium-hq/client';
8
+ *
9
+ * const fields: FieldInfo[] = [
10
+ * { name: 'amount', type: { Integer: { signed: false, width: 64 } } },
11
+ * { name: 'active', type: 'Bool' },
12
+ * ];
13
+ */
14
+ export interface FieldInfo {
15
+ /** Field name matching the circuit parameter. For array types, use indexed notation (`bytes[0]`, `bytes[1]`) - the packer groups these back into arrays on unpack. */
16
+ name: string;
17
+ /** Field type: Integer with sign/width, Bool, FullInteger (256-bit), Float, or Pubkey. */
18
+ type: {
19
+ Integer: {
20
+ signed: boolean;
21
+ width: number;
22
+ };
23
+ } | 'Bool' | 'FullInteger' | 'Float' | 'Pubkey';
24
+ }
25
+ declare enum ArcisValueKind {
26
+ Integer = 0,
27
+ FullInteger = 1,
28
+ Bool = 2,
29
+ Float = 3,
30
+ Pubkey = 4
31
+ }
32
+ /**
33
+ * Integer type metadata. Used internally by packer.
34
+ * @internal
35
+ */
36
+ export declare class IntegerInfo {
37
+ signed: boolean;
38
+ width: bigint;
39
+ constructor(signed: boolean, width: bigint);
40
+ static fromJson(json: {
41
+ "signed": boolean;
42
+ "width": number;
43
+ }): IntegerInfo;
44
+ minValue(): bigint;
45
+ isWithinBounds(b: bigint): boolean;
46
+ name(): string;
47
+ }
48
+ /**
49
+ * Runtime field representation. Used internally by packer.
50
+ * @internal
51
+ */
52
+ export declare class ArcisValueField {
53
+ name: string;
54
+ kind: ArcisValueKind;
55
+ info: IntegerInfo | undefined;
56
+ constructor(name: string, kind: ArcisValueKind, info?: IntegerInfo);
57
+ static fromJson(json: unknown): ArcisValueField;
58
+ toBigInt(arg: unknown): bigint;
59
+ fromBigInt(arg: bigint): boolean | number | bigint | Uint8Array;
60
+ static fromFieldInfo(info: FieldInfo): ArcisValueField;
61
+ toDataSize(index: number): DataSize;
62
+ }
63
+ /**
64
+ * Type container for pack/unpack operations. Used internally by packer.
65
+ * @internal
66
+ */
67
+ export declare class ArcisType {
68
+ name: string;
69
+ fields: ArcisValueField[];
70
+ constructor(name: string, fields: ArcisValueField[]);
71
+ pack(rawData: unknown[]): bigint[];
72
+ unpack(packed: bigint[]): (boolean | number | bigint | Uint8Array)[];
73
+ static fromJson(name: string, json: unknown): ArcisType;
74
+ }
75
+ export {};
76
+ //# sourceMappingURL=arcisType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arcisType.d.ts","sourceRoot":"","sources":["../../../src/arcis/arcisType.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,QAAQ,EAAC,MAAM,cAAc,CAAC;AASpD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,SAAS;IACtB,sKAAsK;IACtK,IAAI,EAAE,MAAM,CAAC;IACb,0FAA0F;IAC1F,IAAI,EAAE;QAAE,OAAO,EAAE;YAAE,MAAM,EAAE,OAAO,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,GAAG,MAAM,GAAG,aAAa,GAAG,OAAO,GAAG,QAAQ,CAAC;CACvG;AAED,aAAK,cAAc;IACf,OAAO,IAAA;IACP,WAAW,IAAA;IACX,IAAI,IAAA;IACJ,KAAK,IAAA;IACL,MAAM,IAAA;CACT;AAED;;;GAGG;AACH,qBAAa,WAAW;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;gBACF,MAAM,EAAC,OAAO,EAAE,KAAK,EAAE,MAAM;WAI3B,QAAQ,CAAC,IAAI,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAC,GAAG,WAAW;IAIhF,QAAQ,IAAI,MAAM;IAGlB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAKlC,IAAI,IAAI,MAAM;CAGjB;AAED;;;GAGG;AACH,qBAAa,eAAe;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,WAAW,GAAG,SAAS,CAAC;gBAClB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,CAAC,EAAE,WAAW;WAKpD,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,eAAe;IA+BtD,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM;IA8D9B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU;WA0CjD,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,eAAe;IAwB7D,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;CAetC;AAED;;;GAGG;AACH,qBAAa,SAAS;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,EAAE,CAAC;gBACd,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE;IAKnD,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE;IAelC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,UAAU,CAAC,EAAE;WAgBtD,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,SAAS;CAMjE"}
@@ -0,0 +1,63 @@
1
+ import { FieldInfo } from "./arcisType.js";
2
+ /**
3
+ * Type-safe packer for converting between TypeScript objects and circuit-compatible bigint arrays.
4
+ *
5
+ * @template TInput - Input object type with field names as keys
6
+ * @template TOutput - Output object type (typically same structure as input)
7
+ */
8
+ export interface Packer<TInput, TOutput> {
9
+ /**
10
+ * Pack input values into bigint array for circuit execution.
11
+ * @param data - Object with field values matching the packer's field definitions.
12
+ * @returns Packed bigint array ready for encryption.
13
+ * @throws Error if a required field is missing.
14
+ */
15
+ pack(data: TInput): bigint[];
16
+ /**
17
+ * Unpack circuit output back to typed object.
18
+ * @param packed - Bigint array from decrypted circuit output.
19
+ * @returns Typed object with field values.
20
+ */
21
+ unpack(packed: bigint[]): TOutput;
22
+ }
23
+ /** Extracts base field name from array-indexed names: "bytes[0]" -> "bytes" */
24
+ type ExtractBaseName<T extends string> = T extends `${infer Base}[${string}]` ? Base : T;
25
+ /** Extracts all base field names from a readonly FieldInfo array. */
26
+ type FieldBaseNames<T extends readonly FieldInfo[]> = ExtractBaseName<T[number]['name']>;
27
+ /**
28
+ * Validates that field base names match TInput keys. Returns `never` on mismatch.
29
+ * Only validates when using `as const`; skipped if types widen to `string`.
30
+ */
31
+ type ValidateFieldNames<TInput, TFields extends readonly FieldInfo[]> = string extends FieldBaseNames<TFields> ? TFields : FieldBaseNames<TFields> extends keyof TInput ? TFields : never;
32
+ /**
33
+ * Create a type-safe packer from field definitions.
34
+ *
35
+ * Use `as const` on the fields array to enable compile-time field name validation.
36
+ *
37
+ * @param fields - Array of {@link FieldInfo} objects defining each field's name and type.
38
+ * @param typeName - Optional name for debugging (default: 'Packer').
39
+ * @returns Packer instance with pack() and unpack() methods.
40
+ * @throws TypeError if field types don't match expected values during pack/unpack.
41
+ * @throws RangeError if array index is out of bounds.
42
+ *
43
+ * @example
44
+ * import { createPacker } from '@arcium-hq/client';
45
+ *
46
+ * // Define fields matching your circuit's input type
47
+ * const fields = [
48
+ * { name: 'a', type: { Integer: { signed: false, width: 32 } } },
49
+ * { name: 'b', type: { Integer: { signed: false, width: 32 } } },
50
+ * ] as const;
51
+ *
52
+ * // Create packer with explicit input/output types
53
+ * const packer = createPacker<{ a: number; b: number }, { a: bigint; b: bigint }>(fields);
54
+ *
55
+ * // Pack values for circuit input
56
+ * const packed = packer.pack({ a: 10, b: 20 });
57
+ *
58
+ * // Unpack circuit output (from decrypted computation result)
59
+ * const result = packer.unpack(decryptedOutput);
60
+ */
61
+ export declare function createPacker<TInput extends Record<string, unknown>, TOutput extends Record<string, unknown>, const TFields extends readonly FieldInfo[] = readonly FieldInfo[]>(fields: TFields & ValidateFieldNames<TInput, TFields>, typeName?: string): Packer<TInput, TOutput>;
62
+ export {};
63
+ //# sourceMappingURL=packer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packer.d.ts","sourceRoot":"","sources":["../../../src/arcis/packer.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,WAAW,MAAM,CAAC,MAAM,EAAE,OAAO;IACnC;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAE7B;;;;OAIG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;CACrC;AAED,+EAA+E;AAC/E,KAAK,eAAe,CAAC,CAAC,SAAS,MAAM,IACjC,CAAC,SAAS,GAAG,MAAM,IAAI,IAAI,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC;AAEpD,qEAAqE;AACrE,KAAK,cAAc,CAAC,CAAC,SAAS,SAAS,SAAS,EAAE,IAC9C,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAEvC;;;GAGG;AACH,KAAK,kBAAkB,CAAC,MAAM,EAAE,OAAO,SAAS,SAAS,SAAS,EAAE,IAChE,MAAM,SAAS,cAAc,CAAC,OAAO,CAAC,GAChC,OAAO,GACP,cAAc,CAAC,OAAO,CAAC,SAAS,MAAM,MAAM,GACxC,OAAO,GACP,KAAK,CAAC;AAmDpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,YAAY,CACxB,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,KAAK,CAAC,OAAO,SAAS,SAAS,SAAS,EAAE,GAAG,SAAS,SAAS,EAAE,EAEjE,MAAM,EAAE,OAAO,GAAG,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,EACrD,QAAQ,GAAE,MAAiB,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAsBzB"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Size descriptor for a single field in circuit packing.
3
+ * A "full" field occupies an entire slot; partial fields are bin-packed together.
4
+ * @internal
5
+ */
6
+ export declare class DataSize {
7
+ /** Whether this field occupies a full slot. */
8
+ isFull: boolean;
9
+ /** Bit width of the field (0 if full). */
10
+ size: number;
11
+ /** Original index in the fields array. */
12
+ index: number;
13
+ constructor(index: number, size?: number);
14
+ }
15
+ /**
16
+ * Packed location of a field within the slot array.
17
+ * @internal
18
+ */
19
+ export declare class PackLocation {
20
+ /** Slot index in the packed array. */
21
+ index: number;
22
+ /** Bit offset within the slot. */
23
+ offset: number;
24
+ constructor(index: number, offset: number);
25
+ }
26
+ /**
27
+ * Pack field sizes into minimum slots using the Arcium packing size (214 bits).
28
+ * @param arr - Array of field size descriptors.
29
+ * @returns Tuple of [total slot count, pack location for each input field].
30
+ * @internal
31
+ */
32
+ export declare function arcisPacking(arr: DataSize[]): [number, PackLocation[]];
33
+ //# sourceMappingURL=packing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packing.d.ts","sourceRoot":"","sources":["../../../src/arcis/packing.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,QAAQ;IACjB,+CAA+C;IAC/C,MAAM,EAAE,OAAO,CAAC;IAChB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,0CAA0C;IAC1C,KAAK,EAAE,MAAM,CAAC;gBAEF,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAM3C;AAeD;;;GAGG;AACH,qBAAa,YAAY;IACrB,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,kCAAkC;IAClC,MAAM,EAAE,MAAM,CAAC;gBAEH,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI5C;AA0DD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,EAAE,CAAC,CAEtE"}