@waku/rln 0.1.6-006cd41.0 → 0.1.6-0877e51.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/_virtual/index2.js +1 -1
- package/bundle/index.js +2 -1
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/lib/checksum.js +3 -3
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/lib/cipher.js +4 -4
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/lib/class.js +7 -7
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/lib/functional.js +7 -7
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/lib/index.js +6 -6
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/lib/kdf.js +5 -5
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/lib/password.js +1 -1
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/lib/schema-validation-generated.js +1 -1
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/lib/schema-validation.js +2 -2
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/lib/types.js +1 -1
- package/bundle/{packages/rln → node_modules/@chainsafe/bls-keystore}/node_modules/@noble/hashes/_assert.js +1 -1
- package/bundle/{packages/rln → node_modules/@chainsafe/bls-keystore}/node_modules/@noble/hashes/_sha2.js +3 -3
- package/bundle/{packages/rln → node_modules/@chainsafe/bls-keystore}/node_modules/@noble/hashes/_u64.js +1 -1
- package/bundle/{packages/rln → node_modules/@chainsafe/bls-keystore}/node_modules/@noble/hashes/cryptoBrowser.js +1 -1
- package/bundle/{packages/rln → node_modules/@chainsafe/bls-keystore}/node_modules/@noble/hashes/hmac.js +3 -3
- package/bundle/{packages/rln → node_modules/@chainsafe/bls-keystore}/node_modules/@noble/hashes/pbkdf2.js +4 -4
- package/bundle/{packages/rln → node_modules/@chainsafe/bls-keystore}/node_modules/@noble/hashes/scrypt.js +5 -5
- package/bundle/{packages/rln → node_modules/@chainsafe/bls-keystore}/node_modules/@noble/hashes/sha256.js +3 -3
- package/bundle/{packages/rln → node_modules/@chainsafe/bls-keystore}/node_modules/@noble/hashes/sha512.js +4 -4
- package/bundle/{packages/rln → node_modules/@chainsafe/bls-keystore}/node_modules/@noble/hashes/utils.js +2 -2
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/aes.js +3 -3
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/pbkdf2.js +7 -7
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +3 -3
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/scrypt.js +3 -3
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/sha256.js +3 -3
- package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +7 -7
- package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +1 -1
- package/bundle/node_modules/@noble/hashes/esm/_assert.js +6 -32
- package/bundle/node_modules/@noble/hashes/esm/_md.js +22 -11
- package/bundle/node_modules/@noble/hashes/esm/_u64.js +4 -3
- package/bundle/{packages/rln/node_modules → node_modules}/@noble/hashes/esm/hmac.js +19 -10
- package/bundle/{packages/rln/node_modules/@noble/hashes/esm/sha256.js → node_modules/@noble/hashes/esm/sha2.js} +36 -50
- package/bundle/node_modules/@noble/hashes/esm/sha256.js +5 -102
- package/bundle/node_modules/@noble/hashes/esm/sha3.js +30 -24
- package/bundle/node_modules/@noble/hashes/esm/utils.js +69 -18
- package/bundle/node_modules/bn.js/lib/bn.js +1 -0
- package/bundle/node_modules/ethereum-cryptography/esm/sha256.js +1 -1
- package/bundle/node_modules/{@ethersproject/keccak256/node_modules/js-sha3 → js-sha3}/src/sha3.js +2 -2
- package/bundle/packages/core/dist/lib/message/version_0.js +1 -4
- package/bundle/packages/rln/dist/contract/constants.js +8 -1
- package/bundle/packages/rln/dist/contract/rln_base_contract.js +135 -74
- package/bundle/packages/rln/dist/credentials_manager.js +18 -16
- package/bundle/packages/rln/dist/identity.js +37 -7
- package/bundle/packages/rln/dist/keystore/cipher.js +3 -3
- package/bundle/packages/rln/dist/keystore/keystore.js +16 -12
- package/bundle/packages/rln/dist/message.js +11 -0
- package/bundle/packages/rln/dist/utils/bytes.js +14 -16
- package/dist/.tsbuildinfo +1 -1
- package/dist/contract/constants.d.ts +6 -0
- package/dist/contract/constants.js +6 -0
- package/dist/contract/constants.js.map +1 -1
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/index.js +1 -0
- package/dist/contract/index.js.map +1 -1
- package/dist/contract/rln_base_contract.d.ts +32 -22
- package/dist/contract/rln_base_contract.js +135 -74
- package/dist/contract/rln_base_contract.js.map +1 -1
- package/dist/contract/types.d.ts +5 -0
- package/dist/contract/types.js.map +1 -1
- package/dist/credentials_manager.js +17 -15
- package/dist/credentials_manager.js.map +1 -1
- package/dist/identity.d.ts +11 -2
- package/dist/identity.js +23 -6
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/keystore/keystore.js +15 -11
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/keystore/types.d.ts +2 -2
- package/dist/message.d.ts +5 -4
- package/dist/message.js +2 -0
- package/dist/message.js.map +1 -1
- package/dist/utils/bytes.d.ts +2 -6
- package/dist/utils/bytes.js +13 -15
- package/dist/utils/bytes.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/contract/constants.ts +9 -0
- package/src/contract/index.ts +1 -0
- package/src/contract/rln_base_contract.ts +176 -113
- package/src/contract/types.ts +5 -0
- package/src/credentials_manager.ts +28 -22
- package/src/identity.ts +32 -6
- package/src/index.ts +3 -1
- package/src/keystore/keystore.ts +32 -26
- package/src/keystore/types.ts +2 -2
- package/src/message.ts +7 -4
- package/src/utils/bytes.ts +21 -25
- package/src/utils/index.ts +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/esm/_assert.js +0 -43
- package/bundle/packages/rln/node_modules/@noble/hashes/esm/_sha2.js +0 -116
- package/bundle/packages/rln/node_modules/@noble/hashes/esm/utils.js +0 -43
- package/dist/contract/test-utils.d.ts +0 -39
- package/dist/contract/test-utils.js +0 -118
- package/dist/contract/test-utils.js.map +0 -1
- package/src/contract/test-utils.ts +0 -179
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/index.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/md5.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/nil.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/parse.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/regex.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/rng.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/sha1.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/stringify.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v1.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v3.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v35.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v4.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v5.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/validate.js +0 -0
- /package/bundle/{packages/rln/node_modules → node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/version.js +0 -0
package/dist/identity.d.ts
CHANGED
@@ -3,7 +3,16 @@ export declare class IdentityCredential {
|
|
3
3
|
readonly IDNullifier: Uint8Array;
|
4
4
|
readonly IDSecretHash: Uint8Array;
|
5
5
|
readonly IDCommitment: Uint8Array;
|
6
|
-
|
7
|
-
|
6
|
+
/**
|
7
|
+
* All variables are in little-endian format
|
8
|
+
*/
|
9
|
+
constructor(IDTrapdoor: Uint8Array, IDNullifier: Uint8Array, IDSecretHash: Uint8Array, IDCommitment: Uint8Array);
|
8
10
|
static fromBytes(memKeys: Uint8Array): IdentityCredential;
|
11
|
+
/**
|
12
|
+
* Converts an ID commitment from bytes to a BigInt, normalizing it against a limit if needed
|
13
|
+
* @param bytes The ID commitment bytes to convert
|
14
|
+
* @param limit Optional limit to normalize against (Q value)
|
15
|
+
* @returns The ID commitment as a BigInt
|
16
|
+
*/
|
17
|
+
static getIdCommitmentBigInt(idCommitment: Uint8Array, limit?: bigint): bigint;
|
9
18
|
}
|
package/dist/identity.js
CHANGED
@@ -1,16 +1,20 @@
|
|
1
|
-
import {
|
1
|
+
import { Logger } from "@waku/utils";
|
2
|
+
import { DEFAULT_Q } from "./contract/constants.js";
|
3
|
+
import { buildBigIntFromUint8ArrayBE } from "./utils/bytes.js";
|
4
|
+
const log = new Logger("waku:rln:identity");
|
2
5
|
export class IdentityCredential {
|
3
6
|
IDTrapdoor;
|
4
7
|
IDNullifier;
|
5
8
|
IDSecretHash;
|
6
9
|
IDCommitment;
|
7
|
-
|
8
|
-
|
10
|
+
/**
|
11
|
+
* All variables are in little-endian format
|
12
|
+
*/
|
13
|
+
constructor(IDTrapdoor, IDNullifier, IDSecretHash, IDCommitment) {
|
9
14
|
this.IDTrapdoor = IDTrapdoor;
|
10
15
|
this.IDNullifier = IDNullifier;
|
11
16
|
this.IDSecretHash = IDSecretHash;
|
12
17
|
this.IDCommitment = IDCommitment;
|
13
|
-
this.IDCommitmentBigInt = IDCommitmentBigInt;
|
14
18
|
}
|
15
19
|
static fromBytes(memKeys) {
|
16
20
|
if (memKeys.length < 128) {
|
@@ -20,8 +24,21 @@ export class IdentityCredential {
|
|
20
24
|
const idNullifier = memKeys.subarray(32, 64);
|
21
25
|
const idSecretHash = memKeys.subarray(64, 96);
|
22
26
|
const idCommitment = memKeys.subarray(96, 128);
|
23
|
-
|
24
|
-
|
27
|
+
return new IdentityCredential(idTrapdoor, idNullifier, idSecretHash, idCommitment);
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* Converts an ID commitment from bytes to a BigInt, normalizing it against a limit if needed
|
31
|
+
* @param bytes The ID commitment bytes to convert
|
32
|
+
* @param limit Optional limit to normalize against (Q value)
|
33
|
+
* @returns The ID commitment as a BigInt
|
34
|
+
*/
|
35
|
+
static getIdCommitmentBigInt(idCommitment, limit = DEFAULT_Q) {
|
36
|
+
let idCommitmentBigIntBE = buildBigIntFromUint8ArrayBE(idCommitment);
|
37
|
+
if (limit && idCommitmentBigIntBE >= limit) {
|
38
|
+
log.warn(`ID commitment is greater than Q, reducing it by Q: ${idCommitmentBigIntBE} % ${limit}`);
|
39
|
+
idCommitmentBigIntBE = idCommitmentBigIntBE % limit;
|
40
|
+
}
|
41
|
+
return idCommitmentBigIntBE;
|
25
42
|
}
|
26
43
|
}
|
27
44
|
//# sourceMappingURL=identity.js.map
|
package/dist/identity.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../src/identity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kBAAkB,CAAC;AAE/D,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAE5C,MAAM,OAAO,kBAAkB;IAKX;IACA;IACA;IACA;IAPlB;;OAEG;IACH,YACkB,UAAsB,EACtB,WAAuB,EACvB,YAAwB,EACxB,YAAwB;QAHxB,eAAU,GAAV,UAAU,CAAY;QACtB,gBAAW,GAAX,WAAW,CAAY;QACvB,iBAAY,GAAZ,YAAY,CAAY;QACxB,iBAAY,GAAZ,YAAY,CAAY;IACvC,CAAC;IAEG,MAAM,CAAC,SAAS,CAAC,OAAmB;QACzC,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;QAED,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC7C,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC9C,MAAM,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;QAE/C,OAAO,IAAI,kBAAkB,CAC3B,UAAU,EACV,WAAW,EACX,YAAY,EACZ,YAAY,CACb,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,qBAAqB,CACjC,YAAwB,EACxB,QAAgB,SAAS;QAEzB,IAAI,oBAAoB,GAAG,2BAA2B,CAAC,YAAY,CAAC,CAAC;QAErE,IAAI,KAAK,IAAI,oBAAoB,IAAI,KAAK,EAAE,CAAC;YAC3C,GAAG,CAAC,IAAI,CACN,sDAAsD,oBAAoB,MAAM,KAAK,EAAE,CACxF,CAAC;YACF,oBAAoB,GAAG,oBAAoB,GAAG,KAAK,CAAC;QACtD,CAAC;QACD,OAAO,oBAAoB,CAAC;IAC9B,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
@@ -11,4 +11,5 @@ import { RLNInstance } from "./rln.js";
|
|
11
11
|
import { MerkleRootTracker } from "./root_tracker.js";
|
12
12
|
import { extractMetaMaskSigner } from "./utils/index.js";
|
13
13
|
export { RLNCredentialsManager, RLNBaseContract, createRLN, Keystore, RLNInstance, IdentityCredential, Proof, RLNEncoder, RLNDecoder, MerkleRootTracker, RLNContract, LINEA_CONTRACT, extractMetaMaskSigner, RLN_ABI };
|
14
|
-
export type { DecryptedCredentials, EncryptedCredentials, Keccak256Hash, KeystoreEntity, MembershipHash,
|
14
|
+
export type { DecryptedCredentials, EncryptedCredentials, Keccak256Hash, KeystoreEntity, MembershipHash, KeystoreMembershipInfo, Password, Sha256Hash } from "./keystore/types.js";
|
15
|
+
export * from "./contract/index.js";
|
package/dist/index.js
CHANGED
@@ -11,4 +11,5 @@ import { RLNInstance } from "./rln.js";
|
|
11
11
|
import { MerkleRootTracker } from "./root_tracker.js";
|
12
12
|
import { extractMetaMaskSigner } from "./utils/index.js";
|
13
13
|
export { RLNCredentialsManager, RLNBaseContract, createRLN, Keystore, RLNInstance, IdentityCredential, Proof, RLNEncoder, RLNDecoder, MerkleRootTracker, RLNContract, LINEA_CONTRACT, extractMetaMaskSigner, RLN_ABI };
|
14
|
+
export * from "./contract/index.js";
|
14
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,SAAS,EACT,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,KAAK,EACL,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,OAAO,EACR,CAAC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,SAAS,EACT,QAAQ,EACR,WAAW,EACX,kBAAkB,EAClB,KAAK,EACL,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,qBAAqB,EACrB,OAAO,EACR,CAAC;AAaF,cAAc,qBAAqB,CAAC"}
|
@@ -4,7 +4,6 @@ import { sha256 } from "ethereum-cryptography/sha256";
|
|
4
4
|
import { bytesToHex, bytesToUtf8, utf8ToBytes } from "ethereum-cryptography/utils";
|
5
5
|
import _ from "lodash";
|
6
6
|
import { v4 as uuidV4 } from "uuid";
|
7
|
-
import { buildBigIntFromUint8Array } from "../utils/bytes.js";
|
8
7
|
import { decryptEipKeystore, keccak256Checksum } from "./cipher.js";
|
9
8
|
import { isCredentialValid, isKeystoreValid } from "./schema_validator.js";
|
10
9
|
const log = new Logger("waku:rln:keystore");
|
@@ -147,14 +146,16 @@ export class Keystore {
|
|
147
146
|
try {
|
148
147
|
const str = bytesToUtf8(bytes);
|
149
148
|
const obj = JSON.parse(str);
|
150
|
-
|
149
|
+
const idCommitmentLE = Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idCommitment", []));
|
150
|
+
const idTrapdoorLE = Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idTrapdoor", []));
|
151
|
+
const idNullifierLE = Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idNullifier", []));
|
152
|
+
const idSecretHashLE = Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idSecretHash", []));
|
151
153
|
return {
|
152
154
|
identity: {
|
153
|
-
IDCommitment:
|
154
|
-
IDTrapdoor:
|
155
|
-
IDNullifier:
|
156
|
-
|
157
|
-
IDSecretHash: Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idSecretHash", []))
|
155
|
+
IDCommitment: idCommitmentLE,
|
156
|
+
IDTrapdoor: idTrapdoorLE,
|
157
|
+
IDNullifier: idNullifierLE,
|
158
|
+
IDSecretHash: idSecretHashLE
|
158
159
|
},
|
159
160
|
membership: {
|
160
161
|
treeIndex: _.get(obj, "treeIndex"),
|
@@ -191,13 +192,16 @@ export class Keystore {
|
|
191
192
|
// follows nwaku implementation
|
192
193
|
// https://github.com/waku-org/nwaku/blob/f05528d4be3d3c876a8b07f9bb7dfaae8aa8ec6e/waku/waku_keystore/protocol_types.nim#L98
|
193
194
|
static fromIdentityToBytes(options) {
|
195
|
+
function toLittleEndian(bytes) {
|
196
|
+
return new Uint8Array(bytes).reverse();
|
197
|
+
}
|
194
198
|
return utf8ToBytes(JSON.stringify({
|
195
199
|
treeIndex: options.membership.treeIndex,
|
196
200
|
identityCredential: {
|
197
|
-
idCommitment: Array.from(options.identity.IDCommitment),
|
198
|
-
idNullifier: Array.from(options.identity.IDNullifier),
|
199
|
-
idSecretHash: Array.from(options.identity.IDSecretHash),
|
200
|
-
idTrapdoor: Array.from(options.identity.IDTrapdoor)
|
201
|
+
idCommitment: Array.from(toLittleEndian(options.identity.IDCommitment)),
|
202
|
+
idNullifier: Array.from(toLittleEndian(options.identity.IDNullifier)),
|
203
|
+
idSecretHash: Array.from(toLittleEndian(options.identity.IDSecretHash)),
|
204
|
+
idTrapdoor: Array.from(toLittleEndian(options.identity.IDTrapdoor))
|
201
205
|
},
|
202
206
|
membershipContract: {
|
203
207
|
chainId: options.membership.chainId,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"keystore.js","sourceRoot":"","sources":["../../src/keystore/keystore.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"keystore.js","sourceRoot":"","sources":["../../src/keystore/keystore.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,IAAI,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EACL,UAAU,EACV,WAAW,EACX,WAAW,EACZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAU3E,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAiC5C,MAAM,OAAO,QAAQ;IACX,IAAI,CAAgB;IAE5B,YAAoB,OAA8C;QAChE,IAAI,CAAC,IAAI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ash = string;
|
|
3
3
|
export type Sha256Hash = string;
|
4
4
|
export type Keccak256Hash = string;
|
5
5
|
export type Password = string | Uint8Array;
|
6
|
-
export type
|
6
|
+
export type KeystoreMembershipInfo = {
|
7
7
|
chainId: string;
|
8
8
|
address: string;
|
9
9
|
treeIndex: number;
|
@@ -11,7 +11,7 @@ export type MembershipInfo = {
|
|
11
11
|
};
|
12
12
|
export type KeystoreEntity = {
|
13
13
|
identity: IdentityCredential;
|
14
|
-
membership:
|
14
|
+
membership: KeystoreMembershipInfo;
|
15
15
|
};
|
16
16
|
export type DecryptedCredentials = KeystoreEntity;
|
17
17
|
export type EncryptedCredentials = {
|
package/dist/message.d.ts
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
import type { IDecodedMessage, IMessage, IRateLimitProof } from "@waku/interfaces";
|
1
|
+
import type { IDecodedMessage, IMessage, IRateLimitProof, IRlnMessage } from "@waku/interfaces";
|
2
2
|
import { RLNInstance } from "./rln.js";
|
3
3
|
export declare function toRLNSignal(contentTopic: string, msg: IMessage): Uint8Array;
|
4
|
-
export declare class RlnMessage<T extends IDecodedMessage> implements
|
5
|
-
rlnInstance
|
6
|
-
msg
|
4
|
+
export declare class RlnMessage<T extends IDecodedMessage> implements IRlnMessage {
|
5
|
+
private rlnInstance;
|
6
|
+
private msg;
|
7
7
|
rateLimitProof: IRateLimitProof | undefined;
|
8
8
|
pubsubTopic: string;
|
9
|
+
version: number;
|
9
10
|
constructor(rlnInstance: RLNInstance, msg: T, rateLimitProof: IRateLimitProof | undefined);
|
10
11
|
verify(roots: Uint8Array[]): boolean | undefined;
|
11
12
|
verifyNoRoot(): boolean | undefined;
|
package/dist/message.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { message } from "@waku/core";
|
1
2
|
import * as utils from "@waku/utils/bytes";
|
2
3
|
import { epochBytesToInt } from "./utils/index.js";
|
3
4
|
export function toRLNSignal(contentTopic, msg) {
|
@@ -9,6 +10,7 @@ export class RlnMessage {
|
|
9
10
|
msg;
|
10
11
|
rateLimitProof;
|
11
12
|
pubsubTopic = "";
|
13
|
+
version = message.version_0.Version;
|
12
14
|
constructor(rlnInstance, msg, rateLimitProof) {
|
13
15
|
this.rlnInstance = rlnInstance;
|
14
16
|
this.msg = msg;
|
package/dist/message.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../src/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAOrC,OAAO,KAAK,KAAK,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,UAAU,WAAW,CAAC,YAAoB,EAAE,GAAa;IAC7D,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;IAChE,OAAO,IAAI,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,GAAG,iBAAiB,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,OAAO,UAAU;IAKX;IACA;IACD;IANF,WAAW,GAAG,EAAE,CAAC;IACjB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC;IAE3C,YACU,WAAwB,EACxB,GAAM,EACP,cAA2C;QAF1C,gBAAW,GAAX,WAAW,CAAa;QACxB,QAAG,GAAH,GAAG,CAAG;QACP,mBAAc,GAAd,cAAc,CAA6B;IACjD,CAAC;IAEG,MAAM,CAAC,KAAmB;QAC/B,OAAO,IAAI,CAAC,cAAc;YACxB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,eAAe,CACtC,IAAI,CAAC,cAAc,EACnB,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,EAC5C,KAAK,CACN,CAAC,2EAA2E;YAC/E,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAEM,YAAY;QACjB,OAAO,IAAI,CAAC,cAAc;YACxB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,gBAAgB,CACvC,IAAI,CAAC,cAAc,EACnB,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,CAC7C,CAAC,2EAA2E;YAC/E,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;IAC1B,CAAC;IAED,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC;IAC/B,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;IAC5B,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;IAC5B,CAAC;IAED,IAAW,IAAI;QACb,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,IAAW,KAAK;QACd,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC;QACzC,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAC;QAE7B,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;CACF"}
|
package/dist/utils/bytes.d.ts
CHANGED
@@ -4,13 +4,9 @@
|
|
4
4
|
* @returns concatenation of all Uint8Array received as input
|
5
5
|
*/
|
6
6
|
export declare function concatenate(...input: Uint8Array[]): Uint8Array;
|
7
|
+
export declare function switchEndianness(bytes: Uint8Array): Uint8Array;
|
8
|
+
export declare function buildBigIntFromUint8ArrayBE(bytes: Uint8Array): bigint;
|
7
9
|
export declare function writeUIntLE(buf: Uint8Array, value: number, offset: number, byteLength: number, noAssert?: boolean): Uint8Array;
|
8
|
-
/**
|
9
|
-
* Transforms Uint8Array into BigInt
|
10
|
-
* @param array: Uint8Array
|
11
|
-
* @returns BigInt
|
12
|
-
*/
|
13
|
-
export declare function buildBigIntFromUint8Array(array: Uint8Array, byteOffset?: number): bigint;
|
14
10
|
/**
|
15
11
|
* Fills with zeros to set length
|
16
12
|
* @param array little endian Uint8Array
|
package/dist/utils/bytes.js
CHANGED
@@ -16,12 +16,12 @@ export function concatenate(...input) {
|
|
16
16
|
}
|
17
17
|
return result;
|
18
18
|
}
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
export function switchEndianness(bytes) {
|
20
|
+
return new Uint8Array(bytes.reverse());
|
21
|
+
}
|
22
|
+
export function buildBigIntFromUint8ArrayBE(bytes) {
|
23
|
+
// Interpret bytes as big-endian
|
24
|
+
return bytes.reduce((acc, byte) => (acc << 8n) + BigInt(byte), 0n);
|
25
25
|
}
|
26
26
|
export function writeUIntLE(buf, value, offset, byteLength, noAssert) {
|
27
27
|
value = +value;
|
@@ -39,15 +39,6 @@ export function writeUIntLE(buf, value, offset, byteLength, noAssert) {
|
|
39
39
|
}
|
40
40
|
return buf;
|
41
41
|
}
|
42
|
-
/**
|
43
|
-
* Transforms Uint8Array into BigInt
|
44
|
-
* @param array: Uint8Array
|
45
|
-
* @returns BigInt
|
46
|
-
*/
|
47
|
-
export function buildBigIntFromUint8Array(array, byteOffset = 0) {
|
48
|
-
const dataView = new DataView(array.buffer);
|
49
|
-
return dataView.getBigUint64(byteOffset, true);
|
50
|
-
}
|
51
42
|
/**
|
52
43
|
* Fills with zeros to set length
|
53
44
|
* @param array little endian Uint8Array
|
@@ -61,4 +52,11 @@ export function zeroPadLE(array, length) {
|
|
61
52
|
}
|
62
53
|
return result;
|
63
54
|
}
|
55
|
+
// Adapted from https://github.com/feross/buffer
|
56
|
+
function checkInt(buf, value, offset, ext, max, min) {
|
57
|
+
if (value > max || value < min)
|
58
|
+
throw new RangeError('"value" argument is out of bounds');
|
59
|
+
if (offset + ext > buf.length)
|
60
|
+
throw new RangeError("Index out of range");
|
61
|
+
}
|
64
62
|
//# sourceMappingURL=bytes.js.map
|
package/dist/utils/bytes.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src/utils/bytes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,GAAG,KAAmB;IAChD,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,WAAW,IAAI,GAAG,CAAC,MAAM,CAAC;IAC5B,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3C,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACxB,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC;IACvB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,
|
1
|
+
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src/utils/bytes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,GAAG,KAAmB;IAChD,IAAI,WAAW,GAAG,CAAC,CAAC;IACpB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,WAAW,IAAI,GAAG,CAAC,MAAM,CAAC;IAC5B,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;IAC3C,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;Q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;AACb,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,KAAiB,EAAE,MAAc;IACzD,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,gDAAgD;AAChD,SAAS,QAAQ,CACf,GAAe,EACf,KAAa,EACb,MAAc,EACd,GAAW,EACX,GAAW,EACX,GAAW;IAEX,IAAI,KAAK,GAAG,GAAG,IAAI,KAAK,GAAG,GAAG;QAC5B,MAAM,IAAI,UAAU,CAAC,mCAAmC,CAAC,CAAC;IAC5D,IAAI,MAAM,GAAG,GAAG,GAAG,GAAG,CAAC,MAAM;QAAE,MAAM,IAAI,UAAU,CAAC,oBAAoB,CAAC,CAAC;AAC5E,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
export { extractMetaMaskSigner } from "./metamask.js";
|
2
|
-
export { concatenate, writeUIntLE,
|
2
|
+
export { concatenate, writeUIntLE, switchEndianness, zeroPadLE } from "./bytes.js";
|
3
3
|
export { sha256, poseidonHash } from "./hash.js";
|
4
4
|
export { dateToEpoch, epochIntToBytes, epochBytesToInt } from "./epoch.js";
|
package/dist/utils/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
export { extractMetaMaskSigner } from "./metamask.js";
|
2
|
-
export { concatenate, writeUIntLE,
|
2
|
+
export { concatenate, writeUIntLE, switchEndianness, zeroPadLE } from "./bytes.js";
|
3
3
|
export { sha256, poseidonHash } from "./hash.js";
|
4
4
|
export { dateToEpoch, epochIntToBytes, epochBytesToInt } from "./epoch.js";
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EACL,WAAW,EACX,WAAW,EACX,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EACL,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,SAAS,EACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
|
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"name":"@waku/rln","version":"0.1.6-
|
1
|
+
{"name":"@waku/rln","version":"0.1.6-0877e51.0","description":"RLN (Rate Limiting Nullifier) implementation for Waku","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"type":"module","homepage":"https://github.com/waku-org/js-waku/tree/master/packages/rln#readme","repository":{"type":"git","url":"https://github.com/waku-org/js-waku.git"},"bugs":{"url":"https://github.com/waku-org/js-waku/issues"},"license":"MIT OR Apache-2.0","keywords":["waku","rln","rate-limiting","privacy","web3"],"scripts":{"build":"run-s build:**","build:copy":"mkdir -p dist/resources && cp -r src/resources/* dist/resources/","build:esm":"tsc","build:bundle":"rollup --config rollup.config.js","fix":"run-s fix:*","fix:lint":"eslint src *.js --fix","check":"run-s check:*","check:tsc":"tsc -p tsconfig.dev.json","check:lint":"eslint \"src/!(resources)/**/*.{ts,js}\" *.js","check:spelling":"cspell \"{README.md,src/**/*.ts}\"","test":"NODE_ENV=test run-s test:*","test:browser":"karma start karma.conf.cjs","watch:build":"tsc -p tsconfig.json -w","watch:test":"mocha --watch","prepublish":"npm run build","reset-hard":"git clean -dfx -e .idea && git reset --hard && npm i && npm run build"},"engines":{"node":">=20"},"devDependencies":{"@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.2.3","@types/chai":"^5.0.1","@types/chai-spies":"^1.0.6","@waku/interfaces":"0.0.31-0877e51.0","@types/deep-equal-in-any-order":"^1.0.4","@types/lodash":"^4.17.15","@types/sinon":"^17.0.3","@waku/build-utils":"^1.0.0","@waku/message-encryption":"0.0.34-0877e51.0","deep-equal-in-any-order":"^2.0.6","fast-check":"^3.23.2","rollup-plugin-copy":"^3.5.0"},"files":["dist","bundle","src/**/*.ts","!**/*.spec.*","!**/*.json","CHANGELOG.md","LICENSE","README.md"],"dependencies":{"@chainsafe/bls-keystore":"3.0.0","@waku/core":"0.0.36-0877e51.0","@waku/utils":"0.0.24-0877e51.0","@noble/hashes":"^1.2.0","@waku/zerokit-rln-wasm":"^0.0.13","ethereum-cryptography":"^3.1.0","ethers":"^5.7.2","lodash":"^4.17.21","uuid":"^11.0.5","chai":"^5.1.2","chai-as-promised":"^8.0.1","chai-spies":"^1.1.0","chai-subset":"^1.6.0","sinon":"^19.0.2"}}
|
@@ -25,4 +25,13 @@ export const RATE_LIMIT_PARAMS = {
|
|
25
25
|
EPOCH_LENGTH: 600 // Epoch length in seconds (10 minutes)
|
26
26
|
} as const;
|
27
27
|
|
28
|
+
/**
|
29
|
+
* Default Q value for the RLN contract
|
30
|
+
* This is the upper bound for the ID commitment
|
31
|
+
* @see https://github.com/waku-org/specs/blob/master/standards/core/rln-contract.md#implementation-suggestions
|
32
|
+
*/
|
33
|
+
export const DEFAULT_Q = BigInt(
|
34
|
+
"21888242871839275222246405745257275088548364400416034343698204186575808495617"
|
35
|
+
);
|
36
|
+
|
28
37
|
export const DEFAULT_RATE_LIMIT = RATE_LIMIT_PARAMS.MAX_RATE;
|
package/src/contract/index.ts
CHANGED