@waku/rln 0.1.4-d27db21.0 → 0.1.5-76f86de.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/CHANGELOG.md +19 -0
- package/README.md +5 -0
- package/bundle/index.js +1 -1
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +1 -1
- package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +1 -1
- package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +1 -1
- package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +11 -11
- package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +7 -7
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +2 -2
- package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +2 -2
- package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +1 -1
- package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +1 -1
- package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +44 -44
- package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +8 -8
- package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +1 -1
- package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +1 -1
- package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +1 -1
- package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +2 -2
- package/bundle/node_modules/@multiformats/multiaddr/dist/src/multiaddr.js +1 -0
- package/bundle/node_modules/@noble/hashes/esm/sha3.js +1 -1
- package/bundle/node_modules/bn.js/lib/bn.js +1 -1
- package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +6 -6
- package/bundle/packages/rln/dist/contract/abi.js +502 -248
- package/bundle/packages/rln/dist/contract/constants.js +4 -5
- package/bundle/packages/rln/dist/contract/rln_contract.js +121 -37
- package/bundle/packages/rln/dist/keystore/keystore.js +2 -1
- package/bundle/packages/rln/dist/rln.js +4 -4
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/checksum.js +2 -2
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/cipher.js +3 -3
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/class.js +4 -4
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/functional.js +4 -4
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/kdf.js +4 -4
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/password.js +1 -1
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation-generated.js +1 -1
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation.js +1 -1
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/aes.js +1 -1
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/pbkdf2.js +1 -1
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +1 -1
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/scrypt.js +1 -1
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/sha256.js +1 -1
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/_assert.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +2 -2
- package/bundle/packages/rln/node_modules/@noble/hashes/_u64.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/cryptoBrowser.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +2 -2
- package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +2 -2
- package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +2 -2
- package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/codec.test-utils.d.ts +36 -0
- package/dist/codec.test-utils.js +56 -0
- package/dist/codec.test-utils.js.map +1 -0
- package/dist/contract/abi.d.ts +21 -17
- package/dist/contract/abi.js +502 -248
- package/dist/contract/abi.js.map +1 -1
- package/dist/contract/constants.d.ts +22 -18
- package/dist/contract/constants.js +3 -3
- package/dist/contract/constants.js.map +1 -1
- package/dist/contract/rln_contract.d.ts +10 -3
- package/dist/contract/rln_contract.js +120 -36
- package/dist/contract/rln_contract.js.map +1 -1
- package/dist/contract/test-setup.d.ts +26 -0
- package/dist/contract/test-setup.js +56 -0
- package/dist/contract/test-setup.js.map +1 -0
- package/dist/contract/test-utils.d.ts +39 -0
- package/dist/contract/test-utils.js +118 -0
- package/dist/contract/test-utils.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/keystore/keystore.js +2 -1
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/keystore/types.d.ts +1 -0
- package/dist/rln.d.ts +1 -1
- package/dist/rln.js +4 -4
- package/dist/rln.js.map +1 -1
- package/package.json +1 -1
- package/src/codec.test-utils.ts +80 -0
- package/src/contract/abi.ts +502 -248
- package/src/contract/constants.ts +3 -3
- package/src/contract/rln_contract.ts +158 -46
- package/src/contract/test-setup.ts +86 -0
- package/src/contract/test-utils.ts +179 -0
- package/src/index.ts +13 -2
- package/src/keystore/keystore.ts +2 -1
- package/src/keystore/types.ts +1 -0
- package/src/rln.ts +5 -5
@@ -0,0 +1,36 @@
|
|
1
|
+
import type { IProtoMessage } from "@waku/interfaces";
|
2
|
+
import type { IdentityCredential } from "./identity.js";
|
3
|
+
export interface TestRLNCodecSetup {
|
4
|
+
rlnInstance: any;
|
5
|
+
credential: IdentityCredential;
|
6
|
+
index: number;
|
7
|
+
payload: Uint8Array;
|
8
|
+
}
|
9
|
+
export declare const TEST_CONSTANTS: {
|
10
|
+
readonly contentTopic: "/test/1/waku-message/utf8";
|
11
|
+
readonly emptyPubsubTopic: "";
|
12
|
+
readonly defaultIndex: 0;
|
13
|
+
readonly defaultPayload: Uint8Array;
|
14
|
+
};
|
15
|
+
export declare const EMPTY_PROTO_MESSAGE: {
|
16
|
+
readonly timestamp: undefined;
|
17
|
+
readonly contentTopic: "";
|
18
|
+
readonly ephemeral: undefined;
|
19
|
+
readonly meta: undefined;
|
20
|
+
readonly rateLimitProof: undefined;
|
21
|
+
readonly version: undefined;
|
22
|
+
};
|
23
|
+
/**
|
24
|
+
* Creates a basic RLN setup for codec tests
|
25
|
+
*/
|
26
|
+
export declare function createTestRLNCodecSetup(): Promise<TestRLNCodecSetup>;
|
27
|
+
/**
|
28
|
+
* Creates a meta setter function for testing
|
29
|
+
*/
|
30
|
+
export declare function createTestMetaSetter(): (msg: IProtoMessage & {
|
31
|
+
meta: undefined;
|
32
|
+
}) => Uint8Array;
|
33
|
+
/**
|
34
|
+
* Verifies common RLN message properties
|
35
|
+
*/
|
36
|
+
export declare function verifyRLNMessage(msg: any, payload: Uint8Array, contentTopic: string, version: number, rlnInstance: any): void;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import { expect } from "chai";
|
2
|
+
import { createRLN } from "./create.js";
|
3
|
+
export const TEST_CONSTANTS = {
|
4
|
+
contentTopic: "/test/1/waku-message/utf8",
|
5
|
+
emptyPubsubTopic: "",
|
6
|
+
defaultIndex: 0,
|
7
|
+
defaultPayload: new Uint8Array([1, 2, 3, 4, 5])
|
8
|
+
};
|
9
|
+
export const EMPTY_PROTO_MESSAGE = {
|
10
|
+
timestamp: undefined,
|
11
|
+
contentTopic: "",
|
12
|
+
ephemeral: undefined,
|
13
|
+
meta: undefined,
|
14
|
+
rateLimitProof: undefined,
|
15
|
+
version: undefined
|
16
|
+
};
|
17
|
+
/**
|
18
|
+
* Creates a basic RLN setup for codec tests
|
19
|
+
*/
|
20
|
+
export async function createTestRLNCodecSetup() {
|
21
|
+
const rlnInstance = await createRLN();
|
22
|
+
const credential = rlnInstance.zerokit.generateIdentityCredentials();
|
23
|
+
rlnInstance.zerokit.insertMember(credential.IDCommitment);
|
24
|
+
return {
|
25
|
+
rlnInstance,
|
26
|
+
credential,
|
27
|
+
index: TEST_CONSTANTS.defaultIndex,
|
28
|
+
payload: TEST_CONSTANTS.defaultPayload
|
29
|
+
};
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Creates a meta setter function for testing
|
33
|
+
*/
|
34
|
+
export function createTestMetaSetter() {
|
35
|
+
return (msg) => {
|
36
|
+
const buffer = new ArrayBuffer(4);
|
37
|
+
const view = new DataView(buffer);
|
38
|
+
view.setUint32(0, msg.payload.length, false);
|
39
|
+
return new Uint8Array(buffer);
|
40
|
+
};
|
41
|
+
}
|
42
|
+
/**
|
43
|
+
* Verifies common RLN message properties
|
44
|
+
*/
|
45
|
+
export function verifyRLNMessage(msg, payload, contentTopic, version, rlnInstance) {
|
46
|
+
expect(msg.rateLimitProof).to.not.be.undefined;
|
47
|
+
expect(msg.verify([rlnInstance.zerokit.getMerkleRoot()])).to.be.true;
|
48
|
+
expect(msg.verifyNoRoot()).to.be.true;
|
49
|
+
expect(msg.epoch).to.not.be.undefined;
|
50
|
+
expect(msg.epoch).to.be.gt(0);
|
51
|
+
expect(msg.contentTopic).to.eq(contentTopic);
|
52
|
+
expect(msg.msg.version).to.eq(version);
|
53
|
+
expect(msg.payload).to.deep.eq(payload);
|
54
|
+
expect(msg.timestamp).to.not.be.undefined;
|
55
|
+
}
|
56
|
+
//# sourceMappingURL=codec.test-utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"codec.test-utils.js","sourceRoot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
4
3
|
stateMutability: string;
|
4
|
+
type: string;
|
5
5
|
name?: undefined;
|
6
|
-
outputs?: undefined;
|
7
6
|
anonymous?: undefined;
|
7
|
+
outputs?: undefined;
|
8
8
|
} | {
|
9
|
-
type: string;
|
10
|
-
name: string;
|
11
9
|
inputs: {
|
10
|
+
internalType: string;
|
12
11
|
name: string;
|
13
12
|
type: string;
|
14
13
|
}[];
|
14
|
+
name: string;
|
15
|
+
type: string;
|
15
16
|
stateMutability?: undefined;
|
16
|
-
outputs?: undefined;
|
17
17
|
anonymous?: undefined;
|
18
|
+
outputs?: undefined;
|
18
19
|
} | {
|
19
|
-
|
20
|
-
name: string;
|
20
|
+
anonymous: boolean;
|
21
21
|
inputs: {
|
22
|
+
indexed: boolean;
|
23
|
+
internalType: string;
|
22
24
|
name: string;
|
23
25
|
type: string;
|
24
26
|
}[];
|
25
|
-
|
27
|
+
name: string;
|
28
|
+
type: string;
|
29
|
+
stateMutability?: undefined;
|
30
|
+
outputs?: undefined;
|
31
|
+
} | {
|
32
|
+
inputs: {
|
33
|
+
internalType: string;
|
26
34
|
name: string;
|
27
35
|
type: string;
|
28
36
|
}[];
|
29
|
-
stateMutability: string;
|
30
|
-
anonymous?: undefined;
|
31
|
-
} | {
|
32
|
-
type: string;
|
33
37
|
name: string;
|
34
|
-
|
38
|
+
outputs: {
|
39
|
+
internalType: string;
|
35
40
|
name: string;
|
36
41
|
type: string;
|
37
|
-
indexed: boolean;
|
38
42
|
}[];
|
39
|
-
|
40
|
-
|
41
|
-
|
43
|
+
stateMutability: string;
|
44
|
+
type: string;
|
45
|
+
anonymous?: undefined;
|
42
46
|
})[];
|