@arcium-hq/client 0.9.7 → 0.10.1

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "address": "3y53DGSaqMNyiwpMkoHqscEwTV2U29aBW23vibQjw8mL",
2
+ "address": "6nZ37t1FKG6irnm9nDhDra7i92HWmtLinRtpSj8MEQHN",
3
3
  "metadata": {
4
4
  "name": "arcium_staking",
5
5
  "version": "0.1.0",
@@ -3734,19 +3734,6 @@
3734
3734
  }
3735
3735
  ],
3736
3736
  "accounts": [
3737
- {
3738
- "name": "ClockAccount",
3739
- "discriminator": [
3740
- 152,
3741
- 171,
3742
- 158,
3743
- 195,
3744
- 75,
3745
- 61,
3746
- 51,
3747
- 8
3748
- ]
3749
- },
3750
3737
  {
3751
3738
  "name": "DelegatedStakingAccount",
3752
3739
  "discriminator": [
@@ -5,7 +5,7 @@
5
5
  * IDL can be found at `target/idl/arcium_staking.json`.
6
6
  */
7
7
  export type ArciumStaking = {
8
- "address": "3y53DGSaqMNyiwpMkoHqscEwTV2U29aBW23vibQjw8mL",
8
+ "address": "6nZ37t1FKG6irnm9nDhDra7i92HWmtLinRtpSj8MEQHN",
9
9
  "metadata": {
10
10
  "name": "arciumStaking",
11
11
  "version": "0.1.0",
@@ -3740,19 +3740,6 @@ export type ArciumStaking = {
3740
3740
  }
3741
3741
  ],
3742
3742
  "accounts": [
3743
- {
3744
- "name": "clockAccount",
3745
- "discriminator": [
3746
- 152,
3747
- 171,
3748
- 158,
3749
- 195,
3750
- 75,
3751
- 61,
3752
- 51,
3753
- 8
3754
- ]
3755
- },
3756
3743
  {
3757
3744
  "name": "delegatedStakingAccount",
3758
3745
  "discriminator": [
package/src/onchain.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Program, AnchorProvider } from '@coral-xyz/anchor';
2
- import * as anchor from '@coral-xyz/anchor';
1
+ import { Program, AnchorProvider } from '@anchor-lang/core';
2
+ import * as anchor from '@anchor-lang/core';
3
3
  import { ConfirmOptions, PublicKey } from '@solana/web3.js';
4
4
  import { ARCIUM_IDL, ArciumIdlType } from './idl/index.js';
5
5
  import { sha256 } from './cryptography/cryptography.js';
@@ -18,8 +18,6 @@ import {
18
18
  getArciumProgramId,
19
19
  getMXEAccAddress,
20
20
  getComputationAccAddress,
21
- getMempoolAccAddress,
22
- getExecutingPoolAccAddress,
23
21
  getFeePoolAccAddress,
24
22
  getRawCircuitAccAddress,
25
23
  getLookupTableAddress,
@@ -465,38 +463,6 @@ export async function uploadCircuit(
465
463
  return sigs;
466
464
  }
467
465
 
468
- /**
469
- * Queue a key recovery initialization for an MXE on a given cluster.
470
- * @param provider - Anchor provider for signing and sending.
471
- * @param clusterOffset - Cluster offset to recover keys from.
472
- * @param mxeProgramId - Public key of the MXE program.
473
- * @param confirmOptions - Transaction confirmation options.
474
- * @returns Array of transaction signatures.
475
- */
476
- export async function queueKeyRecoveryInit(
477
- provider: AnchorProvider,
478
- clusterOffset: number,
479
- mxeProgramId: anchor.web3.PublicKey,
480
- confirmOptions?: ConfirmOptions,
481
- ): Promise<string[]> {
482
- const program = getArciumProgram(provider);
483
- const sigs: string[] = [];
484
- const queueKeyRecoveryInitTx = await program.methods
485
- .queueKeyRecoveryInit(clusterOffset, mxeProgramId)
486
- .accounts({
487
- signer: provider.publicKey,
488
- mxeProgram: mxeProgramId,
489
- })
490
- .transaction();
491
- sigs.push(await signAndSendWithBlockhash(
492
- provider,
493
- queueKeyRecoveryInitTx,
494
- await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || "confirmed" }),
495
- confirmOptions,
496
- ));
497
- return sigs;
498
- }
499
-
500
466
  /**
501
467
  * Build a transaction to finalize a computation definition.
502
468
  * @param provider - Anchor provider to use for transactions.
@@ -689,7 +655,9 @@ async function buildUploadCircuitTx(
689
655
  let bytesInner = bytes;
690
656
 
691
657
  if (bytesInner.length < MAX_UPLOAD_PER_TX_BYTES) {
692
- const paddedBytes = Buffer.allocUnsafe(MAX_UPLOAD_PER_TX_BYTES);
658
+ // Zero-fill the padding; allocUnsafe would leak prior process heap
659
+ // (tx bytes, keys) into public ledger history (R-01).
660
+ const paddedBytes = Buffer.alloc(MAX_UPLOAD_PER_TX_BYTES);
693
661
  paddedBytes.set(bytesInner);
694
662
  bytesInner = paddedBytes;
695
663
  }
@@ -772,155 +740,6 @@ function getCompDefAccPDA(arciumProgramId: anchor.web3.PublicKey, mxeProgramId:
772
740
  return anchor.web3.PublicKey.findProgramAddressSync([Buffer.from(COMP_DEF_ACC_SEED, 'utf-8'), mxeProgramId.toBuffer(), offset], arciumProgramId)[0];
773
741
  }
774
742
 
775
- /**
776
- * Set an MXE to Recovery status, initiating the key recovery process.
777
- * @param provider - Anchor provider to use for transactions.
778
- * @param mxeProgramId - Public key of the MXE program to recover.
779
- * @param confirmOptions - Transaction confirmation options.
780
- * @returns Transaction signature.
781
- */
782
- export async function recoverMxe(
783
- provider: AnchorProvider,
784
- mxeProgramId: anchor.web3.PublicKey,
785
- confirmOptions?: ConfirmOptions,
786
- ): Promise<string> {
787
- const program = getArciumProgram(provider);
788
- const tx = await program.methods
789
- .recoverMxe(mxeProgramId)
790
- .accountsPartial({
791
- authority: provider.publicKey,
792
- mxeProgram: mxeProgramId,
793
- })
794
- .transaction();
795
- return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
796
- }
797
-
798
- /**
799
- * Initialize key recovery execution by creating the MxeRecoveryAccount and
800
- * registering the key_recovery_final computation definition on the backup MXE.
801
- * This is split into two parts due to Solana's 10KB per-instruction allocation limit.
802
- * @param provider - Anchor provider to use for transactions.
803
- * @param originalMxeProgramId - Public key of the original MXE program being recovered.
804
- * @param backupMxeProgramId - Public key of the backup MXE program that will take over.
805
- * @param confirmOptions - Transaction confirmation options.
806
- * @returns Transaction signature from part2.
807
- */
808
- export async function initKeyRecoveryExecution(
809
- provider: AnchorProvider,
810
- originalMxeProgramId: anchor.web3.PublicKey,
811
- backupMxeProgramId: anchor.web3.PublicKey,
812
- confirmOptions?: ConfirmOptions,
813
- ): Promise<string> {
814
- // Part 1: Create MxeRecoveryAccount with partial size
815
- const program = getArciumProgram(provider);
816
- const tx1 = await program.methods
817
- .initKeyRecoveryExecutionPart1(originalMxeProgramId, backupMxeProgramId)
818
- .accountsPartial({
819
- payer: provider.publicKey,
820
- originalMxeProgram: originalMxeProgramId,
821
- backupMxeProgram: backupMxeProgramId,
822
- })
823
- .transaction();
824
- await signAndSendWithBlockhash(provider, tx1, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
825
-
826
- // Part 2: Reallocate to full size and create computation definition
827
- const tx2 = await program.methods
828
- .initKeyRecoveryExecutionPart2(originalMxeProgramId, backupMxeProgramId)
829
- .accountsPartial({
830
- authority: provider.publicKey,
831
- payer: provider.publicKey,
832
- originalMxeProgram: originalMxeProgramId,
833
- backupMxeProgram: backupMxeProgramId,
834
- })
835
- .transaction();
836
- return signAndSendWithBlockhash(provider, tx2, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
837
- }
838
-
839
- /**
840
- * Submit a re-encrypted key recovery share from a recovery peer.
841
- * Recovery peers must decrypt shares using their x25519 private key and re-encrypt
842
- * them for the backup MXE before submission.
843
- * @param provider - Anchor provider to use for transactions.
844
- * @param originalMxeProgramId - Public key of the original MXE program being recovered.
845
- * @param backupMxeProgramId - Public key of the backup MXE program.
846
- * @param peerOffset - Offset of the recovery peer.
847
- * @param peerIndex - Index of this peer in the recovery peers list.
848
- * @param share - Re-encrypted share: 5 field elements of 32 bytes each (160 bytes total).
849
- * @param confirmOptions - Transaction confirmation options.
850
- * @returns Transaction signature.
851
- */
852
- export async function submitKeyRecoveryShare(
853
- provider: AnchorProvider,
854
- originalMxeProgramId: anchor.web3.PublicKey,
855
- backupMxeProgramId: anchor.web3.PublicKey,
856
- peerOffset: number,
857
- peerIndex: number,
858
- share: number[][] | Uint8Array[],
859
- confirmOptions?: ConfirmOptions,
860
- ): Promise<string> {
861
- const program = getArciumProgram(provider);
862
- // Convert to array of 5 elements, each 32 bytes
863
- const shareArrays: number[][] = share.map(elem => Array.from(elem));
864
- if (shareArrays.length !== 5) {
865
- throw new Error(`Share must contain exactly 5 elements, got ${shareArrays.length}`);
866
- }
867
- for (let i = 0; i < 5; i++) {
868
- if (shareArrays[i].length !== 32) {
869
- throw new Error(`Share element ${i} must be exactly 32 bytes, got ${shareArrays[i].length}`);
870
- }
871
- }
872
- const tx = await program.methods
873
- .submitKeyRecoveryShare(
874
- originalMxeProgramId,
875
- backupMxeProgramId,
876
- peerOffset,
877
- peerIndex,
878
- shareArrays as number[][],
879
- )
880
- .accountsPartial({
881
- signer: provider.publicKey,
882
- originalMxeProgram: originalMxeProgramId,
883
- backupMxeProgram: backupMxeProgramId,
884
- })
885
- .transaction();
886
- return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
887
- }
888
-
889
- /**
890
- * Finalize key recovery execution after the submission threshold is met.
891
- * This queues the key_recovery_finalize MPC computation on the backup cluster.
892
- * @param provider - Anchor provider to use for transactions.
893
- * @param originalMxeProgramId - Public key of the original MXE program being recovered.
894
- * @param backupMxeProgramId - Public key of the backup MXE program.
895
- * @param clusterOffset - Cluster offset where the backup MXE is deployed.
896
- * @param keyRecoveryFinalizeOffset - Computation offset for the key_recovery_finalize computation.
897
- * @param confirmOptions - Transaction confirmation options.
898
- * @returns Transaction signature.
899
- */
900
- export async function finalizeKeyRecoveryExecution(
901
- provider: AnchorProvider,
902
- originalMxeProgramId: anchor.web3.PublicKey,
903
- backupMxeProgramId: anchor.web3.PublicKey,
904
- clusterOffset: number,
905
- keyRecoveryFinalizeOffset: anchor.BN,
906
- confirmOptions?: ConfirmOptions,
907
- ): Promise<string> {
908
- const program = getArciumProgram(provider);
909
- const tx = await program.methods
910
- .finalizeKeyRecoveryExecution(originalMxeProgramId, backupMxeProgramId, clusterOffset)
911
- .accountsPartial({
912
- authority: provider.publicKey,
913
- payer: provider.publicKey,
914
- keyRecoveryFinalizeComputation: getComputationAccAddress(clusterOffset, keyRecoveryFinalizeOffset),
915
- executingPool: getExecutingPoolAccAddress(clusterOffset),
916
- mempool: getMempoolAccAddress(clusterOffset),
917
- originalMxeProgram: originalMxeProgramId,
918
- backupMxeProgram: backupMxeProgramId,
919
- })
920
- .transaction();
921
- return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
922
- }
923
-
924
743
  /**
925
744
  * Initialize an MXE (part 1). Due to Solana's 10KB per-instruction allocation limit,
926
745
  * this only partially allocates recovery_cluster_acc.
@@ -965,9 +784,9 @@ export async function initMxePart2(
965
784
  provider: AnchorProvider,
966
785
  clusterOffset: number,
967
786
  mxeProgramId: anchor.web3.PublicKey,
968
- recoveryPeers: number[],
969
787
  keygenOffset: anchor.BN,
970
788
  keyRecoveryInitOffset: anchor.BN,
789
+ recoveryPeers: number[],
971
790
  lutOffset: anchor.BN,
972
791
  mxeAuthority?: anchor.web3.PublicKey,
973
792
  confirmOptions?: ConfirmOptions,
package/src/pda.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PublicKey, AddressLookupTableProgram } from '@solana/web3.js';
2
- import * as anchor from '@coral-xyz/anchor';
2
+ import * as anchor from '@anchor-lang/core';
3
3
  import {
4
4
  ARX_NODE_ACC_SEED,
5
5
  CLOCK_ACC_SEED,
package/src/utils.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as anchor from '@coral-xyz/anchor';
1
+ import * as anchor from '@anchor-lang/core';
2
2
  import { CURVE25519_BASE_FIELD } from './cryptography/rescueDesc.js';
3
3
  import { ctAdd, ctLt, ctSelect, ctSignBit, ctSub, verifyBinSize } from './ctUtils.js';
4
4
  import { ArciumIdlType } from './idl/index.js';