@arcium-hq/client 0.9.1 → 0.9.3
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/build/index.cjs +15 -3
- package/build/index.mjs +15 -4
- package/build/types/arcis/arcisModule.d.ts +26 -0
- package/build/types/arcis/arcisModule.d.ts.map +1 -0
- package/build/types/arcis/arcisType.d.ts +76 -0
- package/build/types/arcis/arcisType.d.ts.map +1 -0
- package/build/types/arcis/packer.d.ts +63 -0
- package/build/types/arcis/packer.d.ts.map +1 -0
- package/build/types/arcis/packing.d.ts +33 -0
- package/build/types/arcis/packing.d.ts.map +1 -0
- package/build/types/callback.d.ts +21 -0
- package/build/types/callback.d.ts.map +1 -0
- package/build/types/constants.d.ts +101 -0
- package/build/types/constants.d.ts.map +1 -0
- package/build/types/cryptography/aes128Cipher.d.ts +14 -0
- package/build/types/cryptography/aes128Cipher.d.ts.map +1 -0
- package/build/types/cryptography/aes192Cipher.d.ts +14 -0
- package/build/types/cryptography/aes192Cipher.d.ts.map +1 -0
- package/build/types/cryptography/aes256Cipher.d.ts +14 -0
- package/build/types/cryptography/aes256Cipher.d.ts.map +1 -0
- package/build/types/cryptography/aesCtrCipher.d.ts +36 -0
- package/build/types/cryptography/aesCtrCipher.d.ts.map +1 -0
- package/build/types/cryptography/arcisEd25519.d.ts +8 -0
- package/build/types/cryptography/arcisEd25519.d.ts.map +1 -0
- package/build/types/cryptography/cSplRescueCipher.d.ts +29 -0
- package/build/types/cryptography/cSplRescueCipher.d.ts.map +1 -0
- package/build/types/cryptography/cryptography.d.ts +38 -0
- package/build/types/cryptography/cryptography.d.ts.map +1 -0
- package/build/types/cryptography/hkdf.d.ts +37 -0
- package/build/types/cryptography/hkdf.d.ts.map +1 -0
- package/build/types/cryptography/hmac.d.ts +22 -0
- package/build/types/cryptography/hmac.d.ts.map +1 -0
- package/build/types/cryptography/rescueCipher.d.ts +29 -0
- package/build/types/cryptography/rescueCipher.d.ts.map +1 -0
- package/build/types/cryptography/rescueCipherCommon.d.ts +45 -0
- package/build/types/cryptography/rescueCipherCommon.d.ts.map +1 -0
- package/build/types/cryptography/rescueDesc.d.ts +80 -0
- package/build/types/cryptography/rescueDesc.d.ts.map +1 -0
- package/build/types/cryptography/rescuePrimeHash.d.ts +23 -0
- package/build/types/cryptography/rescuePrimeHash.d.ts.map +1 -0
- package/build/types/ctUtils.d.ts +50 -0
- package/build/types/ctUtils.d.ts.map +1 -0
- package/build/{index.d.ts → types/idl/arcium.d.ts} +5 -901
- package/build/types/idl/arcium.d.ts.map +1 -0
- package/build/types/idl/arcium_staking.d.ts +4589 -0
- package/build/types/idl/arcium_staking.d.ts.map +1 -0
- package/build/types/idl/index.d.ts +15 -0
- package/build/types/idl/index.d.ts.map +1 -0
- package/build/types/index.d.ts +33 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/localEnv.d.ts +15 -0
- package/build/types/localEnv.d.ts.map +1 -0
- package/build/types/matrix.d.ts +39 -0
- package/build/types/matrix.d.ts.map +1 -0
- package/build/types/onchain.d.ts +223 -0
- package/build/types/onchain.d.ts.map +1 -0
- package/build/types/pda.d.ts +89 -0
- package/build/types/pda.d.ts.map +1 -0
- package/build/types/utils.d.ts +65 -0
- package/build/types/utils.d.ts.map +1 -0
- package/package.json +6 -6
- package/src/arcis/arcisModule.ts +39 -0
- package/src/arcis/arcisType.ts +303 -0
- package/src/arcis/packer.ts +152 -0
- package/src/arcis/packing.ts +115 -0
- package/src/callback.ts +101 -0
- package/src/constants.ts +104 -0
- package/src/cryptography/aes128Cipher.ts +16 -0
- package/src/cryptography/aes192Cipher.ts +16 -0
- package/src/cryptography/aes256Cipher.ts +16 -0
- package/src/cryptography/aesCtrCipher.ts +84 -0
- package/src/cryptography/arcisEd25519.ts +96 -0
- package/src/cryptography/cSplRescueCipher.ts +41 -0
- package/src/cryptography/cryptography.ts +82 -0
- package/src/cryptography/hkdf.ts +58 -0
- package/src/cryptography/hmac.ts +66 -0
- package/src/cryptography/rescueCipher.ts +41 -0
- package/src/cryptography/rescueCipherCommon.ts +211 -0
- package/src/cryptography/rescueDesc.ts +492 -0
- package/src/cryptography/rescuePrimeHash.ts +72 -0
- package/src/ctUtils.ts +124 -0
- package/src/idl/arcium.json +12281 -0
- package/src/idl/arcium.ts +12287 -0
- package/src/idl/arcium_staking.json +4582 -0
- package/src/idl/arcium_staking.ts +4588 -0
- package/src/idl/index.ts +20 -0
- package/src/index.ts +32 -0
- package/src/localEnv.ts +39 -0
- package/src/matrix.ts +215 -0
- package/src/onchain.ts +1020 -0
- package/src/pda.ts +203 -0
- 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.
|
|
1887
|
+
version: "0.9.3",
|
|
1888
1888
|
spec: "0.1.0",
|
|
1889
1889
|
description: "The Arcium program"
|
|
1890
1890
|
};
|
|
@@ -12208,7 +12208,7 @@ var types = [
|
|
|
12208
12208
|
name: "AcccountAccessInfo"
|
|
12209
12209
|
}
|
|
12210
12210
|
},
|
|
12211
|
-
|
|
12211
|
+
15
|
|
12212
12212
|
]
|
|
12213
12213
|
}
|
|
12214
12214
|
},
|
|
@@ -12217,7 +12217,7 @@ var types = [
|
|
|
12217
12217
|
type: {
|
|
12218
12218
|
array: [
|
|
12219
12219
|
"u8",
|
|
12220
|
-
|
|
12220
|
+
2
|
|
12221
12221
|
]
|
|
12222
12222
|
}
|
|
12223
12223
|
}
|
|
@@ -15099,6 +15099,17 @@ async function initMxePart2(provider, clusterOffset, mxeProgramId, recoveryPeers
|
|
|
15099
15099
|
.transaction();
|
|
15100
15100
|
return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
|
|
15101
15101
|
}
|
|
15102
|
+
async function claimComputationRent(provider, clusterOffset, computationOffset, confirmOptions) {
|
|
15103
|
+
const program = getArciumProgram(provider);
|
|
15104
|
+
const tx = await program.methods
|
|
15105
|
+
.claimComputationRent(computationOffset, clusterOffset)
|
|
15106
|
+
.accountsPartial({
|
|
15107
|
+
signer: provider.publicKey,
|
|
15108
|
+
comp: getComputationAccAddress(clusterOffset, computationOffset),
|
|
15109
|
+
})
|
|
15110
|
+
.transaction();
|
|
15111
|
+
return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
|
|
15112
|
+
}
|
|
15102
15113
|
|
|
15103
15114
|
/**
|
|
15104
15115
|
* Read local Arcium environment information from environment variables.
|
|
@@ -15228,6 +15239,7 @@ exports.RescuePrimeHash = RescuePrimeHash;
|
|
|
15228
15239
|
exports.arcisEd25519 = arcisEd25519;
|
|
15229
15240
|
exports.awaitComputationFinalization = awaitComputationFinalization;
|
|
15230
15241
|
exports.buildFinalizeCompDefTx = buildFinalizeCompDefTx;
|
|
15242
|
+
exports.claimComputationRent = claimComputationRent;
|
|
15231
15243
|
exports.createPacker = createPacker;
|
|
15232
15244
|
exports.deserializeLE = deserializeLE;
|
|
15233
15245
|
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.
|
|
1868
|
+
version: "0.9.3",
|
|
1869
1869
|
spec: "0.1.0",
|
|
1870
1870
|
description: "The Arcium program"
|
|
1871
1871
|
};
|
|
@@ -12189,7 +12189,7 @@ var types = [
|
|
|
12189
12189
|
name: "AcccountAccessInfo"
|
|
12190
12190
|
}
|
|
12191
12191
|
},
|
|
12192
|
-
|
|
12192
|
+
15
|
|
12193
12193
|
]
|
|
12194
12194
|
}
|
|
12195
12195
|
},
|
|
@@ -12198,7 +12198,7 @@ var types = [
|
|
|
12198
12198
|
type: {
|
|
12199
12199
|
array: [
|
|
12200
12200
|
"u8",
|
|
12201
|
-
|
|
12201
|
+
2
|
|
12202
12202
|
]
|
|
12203
12203
|
}
|
|
12204
12204
|
}
|
|
@@ -15080,6 +15080,17 @@ async function initMxePart2(provider, clusterOffset, mxeProgramId, recoveryPeers
|
|
|
15080
15080
|
.transaction();
|
|
15081
15081
|
return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
|
|
15082
15082
|
}
|
|
15083
|
+
async function claimComputationRent(provider, clusterOffset, computationOffset, confirmOptions) {
|
|
15084
|
+
const program = getArciumProgram(provider);
|
|
15085
|
+
const tx = await program.methods
|
|
15086
|
+
.claimComputationRent(computationOffset, clusterOffset)
|
|
15087
|
+
.accountsPartial({
|
|
15088
|
+
signer: provider.publicKey,
|
|
15089
|
+
comp: getComputationAccAddress(clusterOffset, computationOffset),
|
|
15090
|
+
})
|
|
15091
|
+
.transaction();
|
|
15092
|
+
return signAndSendWithBlockhash(provider, tx, await provider.connection.getLatestBlockhash({ commitment: confirmOptions?.commitment || 'confirmed' }), confirmOptions);
|
|
15093
|
+
}
|
|
15083
15094
|
|
|
15084
15095
|
/**
|
|
15085
15096
|
* Read local Arcium environment information from environment variables.
|
|
@@ -15185,4 +15196,4 @@ async function awaitComputationFinalization(provider, computationOffset, mxeProg
|
|
|
15185
15196
|
: new Error(timeoutMsg);
|
|
15186
15197
|
}
|
|
15187
15198
|
|
|
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 };
|
|
15199
|
+
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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PublicKey, Finality } from '@solana/web3.js';
|
|
2
|
+
import { AnchorProvider, BN } from '@coral-xyz/anchor';
|
|
3
|
+
/**
|
|
4
|
+
* Wait for a computation to finalize by polling the computation account
|
|
5
|
+
* status via HTTP RPC. Does not use WebSocket subscriptions.
|
|
6
|
+
*
|
|
7
|
+
* Polls every 500ms (same as Agave's send_and_confirm_transaction_with_config).
|
|
8
|
+
* Return the most recent transaction signature on the computation account
|
|
9
|
+
* once finalization is detected.
|
|
10
|
+
*
|
|
11
|
+
* @param provider - Anchor provider.
|
|
12
|
+
* @param computationOffset - Computation offset to wait for.
|
|
13
|
+
* @param mxeProgramId - MXE program public key.
|
|
14
|
+
* @param commitment - Commitment level for RPC calls (default: 'confirmed').
|
|
15
|
+
* @param timeoutMs - Maximum wait time in milliseconds (default: 120000).
|
|
16
|
+
* @returns Transaction signature from the finalization.
|
|
17
|
+
* @throws Error if the MXE account has no cluster assigned.
|
|
18
|
+
* @throws Error if the computation does not finalize within timeoutMs.
|
|
19
|
+
*/
|
|
20
|
+
export declare function awaitComputationFinalization(provider: AnchorProvider, computationOffset: BN, mxeProgramId: PublicKey, commitment?: Finality, timeoutMs?: number): Promise<string>;
|
|
21
|
+
//# sourceMappingURL=callback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"callback.d.ts","sourceRoot":"","sources":["../../src/callback.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,QAAQ,EACX,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACH,cAAc,EAAE,EAAE,EACrB,MAAM,mBAAmB,CAAC;AAM3B;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,4BAA4B,CAC9C,QAAQ,EAAE,cAAc,EACxB,iBAAiB,EAAE,EAAE,EACrB,YAAY,EAAE,SAAS,EACvB,UAAU,GAAE,QAAsB,EAClC,SAAS,GAAE,MAAgB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAiEjB"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seed for ClockAccount PDA.
|
|
3
|
+
* @constant {string}
|
|
4
|
+
*/
|
|
5
|
+
export declare const CLOCK_ACC_SEED = "ClockAccount";
|
|
6
|
+
/**
|
|
7
|
+
* Seed for FeePool PDA.
|
|
8
|
+
* @constant {string}
|
|
9
|
+
*/
|
|
10
|
+
export declare const POOL_ACC_SEED = "FeePool";
|
|
11
|
+
/**
|
|
12
|
+
* Seed for ComputationAccount PDA.
|
|
13
|
+
* @constant {string}
|
|
14
|
+
*/
|
|
15
|
+
export declare const COMPUTATION_ACC_SEED = "ComputationAccount";
|
|
16
|
+
/**
|
|
17
|
+
* Seed for Mempool PDA.
|
|
18
|
+
* @constant {string}
|
|
19
|
+
*/
|
|
20
|
+
export declare const MEMPOOL_ACC_SEED = "Mempool";
|
|
21
|
+
/**
|
|
22
|
+
* Seed for ExecutingPoolAccount PDA.
|
|
23
|
+
* @constant {string}
|
|
24
|
+
*/
|
|
25
|
+
export declare const EXEC_POOL_ACC_SEED = "Execpool";
|
|
26
|
+
/**
|
|
27
|
+
* Seed for ClusterAccount PDA.
|
|
28
|
+
* @constant {string}
|
|
29
|
+
*/
|
|
30
|
+
export declare const CLUSTER_ACC_SEED = "Cluster";
|
|
31
|
+
/**
|
|
32
|
+
* Seed for ArxNodeAccount PDA.
|
|
33
|
+
* @constant {string}
|
|
34
|
+
*/
|
|
35
|
+
export declare const ARX_NODE_ACC_SEED = "ArxNode";
|
|
36
|
+
/**
|
|
37
|
+
* Seed for MXE Account PDA.
|
|
38
|
+
* @constant {string}
|
|
39
|
+
*/
|
|
40
|
+
export declare const MXE_ACCOUNT_SEED = "MXEAccount";
|
|
41
|
+
/**
|
|
42
|
+
* Seed for CompDefAccount PDA.
|
|
43
|
+
* @constant {string}
|
|
44
|
+
*/
|
|
45
|
+
export declare const COMP_DEF_ACC_SEED = "ComputationDefinitionAccount";
|
|
46
|
+
/**
|
|
47
|
+
* Seed for RecoveryClusterAccount PDA.
|
|
48
|
+
* @constant {string}
|
|
49
|
+
*/
|
|
50
|
+
export declare const RECOVERY_CLUSTER_ACC_SEED = "RecoveryClusterAccount";
|
|
51
|
+
/**
|
|
52
|
+
* Seed for MxeRecoveryAccount PDA.
|
|
53
|
+
* @constant {string}
|
|
54
|
+
*/
|
|
55
|
+
export declare const MXE_RECOVERY_ACC_SEED = "MxeRecoveryAccount";
|
|
56
|
+
/**
|
|
57
|
+
* Seed for ComputationDefinitionRaw PDA.
|
|
58
|
+
* @constant {string}
|
|
59
|
+
*/
|
|
60
|
+
export declare const RAW_CIRCUIT_ACC_SEED = "ComputationDefinitionRaw";
|
|
61
|
+
/**
|
|
62
|
+
* Maximum number of bytes that can be reallocated per instruction.
|
|
63
|
+
* @constant {number}
|
|
64
|
+
*/
|
|
65
|
+
export declare const MAX_REALLOC_PER_IX = 10240;
|
|
66
|
+
/**
|
|
67
|
+
* Maximum number of bytes that can be uploaded in a single transaction with the upload instruction.
|
|
68
|
+
* @constant {number}
|
|
69
|
+
*/
|
|
70
|
+
export declare const MAX_UPLOAD_PER_TX_BYTES = 814;
|
|
71
|
+
/**
|
|
72
|
+
* Maximum size of an account in bytes (10MB = 10 * 1024 * 1024).
|
|
73
|
+
* @constant {number}
|
|
74
|
+
*/
|
|
75
|
+
export declare const MAX_ACCOUNT_SIZE = 10485760;
|
|
76
|
+
/**
|
|
77
|
+
* Maximum number of Arcium embiggen instructions allowed in a single transaction (due to compute unit limits).
|
|
78
|
+
* @constant {number}
|
|
79
|
+
*/
|
|
80
|
+
export declare const MAX_EMBIGGEN_IX_PER_TX = 18;
|
|
81
|
+
/**
|
|
82
|
+
* Size of account discriminator in bytes.
|
|
83
|
+
* @constant {number}
|
|
84
|
+
*/
|
|
85
|
+
export declare const DISCRIMINATOR_SIZE = 8;
|
|
86
|
+
/**
|
|
87
|
+
* Size of offset buffer in bytes (u32).
|
|
88
|
+
* @constant {number}
|
|
89
|
+
*/
|
|
90
|
+
export declare const OFFSET_BUFFER_SIZE = 4;
|
|
91
|
+
/**
|
|
92
|
+
* Size of computation definition offset slice in bytes.
|
|
93
|
+
* @constant {number}
|
|
94
|
+
*/
|
|
95
|
+
export declare const COMP_DEF_OFFSET_SIZE = 4;
|
|
96
|
+
/**
|
|
97
|
+
* Size of a uint128 in bytes.
|
|
98
|
+
* @constant {number}
|
|
99
|
+
*/
|
|
100
|
+
export declare const UINT128_BYTE_SIZE = 16;
|
|
101
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,cAAc,iBAAiB,CAAC;AAC7C;;;GAGG;AACH,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,uBAAuB,CAAC;AACzD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C;;;GAGG;AACH,eAAO,MAAM,kBAAkB,aAAa,CAAC;AAC7C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,YAAY,CAAC;AAC1C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAC3C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAC7C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,iCAAiC,CAAC;AAChE;;;GAGG;AACH,eAAO,MAAM,yBAAyB,2BAA2B,CAAC;AAClE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,uBAAuB,CAAC;AAC1D;;;GAGG;AACH,eAAO,MAAM,oBAAoB,6BAA6B,CAAC;AAC/D;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AACxC;;;GAGG;AACH,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAC3C;;;GAGG;AACH,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC;;;GAGG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC;;;GAGG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,KAAK,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AesCtrCipher } from './aesCtrCipher.js';
|
|
2
|
+
/**
|
|
3
|
+
* AES-128 cipher in Counter (CTR) mode, using SHA3-256 to derive the key from a shared secret.
|
|
4
|
+
* See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Aes128Cipher extends AesCtrCipher {
|
|
7
|
+
/**
|
|
8
|
+
* Construct an AES-128 cipher instance using a shared secret.
|
|
9
|
+
* The key is derived using SHA3-256.
|
|
10
|
+
* @param sharedSecret - Shared secret to derive the AES key from.
|
|
11
|
+
*/
|
|
12
|
+
constructor(sharedSecret: Uint8Array);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=aes128Cipher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aes128Cipher.d.ts","sourceRoot":"","sources":["../../../src/cryptography/aes128Cipher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;GAGG;AACH,qBAAa,YAAa,SAAQ,YAAY;IAC1C;;;;OAIG;gBACS,YAAY,EAAE,UAAU;CAGvC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AesCtrCipher } from './aesCtrCipher.js';
|
|
2
|
+
/**
|
|
3
|
+
* AES-192 cipher in Counter (CTR) mode, using SHA3-256 to derive the key from a shared secret.
|
|
4
|
+
* See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Aes192Cipher extends AesCtrCipher {
|
|
7
|
+
/**
|
|
8
|
+
* Construct an AES-192 cipher instance using a shared secret.
|
|
9
|
+
* The key is derived using SHA3-256.
|
|
10
|
+
* @param sharedSecret - Shared secret to derive the AES key from.
|
|
11
|
+
*/
|
|
12
|
+
constructor(sharedSecret: Uint8Array);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=aes192Cipher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aes192Cipher.d.ts","sourceRoot":"","sources":["../../../src/cryptography/aes192Cipher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;GAGG;AACH,qBAAa,YAAa,SAAQ,YAAY;IAC1C;;;;OAIG;gBACS,YAAY,EAAE,UAAU;CAGvC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AesCtrCipher } from './aesCtrCipher.js';
|
|
2
|
+
/**
|
|
3
|
+
* AES-256 cipher in Counter (CTR) mode, using SHA3-256 to derive the key from a shared secret.
|
|
4
|
+
* See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode.
|
|
5
|
+
*/
|
|
6
|
+
export declare class Aes256Cipher extends AesCtrCipher {
|
|
7
|
+
/**
|
|
8
|
+
* Construct an AES-256 cipher instance using a shared secret.
|
|
9
|
+
* The key is derived using SHA3-256.
|
|
10
|
+
* @param sharedSecret - Shared secret to derive the AES key from.
|
|
11
|
+
*/
|
|
12
|
+
constructor(sharedSecret: Uint8Array);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=aes256Cipher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aes256Cipher.d.ts","sourceRoot":"","sources":["../../../src/cryptography/aes256Cipher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD;;;GAGG;AACH,qBAAa,YAAa,SAAQ,YAAY;IAC1C;;;;OAIG;gBACS,YAAY,EAAE,UAAU;CAGvC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported AES key sizes in bits.
|
|
3
|
+
*/
|
|
4
|
+
export type AesKeyBits = 128 | 192 | 256;
|
|
5
|
+
/**
|
|
6
|
+
* Generic AES cipher in Counter (CTR) mode, using SHA3-256 to derive the key from a shared secret.
|
|
7
|
+
* See: https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-38a.pdf (Section 6.5) for details on CTR mode.
|
|
8
|
+
*/
|
|
9
|
+
export declare class AesCtrCipher {
|
|
10
|
+
protected key: Uint8Array;
|
|
11
|
+
private readonly keyBits;
|
|
12
|
+
/**
|
|
13
|
+
* Construct an AES cipher instance using a shared secret.
|
|
14
|
+
* The key is derived using SHA3-256.
|
|
15
|
+
* @param sharedSecret - Shared secret to derive the AES key from.
|
|
16
|
+
* @param keyBits - AES key size in bits (128, 192, or 256).
|
|
17
|
+
*/
|
|
18
|
+
constructor(sharedSecret: Uint8Array, keyBits: AesKeyBits);
|
|
19
|
+
/**
|
|
20
|
+
* Encrypt the plaintext array in Counter (CTR) mode.
|
|
21
|
+
* @param plaintext - Data to encrypt.
|
|
22
|
+
* @param nonce - 8-byte nonce for CTR mode.
|
|
23
|
+
* @returns Encrypted ciphertext as a Uint8Array.
|
|
24
|
+
* @throws Error if the nonce is not 8 bytes long.
|
|
25
|
+
*/
|
|
26
|
+
encrypt(plaintext: Uint8Array, nonce: Uint8Array): Uint8Array;
|
|
27
|
+
/**
|
|
28
|
+
* Decrypt the ciphertext array in Counter (CTR) mode.
|
|
29
|
+
* @param ciphertext - Data to decrypt.
|
|
30
|
+
* @param nonce - 8-byte nonce for CTR mode.
|
|
31
|
+
* @returns Decrypted plaintext as a Uint8Array.
|
|
32
|
+
* @throws Error if the nonce is not 8 bytes long.
|
|
33
|
+
*/
|
|
34
|
+
decrypt(ciphertext: Uint8Array, nonce: Uint8Array): Uint8Array;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=aesCtrCipher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aesCtrCipher.d.ts","sourceRoot":"","sources":["../../../src/cryptography/aesCtrCipher.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAOzC;;;GAGG;AACH,qBAAa,YAAY;IACrB,SAAS,CAAC,GAAG,EAAE,UAAU,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IAErC;;;;;OAKG;gBACS,YAAY,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU;IAwBzD;;;;;;OAMG;IACH,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU;IAU7D;;;;;;OAMG;IACH,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,UAAU;CASjE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CurveFn } from '@noble/curves/abstract/edwards';
|
|
2
|
+
/**
|
|
3
|
+
* Ed25519 curve instance using SHA3-512 for hashing, suitable for MPC (ArcisEd25519 signature scheme).
|
|
4
|
+
* This is essentially Ed25519 but with SHA3-512 instead of SHA-512 for lower multiplicative depth.
|
|
5
|
+
* See: https://datatracker.ietf.org/doc/html/rfc8032#section-5.1
|
|
6
|
+
*/
|
|
7
|
+
export declare const arcisEd25519: CurveFn;
|
|
8
|
+
//# sourceMappingURL=arcisEd25519.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arcisEd25519.d.ts","sourceRoot":"","sources":["../../../src/cryptography/arcisEd25519.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAkB,MAAM,gCAAgC,CAAC;AAyBzE;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,OAAwD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RescueCipherCommon } from './rescueCipherCommon.js';
|
|
2
|
+
/**
|
|
3
|
+
* The Rescue cipher over Curve25519's scalar field in Counter (CTR) mode, with a fixed block size m = 5.
|
|
4
|
+
* See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287
|
|
5
|
+
*/
|
|
6
|
+
export declare class CSplRescueCipher {
|
|
7
|
+
cipher: RescueCipherCommon;
|
|
8
|
+
/**
|
|
9
|
+
* Construct a CSplRescueCipher instance using a shared secret.
|
|
10
|
+
* The key is derived using RescuePrimeHash and used to initialize the RescueDesc.
|
|
11
|
+
* @param sharedSecret - Shared secret to derive the cipher key from.
|
|
12
|
+
*/
|
|
13
|
+
constructor(sharedSecret: Uint8Array);
|
|
14
|
+
/**
|
|
15
|
+
* Encrypt the plaintext vector in Counter (CTR) mode and serialize each block.
|
|
16
|
+
* @param plaintext - Array of plaintext bigints to encrypt.
|
|
17
|
+
* @param nonce - 16-byte nonce for CTR mode.
|
|
18
|
+
* @returns Ciphertext as an array of arrays of numbers (each 32 bytes).
|
|
19
|
+
*/
|
|
20
|
+
encrypt(plaintext: bigint[], nonce: Uint8Array): number[][];
|
|
21
|
+
/**
|
|
22
|
+
* Deserialize and decrypt the ciphertext vector in Counter (CTR) mode.
|
|
23
|
+
* @param ciphertext - Array of arrays of numbers (each 32 bytes) to decrypt.
|
|
24
|
+
* @param nonce - 16-byte nonce for CTR mode.
|
|
25
|
+
* @returns Decrypted plaintext as an array of bigints.
|
|
26
|
+
*/
|
|
27
|
+
decrypt(ciphertext: number[][], nonce: Uint8Array): bigint[];
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=cSplRescueCipher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cSplRescueCipher.d.ts","sourceRoot":"","sources":["../../../src/cryptography/cSplRescueCipher.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;GAGG;AACH,qBAAa,gBAAgB;IACzB,MAAM,EAAE,kBAAkB,CAAC;IAE3B;;;;OAIG;gBACS,YAAY,EAAE,UAAU;IAIpC;;;;;OAKG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE,EAAE;IAI3D;;;;;OAKG;IACH,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE;CAG/D"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scalar field prime modulus for Curve25519: 2^252 + 27742317777372353535851937790883648493
|
|
3
|
+
*/
|
|
4
|
+
export declare const CURVE25519_SCALAR_FIELD_MODULUS: bigint;
|
|
5
|
+
/**
|
|
6
|
+
* Generate a random value within the field bound by q.
|
|
7
|
+
* @param q - Upper bound (exclusive) for the random value.
|
|
8
|
+
* @returns Random bigint value between 0 and q-1.
|
|
9
|
+
*/
|
|
10
|
+
export declare function generateRandomFieldElem(q: bigint): bigint;
|
|
11
|
+
/**
|
|
12
|
+
* Compute the positive modulo of a over m.
|
|
13
|
+
* @param a - Dividend.
|
|
14
|
+
* @param m - Modulus.
|
|
15
|
+
* @returns Positive remainder of a mod m.
|
|
16
|
+
*/
|
|
17
|
+
export declare function positiveModulo(a: bigint, m: bigint): bigint;
|
|
18
|
+
/**
|
|
19
|
+
* Serialize a bigint to a little-endian Uint8Array of the specified length.
|
|
20
|
+
* @param val - Bigint value to serialize.
|
|
21
|
+
* @param lengthInBytes - Desired length of the output array.
|
|
22
|
+
* @returns Serialized value as a Uint8Array.
|
|
23
|
+
* @throws Error if the value is too large for the specified length.
|
|
24
|
+
*/
|
|
25
|
+
export declare function serializeLE(val: bigint, lengthInBytes: number): Uint8Array;
|
|
26
|
+
/**
|
|
27
|
+
* Deserialize a little-endian Uint8Array to a bigint.
|
|
28
|
+
* @param bytes - Uint8Array to deserialize.
|
|
29
|
+
* @returns Deserialized bigint value.
|
|
30
|
+
*/
|
|
31
|
+
export declare function deserializeLE(bytes: Uint8Array): bigint;
|
|
32
|
+
/**
|
|
33
|
+
* Compute the SHA-256 hash of an array of Uint8Arrays.
|
|
34
|
+
* @param byteArrays - Arrays to hash.
|
|
35
|
+
* @returns SHA-256 hash as a Buffer.
|
|
36
|
+
*/
|
|
37
|
+
export declare function sha256(byteArrays: Uint8Array[]): Buffer;
|
|
38
|
+
//# sourceMappingURL=cryptography.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cryptography.d.ts","sourceRoot":"","sources":["../../../src/cryptography/cryptography.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,eAAO,MAAM,+BAA+B,QAAkB,CAAC;AAE/D;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAQzD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,UAAU,CAc1E;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAMvD;AAGD;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,CAMvD"}
|