@waku/rln 0.1.6-b0a2e39.0 → 0.1.6-b133417.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/utils.js +2 -2
- package/bundle/_virtual/utils2.js +2 -2
- package/bundle/index.js +1 -1
- package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/_sha2.js +1 -1
- package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/hmac.js +1 -1
- package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/pbkdf2.js +1 -1
- package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/scrypt.js +1 -1
- package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/sha256.js +1 -1
- package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/sha512.js +1 -1
- package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/utils.js +1 -1
- package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +1 -1
- package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +2 -2
- package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +0 -1
- package/bundle/packages/core/dist/lib/connection_manager/keep_alive_manager.js +0 -1
- package/bundle/packages/core/dist/lib/filter/filter.js +0 -2
- package/bundle/packages/core/dist/lib/light_push/light_push.js +9 -12
- package/bundle/packages/core/dist/lib/message/version_0.js +0 -1
- package/bundle/packages/core/dist/lib/metadata/metadata.js +0 -2
- package/bundle/packages/core/dist/lib/store/store.js +0 -2
- package/bundle/packages/interfaces/dist/protocols.js +0 -10
- package/bundle/packages/proto/dist/generated/light_push.js +3 -3
- package/bundle/packages/rln/dist/codec.js +0 -1
- package/bundle/packages/rln/dist/contract/constants.js +7 -1
- package/bundle/packages/rln/dist/contract/rln_base_contract.js +5 -3
- package/bundle/packages/rln/dist/contract/rln_contract.js +2 -3
- package/bundle/packages/rln/dist/credentials_manager.js +24 -17
- package/bundle/packages/rln/dist/identity.js +8 -6
- package/bundle/packages/rln/dist/keystore/keystore.js +22 -12
- package/bundle/packages/rln/dist/message.js +0 -2
- package/bundle/packages/rln/dist/proof.js +2 -2
- package/bundle/packages/rln/dist/rln.js +0 -2
- package/bundle/packages/rln/dist/utils/bytes.js +103 -58
- package/bundle/packages/rln/dist/utils/epoch.js +0 -1
- package/bundle/packages/rln/dist/utils/hash.js +3 -3
- package/bundle/packages/rln/dist/zerokit.js +17 -17
- package/bundle/packages/utils/dist/common/sharding/index.js +0 -1
- 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/rln_base_contract.js +5 -2
- package/dist/contract/rln_base_contract.js.map +1 -1
- package/dist/contract/rln_contract.js +2 -2
- package/dist/contract/rln_contract.js.map +1 -1
- package/dist/credentials_manager.d.ts +4 -0
- package/dist/credentials_manager.js +25 -16
- package/dist/credentials_manager.js.map +1 -1
- package/dist/identity.d.ts +5 -2
- package/dist/identity.js +8 -5
- package/dist/identity.js.map +1 -1
- package/dist/keystore/keystore.js +22 -11
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/proof.js +2 -2
- package/dist/proof.js.map +1 -1
- package/dist/utils/bytes.d.ts +42 -20
- package/dist/utils/bytes.js +102 -57
- package/dist/utils/bytes.js.map +1 -1
- package/dist/utils/hash.js +5 -5
- package/dist/utils/hash.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/dist/zerokit.js +17 -17
- package/dist/zerokit.js.map +1 -1
- package/package.json +1 -1
- package/src/contract/constants.ts +9 -0
- package/src/contract/rln_base_contract.ts +5 -3
- package/src/contract/rln_contract.ts +5 -2
- package/src/credentials_manager.ts +46 -24
- package/src/identity.ts +11 -7
- package/src/keystore/keystore.ts +41 -23
- package/src/proof.ts +2 -2
- package/src/utils/bytes.ts +118 -72
- package/src/utils/hash.ts +15 -5
- package/src/utils/index.ts +1 -6
- package/src/zerokit.ts +30 -22
- package/bundle/packages/core/dist/lib/light_push/light_push_v3.js +0 -30
- package/bundle/packages/core/dist/lib/light_push/utils.js +0 -18
- package/bundle/packages/interfaces/dist/light_push_v3.js +0 -29
- package/bundle/packages/proto/dist/generated/light_push_v3.js +0 -348
- 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/_virtual/utils.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
var utils = {
|
1
|
+
var utils = {};
|
2
2
|
|
3
|
-
export { utils as
|
3
|
+
export { utils as __exports };
|
@@ -1,3 +1,3 @@
|
|
1
|
-
var utils = {};
|
1
|
+
var utils = {exports: {}};
|
2
2
|
|
3
|
-
export { utils as
|
3
|
+
export { utils as __module };
|
package/bundle/index.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
export { RLNDecoder, RLNEncoder } from './packages/rln/dist/codec.js';
|
2
2
|
export { RLN_ABI } from './packages/rln/dist/contract/abi.js';
|
3
3
|
export { RLNContract } from './packages/rln/dist/contract/rln_contract.js';
|
4
|
-
export { DEFAULT_RATE_LIMIT, LINEA_CONTRACT, RATE_LIMIT_PARAMS, RATE_LIMIT_TIERS } from './packages/rln/dist/contract/constants.js';
|
4
|
+
export { DEFAULT_Q, DEFAULT_RATE_LIMIT, LINEA_CONTRACT, RATE_LIMIT_PARAMS, RATE_LIMIT_TIERS } from './packages/rln/dist/contract/constants.js';
|
5
5
|
export { MembershipState } from './packages/rln/dist/contract/types.js';
|
6
6
|
export { RLNBaseContract } from './packages/rln/dist/contract/rln_base_contract.js';
|
7
7
|
export { createRLN } from './packages/rln/dist/create.js';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { __exports as _sha2 } from '../../../../../../_virtual/_sha2.js';
|
2
2
|
import './_assert.js';
|
3
3
|
import './utils.js';
|
4
|
-
import { __exports as utils } from '../../../../../../_virtual/
|
4
|
+
import { __exports as utils } from '../../../../../../_virtual/utils.js';
|
5
5
|
import { __exports as _assert } from '../../../../../../_virtual/_assert.js';
|
6
6
|
|
7
7
|
Object.defineProperty(_sha2, "__esModule", { value: true });
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { __exports as hmac } from '../../../../../../_virtual/hmac.js';
|
2
2
|
import './_assert.js';
|
3
3
|
import './utils.js';
|
4
|
-
import { __exports as utils } from '../../../../../../_virtual/
|
4
|
+
import { __exports as utils } from '../../../../../../_virtual/utils.js';
|
5
5
|
import { __exports as _assert } from '../../../../../../_virtual/_assert.js';
|
6
6
|
|
7
7
|
(function (exports) {
|
@@ -2,7 +2,7 @@ import { __exports as pbkdf2$1 } from '../../../../../../_virtual/pbkdf22.js';
|
|
2
2
|
import './_assert.js';
|
3
3
|
import './hmac.js';
|
4
4
|
import './utils.js';
|
5
|
-
import { __exports as utils } from '../../../../../../_virtual/
|
5
|
+
import { __exports as utils } from '../../../../../../_virtual/utils.js';
|
6
6
|
import { __exports as _assert } from '../../../../../../_virtual/_assert.js';
|
7
7
|
import { __exports as hmac } from '../../../../../../_virtual/hmac.js';
|
8
8
|
|
@@ -3,7 +3,7 @@ import './_assert.js';
|
|
3
3
|
import './sha256.js';
|
4
4
|
import './pbkdf2.js';
|
5
5
|
import './utils.js';
|
6
|
-
import { __exports as utils } from '../../../../../../_virtual/
|
6
|
+
import { __exports as utils } from '../../../../../../_virtual/utils.js';
|
7
7
|
import { __exports as _assert } from '../../../../../../_virtual/_assert.js';
|
8
8
|
import { __exports as pbkdf2 } from '../../../../../../_virtual/pbkdf22.js';
|
9
9
|
import { __exports as sha256 } from '../../../../../../_virtual/sha2562.js';
|
@@ -2,7 +2,7 @@ import { __exports as sha256 } from '../../../../../../_virtual/sha2562.js';
|
|
2
2
|
import './_sha2.js';
|
3
3
|
import './utils.js';
|
4
4
|
import { __exports as _sha2 } from '../../../../../../_virtual/_sha2.js';
|
5
|
-
import { __exports as utils } from '../../../../../../_virtual/
|
5
|
+
import { __exports as utils } from '../../../../../../_virtual/utils.js';
|
6
6
|
|
7
7
|
Object.defineProperty(sha256, "__esModule", { value: true });
|
8
8
|
sha256.sha224 = sha256.sha256 = void 0;
|
@@ -4,7 +4,7 @@ import './_u64.js';
|
|
4
4
|
import './utils.js';
|
5
5
|
import { __exports as _u64 } from '../../../../../../_virtual/_u64.js';
|
6
6
|
import { __exports as _sha2 } from '../../../../../../_virtual/_sha2.js';
|
7
|
-
import { __exports as utils } from '../../../../../../_virtual/
|
7
|
+
import { __exports as utils } from '../../../../../../_virtual/utils.js';
|
8
8
|
|
9
9
|
Object.defineProperty(sha512, "__esModule", { value: true });
|
10
10
|
sha512.sha384 = sha512.sha512_256 = sha512.sha512_224 = sha512.sha512 = sha512.SHA512 = void 0;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { __exports as utils } from '../../../../../../_virtual/
|
1
|
+
import { __exports as utils } from '../../../../../../_virtual/utils.js';
|
2
2
|
import './cryptoBrowser.js';
|
3
3
|
import { __exports as cryptoBrowser } from '../../../../../../_virtual/cryptoBrowser.js';
|
4
4
|
|
package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { __exports as random } from '../../../../../_virtual/random.js';
|
2
2
|
import '../@noble/hashes/utils.js';
|
3
|
-
import { __exports as utils } from '../../../../../_virtual/
|
3
|
+
import { __exports as utils } from '../../../../../_virtual/utils.js';
|
4
4
|
|
5
5
|
Object.defineProperty(random, "__esModule", { value: true });
|
6
6
|
random.getRandomBytes = random.getRandomBytesSync = void 0;
|
package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import { commonjsGlobal } from '../../../../../_virtual/_commonjsHelpers.js';
|
2
2
|
import { commonjsRequire } from '../../../../../_virtual/_commonjs-dynamic-modules.js';
|
3
|
-
import { __module as utils } from '../../../../../_virtual/
|
3
|
+
import { __module as utils } from '../../../../../_virtual/utils2.js';
|
4
4
|
import '../@noble/hashes/_assert.js';
|
5
5
|
import '../@noble/hashes/utils.js';
|
6
6
|
import { __exports as _assert } from '../../../../../_virtual/_assert.js';
|
7
|
-
import { __exports as utils$1 } from '../../../../../_virtual/
|
7
|
+
import { __exports as utils$1 } from '../../../../../_virtual/utils.js';
|
8
8
|
|
9
9
|
utils.exports;
|
10
10
|
|
@@ -12,7 +12,6 @@ import '../../../../../node_modules/multiformats/dist/src/codecs/json.js';
|
|
12
12
|
import '../../../../../node_modules/@multiformats/multiaddr/dist/src/convert.js';
|
13
13
|
import '../../../../../node_modules/@multiformats/multiaddr/dist/src/protocols-table.js';
|
14
14
|
import '../../../../../node_modules/@multiformats/multiaddr/dist/src/multiaddr.js';
|
15
|
-
import '../../../../interfaces/dist/light_push_v3.js';
|
16
15
|
import '../../../../interfaces/dist/protocols.js';
|
17
16
|
import '../../../../interfaces/dist/connection_manager.js';
|
18
17
|
import '../../../../interfaces/dist/health_indicator.js';
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import '../../../../interfaces/dist/light_push_v3.js';
|
2
1
|
import '../../../../interfaces/dist/protocols.js';
|
3
2
|
import '../../../../interfaces/dist/connection_manager.js';
|
4
3
|
import '../../../../interfaces/dist/health_indicator.js';
|
@@ -20,7 +19,6 @@ import '../../../../proto/dist/generated/filter.js';
|
|
20
19
|
import '../../../../proto/dist/generated/topic_only_message.js';
|
21
20
|
import '../../../../proto/dist/generated/filter_v2.js';
|
22
21
|
import '../../../../proto/dist/generated/light_push.js';
|
23
|
-
import '../../../../proto/dist/generated/light_push_v3.js';
|
24
22
|
import '../../../../proto/dist/generated/store_v3.js';
|
25
23
|
import '../../../../proto/dist/generated/peer_exchange.js';
|
26
24
|
import '../../../../proto/dist/generated/metadata.js';
|
@@ -1,7 +1,15 @@
|
|
1
|
-
import '../../../../interfaces/dist/light_push_v3.js';
|
2
1
|
import '../../../../interfaces/dist/protocols.js';
|
3
2
|
import '../../../../interfaces/dist/connection_manager.js';
|
4
3
|
import '../../../../interfaces/dist/health_indicator.js';
|
4
|
+
import '../../../../proto/dist/generated/message.js';
|
5
|
+
import '../../../../proto/dist/generated/filter.js';
|
6
|
+
import '../../../../proto/dist/generated/topic_only_message.js';
|
7
|
+
import '../../../../proto/dist/generated/filter_v2.js';
|
8
|
+
export { PushResponse } from '../../../../proto/dist/generated/light_push.js';
|
9
|
+
import '../../../../proto/dist/generated/store_v3.js';
|
10
|
+
import '../../../../proto/dist/generated/peer_exchange.js';
|
11
|
+
import '../../../../proto/dist/generated/metadata.js';
|
12
|
+
import '../../../../proto/dist/generated/sds_message.js';
|
5
13
|
import '../../../../../node_modules/multiformats/dist/src/bases/base10.js';
|
6
14
|
import '../../../../../node_modules/multiformats/dist/src/bases/base16.js';
|
7
15
|
import '../../../../../node_modules/multiformats/dist/src/bases/base2.js';
|
@@ -15,16 +23,5 @@ import '../../../../../node_modules/multiformats/dist/src/bases/identity.js';
|
|
15
23
|
import '../../../../../node_modules/multiformats/dist/src/codecs/json.js';
|
16
24
|
import { Logger } from '../../../../utils/dist/logger/index.js';
|
17
25
|
import '../../../../../node_modules/it-length-prefixed/dist/src/decode.js';
|
18
|
-
import '../../../../proto/dist/generated/message.js';
|
19
|
-
import '../../../../proto/dist/generated/filter.js';
|
20
|
-
import '../../../../proto/dist/generated/topic_only_message.js';
|
21
|
-
import '../../../../proto/dist/generated/filter_v2.js';
|
22
|
-
import '../../../../proto/dist/generated/light_push.js';
|
23
|
-
import '../../../../proto/dist/generated/light_push_v3.js';
|
24
|
-
import '../../../../proto/dist/generated/store_v3.js';
|
25
|
-
import '../../../../proto/dist/generated/peer_exchange.js';
|
26
|
-
import '../../../../proto/dist/generated/metadata.js';
|
27
|
-
import '../../../../proto/dist/generated/sds_message.js';
|
28
|
-
import './utils.js';
|
29
26
|
|
30
27
|
new Logger("light-push");
|
@@ -3,7 +3,6 @@ import '../../../../proto/dist/generated/filter.js';
|
|
3
3
|
import '../../../../proto/dist/generated/topic_only_message.js';
|
4
4
|
import '../../../../proto/dist/generated/filter_v2.js';
|
5
5
|
import '../../../../proto/dist/generated/light_push.js';
|
6
|
-
import '../../../../proto/dist/generated/light_push_v3.js';
|
7
6
|
import '../../../../proto/dist/generated/store_v3.js';
|
8
7
|
import '../../../../proto/dist/generated/peer_exchange.js';
|
9
8
|
import '../../../../proto/dist/generated/metadata.js';
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import '../../../../interfaces/dist/light_push_v3.js';
|
2
1
|
import '../../../../interfaces/dist/protocols.js';
|
3
2
|
import '../../../../interfaces/dist/connection_manager.js';
|
4
3
|
import '../../../../interfaces/dist/health_indicator.js';
|
@@ -7,7 +6,6 @@ import '../../../../proto/dist/generated/filter.js';
|
|
7
6
|
import '../../../../proto/dist/generated/topic_only_message.js';
|
8
7
|
import '../../../../proto/dist/generated/filter_v2.js';
|
9
8
|
import '../../../../proto/dist/generated/light_push.js';
|
10
|
-
import '../../../../proto/dist/generated/light_push_v3.js';
|
11
9
|
import '../../../../proto/dist/generated/store_v3.js';
|
12
10
|
import '../../../../proto/dist/generated/peer_exchange.js';
|
13
11
|
import '../../../../proto/dist/generated/metadata.js';
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import '../../../../interfaces/dist/light_push_v3.js';
|
2
1
|
import '../../../../interfaces/dist/protocols.js';
|
3
2
|
import '../../../../interfaces/dist/connection_manager.js';
|
4
3
|
import '../../../../interfaces/dist/health_indicator.js';
|
@@ -20,7 +19,6 @@ import '../../../../proto/dist/generated/filter.js';
|
|
20
19
|
import '../../../../proto/dist/generated/topic_only_message.js';
|
21
20
|
import '../../../../proto/dist/generated/filter_v2.js';
|
22
21
|
import '../../../../proto/dist/generated/light_push.js';
|
23
|
-
import '../../../../proto/dist/generated/light_push_v3.js';
|
24
22
|
import '../../../../proto/dist/generated/store_v3.js';
|
25
23
|
import '../../../../proto/dist/generated/peer_exchange.js';
|
26
24
|
import '../../../../proto/dist/generated/metadata.js';
|
@@ -74,16 +74,6 @@ var ProtocolError;
|
|
74
74
|
* nwaku: https://github.com/waku-org/nwaku/blob/c3cb06ac6c03f0f382d3941ea53b330f6a8dd127/waku/waku_rln_relay/group_manager/group_manager_base.nim#L201C19-L201C42
|
75
75
|
*/
|
76
76
|
ProtocolError["RLN_PROOF_GENERATION"] = "Proof generation failed";
|
77
|
-
/**
|
78
|
-
* Message validation failed according to Light Push v3 specifications.
|
79
|
-
* This includes validation of message format, fields, or other protocol-specific requirements.
|
80
|
-
*/
|
81
|
-
ProtocolError["INVALID_MESSAGE"] = "Invalid message format";
|
82
|
-
/**
|
83
|
-
* Rate limiting error when too many requests are sent in a short period.
|
84
|
-
* Mitigation: Implement backoff strategy or reduce request frequency.
|
85
|
-
*/
|
86
|
-
ProtocolError["RATE_LIMIT_EXCEEDED"] = "Rate limit exceeded";
|
87
77
|
//
|
88
78
|
// RECEIVE ERRORS SECTION
|
89
79
|
//
|
@@ -122,7 +122,7 @@ var PushResponse;
|
|
122
122
|
return decodeMessage(buf, PushResponse.codec(), opts);
|
123
123
|
};
|
124
124
|
})(PushResponse || (PushResponse = {}));
|
125
|
-
var PushRpc;
|
125
|
+
var PushRpc$1;
|
126
126
|
(function (PushRpc) {
|
127
127
|
let _codec;
|
128
128
|
PushRpc.codec = () => {
|
@@ -187,7 +187,7 @@ var PushRpc;
|
|
187
187
|
PushRpc.decode = (buf, opts) => {
|
188
188
|
return decodeMessage(buf, PushRpc.codec(), opts);
|
189
189
|
};
|
190
|
-
})(PushRpc || (PushRpc = {}));
|
190
|
+
})(PushRpc$1 || (PushRpc$1 = {}));
|
191
191
|
var RateLimitProof;
|
192
192
|
(function (RateLimitProof) {
|
193
193
|
let _codec;
|
@@ -386,4 +386,4 @@ var WakuMessage;
|
|
386
386
|
};
|
387
387
|
})(WakuMessage || (WakuMessage = {}));
|
388
388
|
|
389
|
-
export { PushRequest, PushResponse, PushRpc, RateLimitProof, WakuMessage };
|
389
|
+
export { PushRequest, PushResponse, PushRpc$1 as PushRpc, RateLimitProof, WakuMessage };
|
@@ -22,6 +22,12 @@ const RATE_LIMIT_PARAMS = {
|
|
22
22
|
MAX_TOTAL_RATE: 160_000, // Maximum total rate limit across all memberships
|
23
23
|
EPOCH_LENGTH: 600 // Epoch length in seconds (10 minutes)
|
24
24
|
};
|
25
|
+
/**
|
26
|
+
* Default Q value for the RLN contract
|
27
|
+
* This is the upper bound for the ID commitment
|
28
|
+
* @see https://github.com/waku-org/specs/blob/master/standards/core/rln-contract.md#implementation-suggestions
|
29
|
+
*/
|
30
|
+
const DEFAULT_Q = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
|
25
31
|
const DEFAULT_RATE_LIMIT = RATE_LIMIT_PARAMS.MAX_RATE;
|
26
32
|
|
27
|
-
export { DEFAULT_RATE_LIMIT, LINEA_CONTRACT, RATE_LIMIT_PARAMS, RATE_LIMIT_TIERS };
|
33
|
+
export { DEFAULT_Q, DEFAULT_RATE_LIMIT, LINEA_CONTRACT, RATE_LIMIT_PARAMS, RATE_LIMIT_TIERS };
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import '../../../interfaces/dist/light_push_v3.js';
|
2
1
|
import '../../../interfaces/dist/protocols.js';
|
3
2
|
import '../../../interfaces/dist/connection_manager.js';
|
4
3
|
import '../../../interfaces/dist/health_indicator.js';
|
@@ -14,6 +13,7 @@ import '../../../../node_modules/multiformats/dist/src/bases/base8.js';
|
|
14
13
|
import '../../../../node_modules/multiformats/dist/src/bases/identity.js';
|
15
14
|
import '../../../../node_modules/multiformats/dist/src/codecs/json.js';
|
16
15
|
import { Logger } from '../../../utils/dist/logger/index.js';
|
16
|
+
import { BytesUtils } from '../utils/bytes.js';
|
17
17
|
import { RLN_ABI } from './abi.js';
|
18
18
|
import { DEFAULT_RATE_LIMIT, RATE_LIMIT_PARAMS } from './constants.js';
|
19
19
|
import { MembershipState } from './types.js';
|
@@ -353,7 +353,9 @@ class RLNBaseContract {
|
|
353
353
|
}
|
354
354
|
const estimatedGas = await this.contract.estimateGas.register(identity.IDCommitmentBigInt, this.rateLimit, []);
|
355
355
|
const gasLimit = estimatedGas.add(10000);
|
356
|
-
const txRegisterResponse = await this.contract.register(identity.IDCommitmentBigInt, this.rateLimit, [], {
|
356
|
+
const txRegisterResponse = await this.contract.register(identity.IDCommitmentBigInt, this.rateLimit, [], {
|
357
|
+
gasLimit
|
358
|
+
});
|
357
359
|
const txRegisterReceipt = await txRegisterResponse.wait();
|
358
360
|
if (txRegisterReceipt.status === 0) {
|
359
361
|
throw new Error("Transaction failed on-chain");
|
@@ -415,7 +417,7 @@ class RLNBaseContract {
|
|
415
417
|
async registerWithPermitAndErase(identity, permit, idCommitmentsToErase) {
|
416
418
|
try {
|
417
419
|
log.info(`Registering identity with permit and rate limit: ${this.rateLimit} messages/epoch`);
|
418
|
-
const txRegisterResponse = await this.contract.registerWithPermit(permit.owner, permit.deadline, permit.v, permit.r, permit.s, identity.
|
420
|
+
const txRegisterResponse = await this.contract.registerWithPermit(permit.owner, permit.deadline, permit.v, permit.r, permit.s, BytesUtils.buildBigIntFromUint8ArrayBE(identity.IDCommitment), this.rateLimit, idCommitmentsToErase.map((id) => BigNumber.from(id)));
|
419
421
|
const txRegisterReceipt = await txRegisterResponse.wait();
|
420
422
|
const memberRegistered = txRegisterReceipt.events?.find((event) => event.event === "MembershipRegistered");
|
421
423
|
if (!memberRegistered || !memberRegistered.args) {
|
@@ -1,11 +1,10 @@
|
|
1
|
-
import '../../../interfaces/dist/light_push_v3.js';
|
2
1
|
import '../../../interfaces/dist/protocols.js';
|
3
2
|
import '../../../interfaces/dist/connection_manager.js';
|
4
3
|
import '../../../interfaces/dist/health_indicator.js';
|
5
4
|
import { hexToBytes } from '../../../utils/dist/bytes/index.js';
|
6
5
|
import { Logger } from '../../../utils/dist/logger/index.js';
|
7
6
|
import { MerkleRootTracker } from '../root_tracker.js';
|
8
|
-
import {
|
7
|
+
import { BytesUtils } from '../utils/bytes.js';
|
9
8
|
import { RLNBaseContract } from './rln_base_contract.js';
|
10
9
|
import { BigNumber } from '../../../../node_modules/@ethersproject/bignumber/lib.esm/bignumber.js';
|
11
10
|
|
@@ -84,7 +83,7 @@ class RLNContract extends RLNBaseContract {
|
|
84
83
|
if (typeof index === "number" || typeof index === "string") {
|
85
84
|
index = BigNumber.from(index);
|
86
85
|
}
|
87
|
-
const idCommitment = zeroPadLE(hexToBytes(_idCommitment), 32);
|
86
|
+
const idCommitment = BytesUtils.zeroPadLE(hexToBytes(_idCommitment), 32);
|
88
87
|
rlnInstance.zerokit.insertMember(idCommitment);
|
89
88
|
const numericIndex = index.toNumber();
|
90
89
|
this._members.set(numericIndex, {
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { hmac } from '../../../node_modules/@noble/hashes/esm/hmac.js';
|
2
|
-
import { sha256 } from '../../../node_modules/@noble/hashes/esm/
|
3
|
-
import '../../interfaces/dist/light_push_v3.js';
|
2
|
+
import { sha256 } from '../../../node_modules/@noble/hashes/esm/sha2.js';
|
4
3
|
import '../../interfaces/dist/protocols.js';
|
5
4
|
import '../../interfaces/dist/connection_manager.js';
|
6
5
|
import '../../interfaces/dist/health_indicator.js';
|
@@ -16,12 +15,12 @@ import '../../../node_modules/multiformats/dist/src/bases/base8.js';
|
|
16
15
|
import '../../../node_modules/multiformats/dist/src/bases/identity.js';
|
17
16
|
import '../../../node_modules/multiformats/dist/src/codecs/json.js';
|
18
17
|
import { Logger } from '../../utils/dist/logger/index.js';
|
19
|
-
import { LINEA_CONTRACT } from './contract/constants.js';
|
18
|
+
import { LINEA_CONTRACT, DEFAULT_Q } from './contract/constants.js';
|
20
19
|
import { RLNBaseContract } from './contract/rln_base_contract.js';
|
21
20
|
import { IdentityCredential } from './identity.js';
|
22
21
|
import { Keystore } from './keystore/keystore.js';
|
22
|
+
import { BytesUtils } from './utils/bytes.js';
|
23
23
|
import { extractMetaMaskSigner } from './utils/metamask.js';
|
24
|
-
import { buildBigIntFromUint8Array } from './utils/bytes.js';
|
25
24
|
import './utils/epoch.js';
|
26
25
|
|
27
26
|
const log = new Logger("waku:credentials");
|
@@ -96,7 +95,7 @@ class RLNCredentialsManager {
|
|
96
95
|
}
|
97
96
|
else {
|
98
97
|
log.info("Using local implementation to generate identity");
|
99
|
-
identity = this.generateSeededIdentityCredential(options.signature);
|
98
|
+
identity = await this.generateSeededIdentityCredential(options.signature);
|
100
99
|
}
|
101
100
|
}
|
102
101
|
if (!identity) {
|
@@ -192,24 +191,32 @@ class RLNCredentialsManager {
|
|
192
191
|
* @param seed A string seed to generate the identity from
|
193
192
|
* @returns IdentityCredential
|
194
193
|
*/
|
195
|
-
generateSeededIdentityCredential(seed) {
|
194
|
+
async generateSeededIdentityCredential(seed) {
|
196
195
|
log.info("Generating seeded identity credential");
|
197
196
|
// Convert the seed to bytes
|
198
197
|
const encoder = new TextEncoder();
|
199
198
|
const seedBytes = encoder.encode(seed);
|
200
199
|
// Generate deterministic values using HMAC-SHA256
|
201
200
|
// We use different context strings for each component to ensure they're different
|
202
|
-
const
|
203
|
-
const
|
204
|
-
|
205
|
-
const
|
206
|
-
const
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
201
|
+
const idTrapdoorBE = hmac(sha256, seedBytes, encoder.encode("IDTrapdoor"));
|
202
|
+
const idNullifierBE = hmac(sha256, seedBytes, encoder.encode("IDNullifier"));
|
203
|
+
const combinedBytes = new Uint8Array([...idTrapdoorBE, ...idNullifierBE]);
|
204
|
+
const idSecretHashBE = sha256(combinedBytes);
|
205
|
+
const idCommitmentRawBE = sha256(idSecretHashBE);
|
206
|
+
const idCommitmentBE = this.reduceIdCommitment(idCommitmentRawBE);
|
207
|
+
log.info("Successfully generated identity credential, storing in Big Endian format");
|
208
|
+
return new IdentityCredential(idTrapdoorBE, idNullifierBE, idSecretHashBE, idCommitmentBE);
|
209
|
+
}
|
210
|
+
/**
|
211
|
+
* Helper: take 32-byte BE, reduce mod Q, return 32-byte BE
|
212
|
+
*/
|
213
|
+
reduceIdCommitment(bytesBE, limit = DEFAULT_Q) {
|
214
|
+
const nBE = BytesUtils.buildBigIntFromUint8ArrayBE(bytesBE);
|
215
|
+
if (nBE >= limit) {
|
216
|
+
log.warn(`ID commitment is greater than Q, reducing it by Q: ${nBE} % ${limit}`);
|
217
|
+
return BytesUtils.bigIntToUint8Array32BE(nBE % limit);
|
218
|
+
}
|
219
|
+
return bytesBE;
|
213
220
|
}
|
214
221
|
}
|
215
222
|
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
import './utils/epoch.js';
|
1
|
+
import { BytesUtils } from './utils/bytes.js';
|
3
2
|
|
4
3
|
class IdentityCredential {
|
5
4
|
IDTrapdoor;
|
@@ -7,12 +6,16 @@ class IdentityCredential {
|
|
7
6
|
IDSecretHash;
|
8
7
|
IDCommitment;
|
9
8
|
IDCommitmentBigInt;
|
10
|
-
|
9
|
+
/**
|
10
|
+
* All variables are in little-endian format
|
11
|
+
*/
|
12
|
+
constructor(IDTrapdoor, IDNullifier, IDSecretHash, IDCommitment) {
|
11
13
|
this.IDTrapdoor = IDTrapdoor;
|
12
14
|
this.IDNullifier = IDNullifier;
|
13
15
|
this.IDSecretHash = IDSecretHash;
|
14
16
|
this.IDCommitment = IDCommitment;
|
15
|
-
this.IDCommitmentBigInt =
|
17
|
+
this.IDCommitmentBigInt =
|
18
|
+
BytesUtils.buildBigIntFromUint8ArrayBE(IDCommitment);
|
16
19
|
}
|
17
20
|
static fromBytes(memKeys) {
|
18
21
|
if (memKeys.length < 128) {
|
@@ -22,8 +25,7 @@ class IdentityCredential {
|
|
22
25
|
const idNullifier = memKeys.subarray(32, 64);
|
23
26
|
const idSecretHash = memKeys.subarray(64, 96);
|
24
27
|
const idCommitment = memKeys.subarray(96, 128);
|
25
|
-
|
26
|
-
return new IdentityCredential(idTrapdoor, idNullifier, idSecretHash, idCommitment, idCommitmentBigInt);
|
28
|
+
return new IdentityCredential(idTrapdoor, idNullifier, idSecretHash, idCommitment);
|
27
29
|
}
|
28
30
|
}
|
29
31
|
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import '../../../../node_modules/@chainsafe/bls-keystore/lib/index.js';
|
2
|
-
import '../../../interfaces/dist/light_push_v3.js';
|
3
2
|
import '../../../interfaces/dist/protocols.js';
|
4
3
|
import '../../../interfaces/dist/connection_manager.js';
|
5
4
|
import '../../../interfaces/dist/health_indicator.js';
|
@@ -18,7 +17,7 @@ import { Logger } from '../../../utils/dist/logger/index.js';
|
|
18
17
|
import { sha256 } from '../../../../node_modules/ethereum-cryptography/esm/sha256.js';
|
19
18
|
import { bytesToUtf8 } from '../../../../node_modules/ethereum-cryptography/esm/utils.js';
|
20
19
|
import _ from '../../../../node_modules/lodash/lodash.js';
|
21
|
-
import {
|
20
|
+
import { BytesUtils } from '../utils/bytes.js';
|
22
21
|
import { keccak256Checksum, decryptEipKeystore } from './cipher.js';
|
23
22
|
import { isKeystoreValid, isCredentialValid } from './schema_validator.js';
|
24
23
|
import { __exports as lib } from '../../../../_virtual/index.js';
|
@@ -165,14 +164,24 @@ class Keystore {
|
|
165
164
|
try {
|
166
165
|
const str = bytesToUtf8(bytes);
|
167
166
|
const obj = JSON.parse(str);
|
168
|
-
//
|
167
|
+
// Little Endian
|
168
|
+
const idCommitmentLE = Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idCommitment", []));
|
169
|
+
const idTrapdoorLE = Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idTrapdoor", []));
|
170
|
+
const idNullifierLE = Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idNullifier", []));
|
171
|
+
const idSecretHashLE = Keystore.fromArraylikeToBytes(_.get(obj, "identityCredential.idSecretHash", []));
|
172
|
+
// Big Endian
|
173
|
+
const idCommitmentBE = BytesUtils.switchEndianness(idCommitmentLE);
|
174
|
+
const idTrapdoorBE = BytesUtils.switchEndianness(idTrapdoorLE);
|
175
|
+
const idNullifierBE = BytesUtils.switchEndianness(idNullifierLE);
|
176
|
+
const idSecretHashBE = BytesUtils.switchEndianness(idSecretHashLE);
|
177
|
+
const idCommitmentBigInt = BytesUtils.buildBigIntFromUint8ArrayBE(idCommitmentBE);
|
169
178
|
return {
|
170
179
|
identity: {
|
171
|
-
IDCommitment:
|
172
|
-
IDTrapdoor:
|
173
|
-
IDNullifier:
|
174
|
-
|
175
|
-
|
180
|
+
IDCommitment: idCommitmentBE,
|
181
|
+
IDTrapdoor: idTrapdoorBE,
|
182
|
+
IDNullifier: idNullifierBE,
|
183
|
+
IDSecretHash: idSecretHashBE,
|
184
|
+
IDCommitmentBigInt: idCommitmentBigInt
|
176
185
|
},
|
177
186
|
membership: {
|
178
187
|
treeIndex: _.get(obj, "treeIndex"),
|
@@ -208,14 +217,15 @@ class Keystore {
|
|
208
217
|
}
|
209
218
|
// follows nwaku implementation
|
210
219
|
// https://github.com/waku-org/nwaku/blob/f05528d4be3d3c876a8b07f9bb7dfaae8aa8ec6e/waku/waku_keystore/protocol_types.nim#L98
|
220
|
+
// IdentityCredential is stored in Big Endian format => switch to Little Endian
|
211
221
|
static fromIdentityToBytes(options) {
|
212
222
|
return utf8ToBytes(JSON.stringify({
|
213
223
|
treeIndex: options.membership.treeIndex,
|
214
224
|
identityCredential: {
|
215
|
-
idCommitment: Array.from(options.identity.IDCommitment),
|
216
|
-
idNullifier: Array.from(options.identity.IDNullifier),
|
217
|
-
idSecretHash: Array.from(options.identity.IDSecretHash),
|
218
|
-
idTrapdoor: Array.from(options.identity.IDTrapdoor)
|
225
|
+
idCommitment: Array.from(BytesUtils.switchEndianness(options.identity.IDCommitment)),
|
226
|
+
idNullifier: Array.from(BytesUtils.switchEndianness(options.identity.IDNullifier)),
|
227
|
+
idSecretHash: Array.from(BytesUtils.switchEndianness(options.identity.IDSecretHash)),
|
228
|
+
idTrapdoor: Array.from(BytesUtils.switchEndianness(options.identity.IDTrapdoor))
|
219
229
|
},
|
220
230
|
membershipContract: {
|
221
231
|
chainId: options.membership.chainId,
|
@@ -1,10 +1,8 @@
|
|
1
1
|
import { Version } from '../../core/dist/lib/message/version_0.js';
|
2
2
|
import '../../core/dist/lib/filter/filter.js';
|
3
3
|
import '../../core/dist/lib/light_push/light_push.js';
|
4
|
-
import '../../core/dist/lib/light_push/light_push_v3.js';
|
5
4
|
import '../../core/dist/lib/store/store.js';
|
6
5
|
import '../../core/dist/lib/connection_manager/connection_manager.js';
|
7
|
-
import '../../interfaces/dist/light_push_v3.js';
|
8
6
|
import '../../interfaces/dist/protocols.js';
|
9
7
|
import '../../interfaces/dist/connection_manager.js';
|
10
8
|
import '../../interfaces/dist/health_indicator.js';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { BytesUtils } from './utils/bytes.js';
|
2
2
|
import { poseidonHash } from './utils/hash.js';
|
3
3
|
import './utils/epoch.js';
|
4
4
|
|
@@ -48,7 +48,7 @@ class Proof {
|
|
48
48
|
}
|
49
49
|
}
|
50
50
|
function proofToBytes(p) {
|
51
|
-
return concatenate(p.proof, p.merkleRoot, p.epoch, p.shareX, p.shareY, p.nullifier, p.rlnIdentifier);
|
51
|
+
return BytesUtils.concatenate(p.proof, p.merkleRoot, p.epoch, p.shareX, p.shareY, p.nullifier, p.rlnIdentifier);
|
52
52
|
}
|
53
53
|
|
54
54
|
export { Proof, proofToBytes };
|
@@ -1,10 +1,8 @@
|
|
1
1
|
import { createEncoder, createDecoder } from '../../core/dist/lib/message/version_0.js';
|
2
2
|
import '../../core/dist/lib/filter/filter.js';
|
3
3
|
import '../../core/dist/lib/light_push/light_push.js';
|
4
|
-
import '../../core/dist/lib/light_push/light_push_v3.js';
|
5
4
|
import '../../core/dist/lib/store/store.js';
|
6
5
|
import '../../core/dist/lib/connection_manager/connection_manager.js';
|
7
|
-
import '../../interfaces/dist/light_push_v3.js';
|
8
6
|
import '../../interfaces/dist/protocols.js';
|
9
7
|
import '../../interfaces/dist/connection_manager.js';
|
10
8
|
import '../../interfaces/dist/health_indicator.js';
|