@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.
Files changed (92) hide show
  1. package/build/index.cjs +15 -3
  2. package/build/index.mjs +15 -4
  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} +5 -901
  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 +12281 -0
  83. package/src/idl/arcium.ts +12287 -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
@@ -0,0 +1,37 @@
1
+ import { HMACRescuePrime } from './hmac.js';
2
+ import { FpField } from './rescueDesc.js';
3
+ /**
4
+ * HKDF (HMAC-based Extract-and-Expand Key Derivation Function) using the Rescue-Prime hash function.
5
+ * Follows RFC 5869. Only supports L = HashLen.
6
+ */
7
+ export declare class HKDFRescuePrime {
8
+ hmac: HMACRescuePrime;
9
+ /**
10
+ * Construct a new HKDFRescuePrime instance.
11
+ */
12
+ constructor(field: FpField);
13
+ /**
14
+ * HKDF-Extract step: derive a pseudorandom key (PRK) from the input keying material (IKM) and salt.
15
+ * @param salt - Salt value as an array of bigints.
16
+ * @param ikm - Input keying material as an array of bigints.
17
+ * @returns Pseudorandom key (PRK) as an array of bigints.
18
+ */
19
+ extract(salt: bigint[], ikm: bigint[]): bigint[];
20
+ /**
21
+ * HKDF-Expand step: expand the pseudorandom key (PRK) with info to produce output keying material (OKM).
22
+ * Only supports L = HashLen = 5, i.e. N = 1.
23
+ * @param prk - Pseudorandom key as an array of bigints.
24
+ * @param info - Context and application specific information as an array of bigints.
25
+ * @returns Output keying material (OKM) as an array of bigints.
26
+ */
27
+ expand(prk: bigint[], info: bigint[]): bigint[];
28
+ /**
29
+ * Perform the full HKDF (extract and expand) to derive output keying material (OKM).
30
+ * @param salt - Salt value as an array of bigints.
31
+ * @param ikm - Input keying material as an array of bigints.
32
+ * @param info - Context and application specific information as an array of bigints.
33
+ * @returns Output keying material (OKM) as an array of bigints.
34
+ */
35
+ okm(salt: bigint[], ikm: bigint[], info: bigint[]): bigint[];
36
+ }
37
+ //# sourceMappingURL=hkdf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hkdf.d.ts","sourceRoot":"","sources":["../../../src/cryptography/hkdf.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C;;;GAGG;AACH,qBAAa,eAAe;IACxB,IAAI,EAAE,eAAe,CAAC;IAEtB;;OAEG;gBACS,KAAK,EAAE,OAAO;IAI1B;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAQhD;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;IAQ/C;;;;;;OAMG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;CAI/D"}
@@ -0,0 +1,22 @@
1
+ import { FpField } from './rescueDesc.js';
2
+ import { RescuePrimeHash } from './rescuePrimeHash.js';
3
+ /**
4
+ * HMACRescuePrime provides a message authentication code (MAC) using the Rescue-Prime hash function.
5
+ * We refer to https://datatracker.ietf.org/doc/html/rfc2104 for more details.
6
+ */
7
+ export declare class HMACRescuePrime {
8
+ hasher: RescuePrimeHash;
9
+ /**
10
+ * Construct a new HMACRescuePrime instance.
11
+ */
12
+ constructor(field: FpField);
13
+ /**
14
+ * Compute the HMAC digest of a message with a given key using Rescue-Prime.
15
+ * @param key - Key as an array of bigints.
16
+ * @param message - Message as an array of bigints.
17
+ * @returns HMAC digest as an array of bigints.
18
+ * @throws Error if the key is shorter than the hash function's digest length or longer than the hash function's rate.
19
+ */
20
+ digest(key: bigint[], message: bigint[]): bigint[];
21
+ }
22
+ //# sourceMappingURL=hmac.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hmac.d.ts","sourceRoot":"","sources":["../../../src/cryptography/hmac.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAgBvD;;;GAGG;AACH,qBAAa,eAAe;IACxB,MAAM,EAAE,eAAe,CAAC;IAExB;;OAEG;gBACS,KAAK,EAAE,OAAO;IAI1B;;;;;;OAMG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;CA0BrD"}
@@ -0,0 +1,29 @@
1
+ import { RescueCipherCommon } from './rescueCipherCommon.js';
2
+ /**
3
+ * The Rescue cipher over Curve25519's base 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 RescueCipher {
7
+ cipher: RescueCipherCommon;
8
+ /**
9
+ * Construct a RescueCipher 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=rescueCipher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rescueCipher.d.ts","sourceRoot":"","sources":["../../../src/cryptography/rescueCipher.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D;;;GAGG;AACH,qBAAa,YAAY;IACrB,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,45 @@
1
+ import { RescueDesc, FpField } from './rescueDesc.js';
2
+ /**
3
+ * The Rescue cipher 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 RescueCipherCommon {
7
+ desc: RescueDesc;
8
+ /**
9
+ * Construct a RescueCipherCommon 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, field: FpField);
14
+ /**
15
+ * Encrypt the plaintext vector in Counter (CTR) mode (raw, returns bigints).
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 bigints.
19
+ * @throws Error if the nonce is not 16 bytes long.
20
+ */
21
+ encrypt_raw(plaintext: bigint[], nonce: Uint8Array): bigint[];
22
+ /**
23
+ * Encrypt the plaintext vector in Counter (CTR) mode and serialize each block.
24
+ * @param plaintext - Array of plaintext bigints to encrypt.
25
+ * @param nonce - 16-byte nonce for CTR mode.
26
+ * @returns Ciphertext as an array of arrays of numbers (each 32 bytes).
27
+ */
28
+ encrypt(plaintext: bigint[], nonce: Uint8Array): number[][];
29
+ /**
30
+ * Decrypt the ciphertext vector in Counter (CTR) mode (raw, expects bigints).
31
+ * @param ciphertext - Array of ciphertext bigints to decrypt.
32
+ * @param nonce - 16-byte nonce for CTR mode.
33
+ * @returns Decrypted plaintext as an array of bigints.
34
+ * @throws Error if the nonce is not 16 bytes long.
35
+ */
36
+ decrypt_raw(ciphertext: bigint[], nonce: Uint8Array): bigint[];
37
+ /**
38
+ * Deserialize and decrypt the ciphertext vector in Counter (CTR) mode.
39
+ * @param ciphertext - Array of arrays of numbers (each 32 bytes) to decrypt.
40
+ * @param nonce - 16-byte nonce for CTR mode.
41
+ * @returns Decrypted plaintext as an array of bigints.
42
+ */
43
+ decrypt(ciphertext: number[][], nonce: Uint8Array): bigint[];
44
+ }
45
+ //# sourceMappingURL=rescueCipherCommon.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rescueCipherCommon.d.ts","sourceRoot":"","sources":["../../../src/cryptography/rescueCipherCommon.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EAEV,OAAO,EAEV,MAAM,iBAAiB,CAAC;AAoBzB;;;GAGG;AACH,qBAAa,kBAAkB;IAC3B,IAAI,EAAE,UAAU,CAAC;IAEjB;;;;OAIG;gBACS,YAAY,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO;IAuCpD;;;;;;OAMG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE;IAwC7D;;;;;OAKG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE,EAAE;IAI3D;;;;;;OAMG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE;IAqC9D;;;;;OAKG;IACH,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,UAAU,GAAG,MAAM,EAAE;CAQ/D"}
@@ -0,0 +1,80 @@
1
+ import { IField } from '@noble/curves/abstract/modular';
2
+ import { Matrix } from '../matrix.js';
3
+ /**
4
+ * Represents the operational mode for the Rescue cryptographic primitive.
5
+ * Can be either a block cipher mode with a key, or a hash function mode with parameters.
6
+ */
7
+ type RescueMode = BlockCipher | HashFunction;
8
+ /**
9
+ * Block cipher mode configuration for Rescue.
10
+ * Use a key for encryption/decryption operations.
11
+ */
12
+ type BlockCipher = {
13
+ kind: 'cipher';
14
+ key: bigint[];
15
+ };
16
+ /**
17
+ * Hash function mode configuration for Rescue.
18
+ * @param m - Rate (number of field elements absorbed per round).
19
+ * @param capacity - Capacity (number of field elements in the state that are not directly accessible).
20
+ */
21
+ type HashFunction = {
22
+ kind: 'hash';
23
+ m: number;
24
+ capacity: number;
25
+ };
26
+ /**
27
+ * Field type.
28
+ */
29
+ export type FpField = IField<bigint>;
30
+ /**
31
+ * Curve25519 base field as an IField instance.
32
+ */
33
+ export declare const CURVE25519_BASE_FIELD: FpField;
34
+ /**
35
+ * Curve25519 scalar field as an IField instance.
36
+ */
37
+ export declare const CURVE25519_SCALAR_FIELD: FpField;
38
+ /**
39
+ * Description and parameters for the Rescue cipher or hash function, including round constants, MDS matrix, and key schedule.
40
+ * See: https://tosc.iacr.org/index.php/ToSC/article/view/8695/8287
41
+ */
42
+ export declare class RescueDesc {
43
+ mode: RescueMode;
44
+ field: FpField;
45
+ alpha: bigint;
46
+ alphaInverse: bigint;
47
+ nRounds: number;
48
+ m: number;
49
+ mdsMat: Matrix;
50
+ mdsMatInverse: Matrix;
51
+ roundKeys: Matrix[];
52
+ /**
53
+ * Construct a RescueDesc for a given field and mode (cipher or hash).
54
+ * Initialize round constants, MDS matrix, and key schedule.
55
+ * @param field - Field to use (e.g., CURVE25519_BASE_FIELD).
56
+ * @param mode - Mode: block cipher or hash function.
57
+ */
58
+ constructor(field: FpField, mode: RescueMode);
59
+ /**
60
+ * Sample round constants for the Rescue permutation, using SHAKE256.
61
+ * @param nRounds - Number of rounds.
62
+ * @returns Array of round constant matrices.
63
+ */
64
+ sampleConstants(nRounds: number): Matrix[];
65
+ /**
66
+ * Apply the Rescue permutation to a state matrix.
67
+ * @param state - Input state matrix.
68
+ * @returns Permuted state matrix.
69
+ */
70
+ permute(state: Matrix): Matrix;
71
+ /**
72
+ * Apply the inverse Rescue permutation to a state matrix.
73
+ * @param state - Input state matrix.
74
+ * @returns Inverse-permuted state matrix.
75
+ */
76
+ permuteInverse(state: Matrix): Matrix;
77
+ }
78
+ export declare function toVec(data: bigint[]): bigint[][];
79
+ export {};
80
+ //# sourceMappingURL=rescueDesc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rescueDesc.d.ts","sourceRoot":"","sources":["../../../src/cryptography/rescueDesc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAU,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtC;;;GAGG;AACH,KAAK,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC;AAE7C;;;GAGG;AACH,KAAK,WAAW,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC;AAErD;;;;GAIG;AACH,KAAK,YAAY,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,OAA0B,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,OAA0B,CAAC;AASjE;;;GAGG;AACH,qBAAa,UAAU;IACnB,IAAI,EAAE,UAAU,CAAC;IAEjB,KAAK,EAAE,OAAO,CAAC;IAGf,KAAK,EAAE,MAAM,CAAC;IAGd,YAAY,EAAE,MAAM,CAAC;IAErB,OAAO,EAAE,MAAM,CAAC;IAEhB,CAAC,EAAE,MAAM,CAAC;IAGV,MAAM,EAAE,MAAM,CAAC;IAGf,aAAa,EAAE,MAAM,CAAC;IAGtB,SAAS,EAAE,MAAM,EAAE,CAAC;IAEpB;;;;;OAKG;gBACS,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU;IAuD5C;;;;OAIG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;IAoF1C;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAW9B;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAUxC;AAqOD,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,CAMhD"}
@@ -0,0 +1,23 @@
1
+ import { RescueDesc, FpField } from './rescueDesc.js';
2
+ /**
3
+ * The Rescue-Prime hash function, as described in https://eprint.iacr.org/2020/1143.pdf, offering 256 bits
4
+ * of security against collision, preimage and second-preimage attacks for any field of size at least 102 bits.
5
+ * We use the sponge construction with fixed rate = 7 and capacity = 5 (i.e., m = 12), and truncate the
6
+ * output to 5 field elements.
7
+ */
8
+ export declare class RescuePrimeHash {
9
+ desc: RescueDesc;
10
+ rate: number;
11
+ digestLength: number;
12
+ /**
13
+ * Construct a RescuePrimeHash instance with rate = 7 and capacity = 5.
14
+ */
15
+ constructor(field: FpField);
16
+ /**
17
+ * Compute the Rescue-Prime hash of a message, with padding as described in Algorithm 2 of the paper.
18
+ * @param message - Input message as an array of bigints.
19
+ * @returns Hash output as an array of bigints (length = digestLength).
20
+ */
21
+ digest(message: bigint[]): bigint[];
22
+ }
23
+ //# sourceMappingURL=rescuePrimeHash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rescuePrimeHash.d.ts","sourceRoot":"","sources":["../../../src/cryptography/rescuePrimeHash.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,OAAO,EACV,MAAM,iBAAiB,CAAC;AAGzB;;;;;GAKG;AACH,qBAAa,eAAe;IACxB,IAAI,EAAE,UAAU,CAAC;IAEjB,IAAI,EAAE,MAAM,CAAC;IAEb,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;gBACS,KAAK,EAAE,OAAO;IAgB1B;;;;OAIG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE;CA4BtC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Constant-time addition of two bigints, using 2's complement representation.
3
+ * @param x - First operand.
4
+ * @param y - Second operand.
5
+ * @param binSize - Number of bits to use in the operation.
6
+ * @returns Sum as a bigint.
7
+ */
8
+ export declare function ctAdd(x: bigint, y: bigint, binSize: bigint): bigint;
9
+ /**
10
+ * Constant-time subtraction of two bigints, using 2's complement representation.
11
+ * @param x - First operand.
12
+ * @param y - Second operand.
13
+ * @param binSize - Number of bits to use in the operation.
14
+ * @returns Difference as a bigint.
15
+ */
16
+ export declare function ctSub(x: bigint, y: bigint, binSize: bigint): bigint;
17
+ /**
18
+ * Return the sign bit of a bigint in constant time.
19
+ * @param x - Bigint to check.
20
+ * @param binSize - Bit position to check (typically the highest bit).
21
+ * @returns True if the sign bit is set, false otherwise.
22
+ */
23
+ export declare function ctSignBit(x: bigint, binSize: bigint): boolean;
24
+ /**
25
+ * Constant-time less-than comparison for two bigints.
26
+ * @param x - First operand.
27
+ * @param y - Second operand.
28
+ * @param binSize - Number of bits to use in the operation.
29
+ * @returns True if x < y, false otherwise.
30
+ */
31
+ export declare function ctLt(x: bigint, y: bigint, binSize: bigint): boolean;
32
+ /**
33
+ * Constant-time select between two bigints based on a boolean condition.
34
+ * @param b - Condition; if true, select x, otherwise select y.
35
+ * @param x - Value to select if b is true.
36
+ * @param y - Value to select if b is false.
37
+ * @param binSize - Number of bits to use in the operation.
38
+ * @returns Selected bigint.
39
+ */
40
+ export declare function ctSelect(b: boolean, x: bigint, y: bigint, binSize: bigint): bigint;
41
+ /**
42
+ * Check if a bigint fits in the range -2^binSize <= x < 2^binSize.
43
+ * Not constant-time for arbitrary x, but is constant-time for all inputs for which the function returns true.
44
+ * If you assert your inputs satisfy verifyBinSize(x, binSize), you need not care about the non constant-timeness of this function.
45
+ * @param x - Bigint to check.
46
+ * @param binSize - Number of bits to use in the check.
47
+ * @returns True if x fits in the range, false otherwise.
48
+ */
49
+ export declare function verifyBinSize(x: bigint, binSize: bigint): boolean;
50
+ //# sourceMappingURL=ctUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ctUtils.d.ts","sourceRoot":"","sources":["../../src/ctUtils.ts"],"names":[],"mappings":"AAkDA;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAGnE;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAQnE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAE7D;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAElF;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAGjE"}