@waku/rln 0.1.6-10590da.0 → 0.1.6-383e0b2.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/_virtual/utils.js +2 -2
- package/bundle/_virtual/utils2.js +2 -2
- package/bundle/index.js +1 -2
- package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +1 -1
- package/bundle/node_modules/{js-sha3 → @ethersproject/keccak256/node_modules/js-sha3}/src/sha3.js +2 -2
- package/bundle/node_modules/@noble/hashes/esm/_assert.js +32 -6
- package/bundle/node_modules/@noble/hashes/esm/_md.js +11 -22
- package/bundle/node_modules/@noble/hashes/esm/_u64.js +3 -4
- package/bundle/node_modules/@noble/hashes/esm/sha256.js +102 -5
- package/bundle/node_modules/@noble/hashes/esm/sha3.js +24 -30
- package/bundle/node_modules/@noble/hashes/esm/utils.js +18 -69
- package/bundle/node_modules/bn.js/lib/bn.js +0 -1
- package/bundle/node_modules/ethereum-cryptography/esm/sha256.js +1 -1
- package/bundle/packages/rln/dist/contract/constants.js +0 -1
- package/bundle/packages/rln/dist/contract/rln_base_contract.js +71 -127
- package/bundle/packages/rln/dist/credentials_manager.js +4 -9
- package/bundle/packages/rln/dist/identity.js +1 -1
- package/bundle/packages/rln/dist/keystore/cipher.js +3 -3
- package/bundle/packages/rln/dist/keystore/keystore.js +1 -1
- package/bundle/packages/rln/dist/utils/bytes.js +2 -6
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/checksum.js +3 -3
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/cipher.js +4 -4
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/class.js +7 -7
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/functional.js +7 -7
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/index.js +6 -6
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/kdf.js +5 -5
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/password.js +1 -1
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/schema-validation-generated.js +1 -1
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/schema-validation.js +2 -2
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/types.js +1 -1
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/aes.js +3 -3
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/pbkdf2.js +7 -7
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +3 -3
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/scrypt.js +3 -3
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/sha256.js +3 -3
- package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +7 -7
- package/bundle/{node_modules/@chainsafe/bls-keystore → packages/rln}/node_modules/@noble/hashes/_assert.js +1 -1
- package/bundle/{node_modules/@chainsafe/bls-keystore → packages/rln}/node_modules/@noble/hashes/_sha2.js +3 -3
- package/bundle/{node_modules/@chainsafe/bls-keystore → packages/rln}/node_modules/@noble/hashes/_u64.js +1 -1
- package/bundle/{node_modules/@chainsafe/bls-keystore → packages/rln}/node_modules/@noble/hashes/cryptoBrowser.js +1 -1
- package/bundle/packages/rln/node_modules/@noble/hashes/esm/_assert.js +43 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/esm/_sha2.js +116 -0
- package/bundle/{node_modules → packages/rln/node_modules}/@noble/hashes/esm/hmac.js +10 -19
- package/bundle/{node_modules/@noble/hashes/esm/sha2.js → packages/rln/node_modules/@noble/hashes/esm/sha256.js} +50 -36
- package/bundle/packages/rln/node_modules/@noble/hashes/esm/utils.js +43 -0
- package/bundle/{node_modules/@chainsafe/bls-keystore → packages/rln}/node_modules/@noble/hashes/hmac.js +3 -3
- package/bundle/{node_modules/@chainsafe/bls-keystore → packages/rln}/node_modules/@noble/hashes/pbkdf2.js +4 -4
- package/bundle/{node_modules/@chainsafe/bls-keystore → packages/rln}/node_modules/@noble/hashes/scrypt.js +5 -5
- package/bundle/{node_modules/@chainsafe/bls-keystore → packages/rln}/node_modules/@noble/hashes/sha256.js +3 -3
- package/bundle/{node_modules/@chainsafe/bls-keystore → packages/rln}/node_modules/@noble/hashes/sha512.js +4 -4
- package/bundle/{node_modules/@chainsafe/bls-keystore → packages/rln}/node_modules/@noble/hashes/utils.js +2 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/contract/index.d.ts +0 -1
- package/dist/contract/index.js +0 -1
- package/dist/contract/index.js.map +1 -1
- package/dist/contract/rln_base_contract.d.ts +22 -32
- package/dist/contract/rln_base_contract.js +71 -127
- package/dist/contract/rln_base_contract.js.map +1 -1
- package/dist/contract/types.d.ts +0 -5
- package/dist/contract/types.js.map +1 -1
- package/dist/credentials_manager.js +2 -7
- package/dist/credentials_manager.js.map +1 -1
- package/dist/identity.js +1 -1
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/keystore/types.d.ts +2 -2
- package/dist/utils/bytes.js +2 -6
- package/dist/utils/bytes.js.map +1 -1
- package/package.json +1 -1
- package/src/contract/index.ts +0 -1
- package/src/contract/rln_base_contract.ts +102 -166
- package/src/contract/types.ts +0 -5
- package/src/credentials_manager.ts +2 -9
- package/src/identity.ts +1 -1
- package/src/index.ts +1 -3
- package/src/keystore/keystore.ts +2 -4
- package/src/keystore/types.ts +2 -2
- package/src/utils/bytes.ts +2 -6
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/index.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/md5.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/nil.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/parse.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/regex.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/rng.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/sha1.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/stringify.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v1.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v3.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v35.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v4.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v5.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/validate.js +0 -0
- /package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/version.js +0 -0
@@ -24,32 +24,15 @@ class RLNBaseContract {
|
|
24
24
|
contract;
|
25
25
|
deployBlock;
|
26
26
|
rateLimit;
|
27
|
-
minRateLimit;
|
28
|
-
maxRateLimit;
|
29
27
|
_members = new Map();
|
30
28
|
_membersFilter;
|
31
29
|
_membershipErasedFilter;
|
32
30
|
_membersExpiredFilter;
|
33
31
|
/**
|
34
|
-
*
|
32
|
+
* Constructor for RLNBaseContract.
|
33
|
+
* Allows injecting a mocked contract for testing purposes.
|
35
34
|
*/
|
36
35
|
constructor(options) {
|
37
|
-
const { address, signer, rateLimit = DEFAULT_RATE_LIMIT, contract } = options;
|
38
|
-
log.info("Initializing RLNBaseContract", { address, rateLimit });
|
39
|
-
this.contract = contract || new Contract(address, RLN_ABI, signer);
|
40
|
-
this.rateLimit = rateLimit;
|
41
|
-
try {
|
42
|
-
log.info("Setting up event filters");
|
43
|
-
// Initialize event filters
|
44
|
-
this._membersFilter = this.contract.filters.MembershipRegistered();
|
45
|
-
this._membershipErasedFilter = this.contract.filters.MembershipErased();
|
46
|
-
this._membersExpiredFilter = this.contract.filters.MembershipExpired();
|
47
|
-
log.info("Event filters initialized successfully");
|
48
|
-
}
|
49
|
-
catch (error) {
|
50
|
-
log.error("Failed to initialize event filters", { error });
|
51
|
-
throw new Error("Failed to initialize event filters: " + error.message);
|
52
|
-
}
|
53
36
|
// Initialize members and subscriptions
|
54
37
|
this.fetchMembers()
|
55
38
|
.then(() => {
|
@@ -58,20 +41,14 @@ class RLNBaseContract {
|
|
58
41
|
.catch((error) => {
|
59
42
|
log.error("Failed to initialize members", { error });
|
60
43
|
});
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
instance.contract.maxMembershipRateLimit()
|
70
|
-
]);
|
71
|
-
instance.minRateLimit = BigNumber.from(min).toNumber();
|
72
|
-
instance.maxRateLimit = BigNumber.from(max).toNumber();
|
73
|
-
instance.validateRateLimit(instance.rateLimit);
|
74
|
-
return instance;
|
44
|
+
const { address, signer, rateLimit = DEFAULT_RATE_LIMIT, contract } = options;
|
45
|
+
this.validateRateLimit(rateLimit);
|
46
|
+
this.contract = contract || new Contract(address, RLN_ABI, signer);
|
47
|
+
this.rateLimit = rateLimit;
|
48
|
+
// Initialize event filters
|
49
|
+
this._membersFilter = this.contract.filters.MembershipRegistered();
|
50
|
+
this._membershipErasedFilter = this.contract.filters.MembershipErased();
|
51
|
+
this._membersExpiredFilter = this.contract.filters.MembershipExpired();
|
75
52
|
}
|
76
53
|
/**
|
77
54
|
* Gets the current rate limit for this contract instance
|
@@ -92,20 +69,20 @@ class RLNBaseContract {
|
|
92
69
|
return this.contract.provider;
|
93
70
|
}
|
94
71
|
/**
|
95
|
-
* Gets the minimum allowed rate limit
|
72
|
+
* Gets the minimum allowed rate limit from the contract
|
73
|
+
* @returns Promise<number> The minimum rate limit in messages per epoch
|
96
74
|
*/
|
97
|
-
getMinRateLimit() {
|
98
|
-
|
99
|
-
|
100
|
-
return this.minRateLimit;
|
75
|
+
async getMinRateLimit() {
|
76
|
+
const minRate = await this.contract.minMembershipRateLimit();
|
77
|
+
return BigNumber.from(minRate).toNumber();
|
101
78
|
}
|
102
79
|
/**
|
103
|
-
* Gets the maximum allowed rate limit
|
80
|
+
* Gets the maximum allowed rate limit from the contract
|
81
|
+
* @returns Promise<number> The maximum rate limit in messages per epoch
|
104
82
|
*/
|
105
|
-
getMaxRateLimit() {
|
106
|
-
|
107
|
-
|
108
|
-
return this.maxRateLimit;
|
83
|
+
async getMaxRateLimit() {
|
84
|
+
const maxRate = await this.contract.maxMembershipRateLimit();
|
85
|
+
return BigNumber.from(maxRate).toNumber();
|
109
86
|
}
|
110
87
|
/**
|
111
88
|
* Gets the maximum total rate limit across all memberships
|
@@ -138,7 +115,7 @@ class RLNBaseContract {
|
|
138
115
|
* Updates the rate limit for future registrations
|
139
116
|
* @param newRateLimit The new rate limit to use
|
140
117
|
*/
|
141
|
-
setRateLimit(newRateLimit) {
|
118
|
+
async setRateLimit(newRateLimit) {
|
142
119
|
this.validateRateLimit(newRateLimit);
|
143
120
|
this.rateLimit = newRateLimit;
|
144
121
|
}
|
@@ -270,67 +247,75 @@ class RLNBaseContract {
|
|
270
247
|
this.processEvents([event]);
|
271
248
|
});
|
272
249
|
}
|
273
|
-
|
250
|
+
/**
|
251
|
+
* Helper method to get remaining messages in current epoch
|
252
|
+
* @param membershipId The ID of the membership to check
|
253
|
+
* @returns number of remaining messages allowed in current epoch
|
254
|
+
*/
|
255
|
+
async getRemainingMessages(membershipId) {
|
256
|
+
try {
|
257
|
+
const [startTime, , rateLimit] = await this.contract.getMembershipInfo(membershipId);
|
258
|
+
// Calculate current epoch
|
259
|
+
const currentTime = Math.floor(Date.now() / 1000);
|
260
|
+
const epochsPassed = Math.floor((currentTime - startTime) / RATE_LIMIT_PARAMS.EPOCH_LENGTH);
|
261
|
+
const currentEpochStart = startTime + epochsPassed * RATE_LIMIT_PARAMS.EPOCH_LENGTH;
|
262
|
+
// Get message count in current epoch using contract's function
|
263
|
+
const messageCount = await this.contract.getMessageCount(membershipId, currentEpochStart);
|
264
|
+
return Math.max(0, BigNumber.from(rateLimit)
|
265
|
+
.sub(BigNumber.from(messageCount))
|
266
|
+
.toNumber());
|
267
|
+
}
|
268
|
+
catch (error) {
|
269
|
+
log.error(`Error getting remaining messages: ${error.message}`);
|
270
|
+
return 0; // Fail safe: assume no messages remaining on error
|
271
|
+
}
|
272
|
+
}
|
273
|
+
async getMembershipInfo(idCommitment) {
|
274
274
|
try {
|
275
|
-
const
|
275
|
+
const [startBlock, endBlock, rateLimit] = await this.contract.getMembershipInfo(idCommitment);
|
276
276
|
const currentBlock = await this.contract.provider.getBlockNumber();
|
277
|
-
const [depositAmount, activeDuration, gracePeriodStartTimestamp, gracePeriodDuration, rateLimit, index, holder, token] = membershipData;
|
278
|
-
const gracePeriodEnd = gracePeriodStartTimestamp.add(gracePeriodDuration);
|
279
277
|
let state;
|
280
|
-
if (currentBlock <
|
278
|
+
if (currentBlock < startBlock) {
|
281
279
|
state = MembershipState.Active;
|
282
280
|
}
|
283
|
-
else if (currentBlock <
|
281
|
+
else if (currentBlock < endBlock) {
|
284
282
|
state = MembershipState.GracePeriod;
|
285
283
|
}
|
286
284
|
else {
|
287
285
|
state = MembershipState.Expired;
|
288
286
|
}
|
287
|
+
const index = await this.getMemberIndex(idCommitment);
|
288
|
+
if (!index)
|
289
|
+
return undefined;
|
289
290
|
return {
|
290
291
|
index,
|
291
|
-
idCommitment
|
292
|
-
rateLimit:
|
293
|
-
startBlock:
|
294
|
-
endBlock:
|
295
|
-
state
|
296
|
-
depositAmount,
|
297
|
-
activeDuration,
|
298
|
-
gracePeriodDuration,
|
299
|
-
holder,
|
300
|
-
token
|
292
|
+
idCommitment,
|
293
|
+
rateLimit: rateLimit.toNumber(),
|
294
|
+
startBlock: startBlock.toNumber(),
|
295
|
+
endBlock: endBlock.toNumber(),
|
296
|
+
state
|
301
297
|
};
|
302
298
|
}
|
303
299
|
catch (error) {
|
304
|
-
log.error("Error in getMembershipInfo:", error);
|
305
300
|
return undefined;
|
306
301
|
}
|
307
302
|
}
|
308
|
-
async extendMembership(
|
309
|
-
|
310
|
-
await tx.wait();
|
311
|
-
return tx;
|
303
|
+
async extendMembership(idCommitment) {
|
304
|
+
return this.contract.extendMemberships([idCommitment]);
|
312
305
|
}
|
313
|
-
async eraseMembership(
|
314
|
-
|
315
|
-
!(await this.isInGracePeriod(idCommitmentBigInt))) {
|
316
|
-
throw new Error("Membership is not expired or in grace period");
|
317
|
-
}
|
318
|
-
const estimatedGas = await this.contract.estimateGas["eraseMemberships(uint256[],bool)"]([idCommitmentBigInt], eraseFromMembershipSet);
|
319
|
-
const gasLimit = estimatedGas.add(10000);
|
320
|
-
const tx = await this.contract["eraseMemberships(uint256[],bool)"]([idCommitmentBigInt], eraseFromMembershipSet, { gasLimit });
|
321
|
-
await tx.wait();
|
322
|
-
return tx;
|
306
|
+
async eraseMembership(idCommitment, eraseFromMembershipSet = true) {
|
307
|
+
return this.contract.eraseMemberships([idCommitment], eraseFromMembershipSet);
|
323
308
|
}
|
324
|
-
async registerMembership(
|
309
|
+
async registerMembership(idCommitment, rateLimit = DEFAULT_RATE_LIMIT) {
|
325
310
|
if (rateLimit < RATE_LIMIT_PARAMS.MIN_RATE ||
|
326
311
|
rateLimit > RATE_LIMIT_PARAMS.MAX_RATE) {
|
327
312
|
throw new Error(`Rate limit must be between ${RATE_LIMIT_PARAMS.MIN_RATE} and ${RATE_LIMIT_PARAMS.MAX_RATE}`);
|
328
313
|
}
|
329
|
-
return this.contract.register(
|
314
|
+
return this.contract.register(idCommitment, rateLimit, []);
|
330
315
|
}
|
331
|
-
async withdraw(token,
|
316
|
+
async withdraw(token, holder) {
|
332
317
|
try {
|
333
|
-
const tx = await this.contract.withdraw(token, from);
|
318
|
+
const tx = await this.contract.withdraw(token, { from: holder });
|
334
319
|
await tx.wait();
|
335
320
|
}
|
336
321
|
catch (error) {
|
@@ -341,7 +326,7 @@ class RLNBaseContract {
|
|
341
326
|
try {
|
342
327
|
log.info(`Registering identity with rate limit: ${this.rateLimit} messages/epoch`);
|
343
328
|
// Check if the ID commitment is already registered
|
344
|
-
const existingIndex = await this.getMemberIndex(identity.IDCommitmentBigInt);
|
329
|
+
const existingIndex = await this.getMemberIndex(identity.IDCommitmentBigInt.toString());
|
345
330
|
if (existingIndex) {
|
346
331
|
throw new Error(`ID commitment is already registered with index ${existingIndex}`);
|
347
332
|
}
|
@@ -447,15 +432,13 @@ class RLNBaseContract {
|
|
447
432
|
}
|
448
433
|
}
|
449
434
|
/**
|
450
|
-
* Validates that the rate limit is within the allowed range
|
435
|
+
* Validates that the rate limit is within the allowed range
|
451
436
|
* @throws Error if the rate limit is outside the allowed range
|
452
437
|
*/
|
453
438
|
validateRateLimit(rateLimit) {
|
454
|
-
if (
|
455
|
-
|
456
|
-
|
457
|
-
if (rateLimit < this.minRateLimit || rateLimit > this.maxRateLimit) {
|
458
|
-
throw new Error(`Rate limit must be between ${this.minRateLimit} and ${this.maxRateLimit} messages per epoch`);
|
439
|
+
if (rateLimit < RATE_LIMIT_PARAMS.MIN_RATE ||
|
440
|
+
rateLimit > RATE_LIMIT_PARAMS.MAX_RATE) {
|
441
|
+
throw new Error(`Rate limit must be between ${RATE_LIMIT_PARAMS.MIN_RATE} and ${RATE_LIMIT_PARAMS.MAX_RATE} messages per epoch`);
|
459
442
|
}
|
460
443
|
}
|
461
444
|
get membersFilter() {
|
@@ -476,9 +459,9 @@ class RLNBaseContract {
|
|
476
459
|
}
|
477
460
|
return this._membersExpiredFilter;
|
478
461
|
}
|
479
|
-
async getMemberIndex(
|
462
|
+
async getMemberIndex(idCommitment) {
|
480
463
|
try {
|
481
|
-
const events = await this.contract.queryFilter(this.contract.filters.MembershipRegistered(
|
464
|
+
const events = await this.contract.queryFilter(this.contract.filters.MembershipRegistered(idCommitment));
|
482
465
|
if (events.length === 0)
|
483
466
|
return undefined;
|
484
467
|
// Get the most recent registration event
|
@@ -489,45 +472,6 @@ class RLNBaseContract {
|
|
489
472
|
return undefined;
|
490
473
|
}
|
491
474
|
}
|
492
|
-
async getMembershipStatus(idCommitment) {
|
493
|
-
const [isExpired, isInGrace] = await Promise.all([
|
494
|
-
this.contract.isExpired(idCommitment),
|
495
|
-
this.contract.isInGracePeriod(idCommitment)
|
496
|
-
]);
|
497
|
-
if (isExpired)
|
498
|
-
return "expired";
|
499
|
-
if (isInGrace)
|
500
|
-
return "grace";
|
501
|
-
return "active";
|
502
|
-
}
|
503
|
-
/**
|
504
|
-
* Checks if a membership is expired for the given idCommitment
|
505
|
-
* @param idCommitmentBigInt The idCommitment as bigint
|
506
|
-
* @returns Promise<boolean> True if expired, false otherwise
|
507
|
-
*/
|
508
|
-
async isExpired(idCommitmentBigInt) {
|
509
|
-
try {
|
510
|
-
return await this.contract.isExpired(idCommitmentBigInt);
|
511
|
-
}
|
512
|
-
catch (error) {
|
513
|
-
log.error("Error in isExpired:", error);
|
514
|
-
return false;
|
515
|
-
}
|
516
|
-
}
|
517
|
-
/**
|
518
|
-
* Checks if a membership is in grace period for the given idCommitment
|
519
|
-
* @param idCommitmentBigInt The idCommitment as bigint
|
520
|
-
* @returns Promise<boolean> True if in grace period, false otherwise
|
521
|
-
*/
|
522
|
-
async isInGracePeriod(idCommitmentBigInt) {
|
523
|
-
try {
|
524
|
-
return await this.contract.isInGracePeriod(idCommitmentBigInt);
|
525
|
-
}
|
526
|
-
catch (error) {
|
527
|
-
log.error("Error in isInGracePeriod:", error);
|
528
|
-
return false;
|
529
|
-
}
|
530
|
-
}
|
531
475
|
}
|
532
476
|
|
533
477
|
export { RLNBaseContract };
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { hmac } from '
|
2
|
-
import { sha256 } from '
|
1
|
+
import { hmac } from '../node_modules/@noble/hashes/esm/hmac.js';
|
2
|
+
import { sha256 } from '../node_modules/@noble/hashes/esm/sha256.js';
|
3
3
|
import '../../interfaces/dist/protocols.js';
|
4
4
|
import '../../interfaces/dist/connection_manager.js';
|
5
5
|
import '../../interfaces/dist/health_indicator.js';
|
@@ -64,7 +64,7 @@ class RLNCredentialsManager {
|
|
64
64
|
}
|
65
65
|
this.credentials = credentials;
|
66
66
|
this.signer = signer;
|
67
|
-
this.contract =
|
67
|
+
this.contract = new RLNBaseContract({
|
68
68
|
address: address,
|
69
69
|
signer: signer,
|
70
70
|
rateLimit: rateLimit ?? this.zerokit?.rateLimit
|
@@ -206,12 +206,7 @@ class RLNCredentialsManager {
|
|
206
206
|
// Generate IDCommitment as a hash of IDSecretHash
|
207
207
|
const idCommitment = sha256(idSecretHash);
|
208
208
|
// Convert IDCommitment to BigInt
|
209
|
-
|
210
|
-
const Q = BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
|
211
|
-
if (idCommitmentBigInt >= Q) {
|
212
|
-
log.warn("IDCommitment is greater than Q, truncating");
|
213
|
-
idCommitmentBigInt = idCommitmentBigInt % Q;
|
214
|
-
}
|
209
|
+
const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment);
|
215
210
|
log.info("Successfully generated identity credential");
|
216
211
|
return new IdentityCredential(idTrapdoor, idNullifier, idSecretHash, idCommitment, idCommitmentBigInt);
|
217
212
|
}
|
@@ -22,7 +22,7 @@ class IdentityCredential {
|
|
22
22
|
const idNullifier = memKeys.subarray(32, 64);
|
23
23
|
const idSecretHash = memKeys.subarray(64, 96);
|
24
24
|
const idCommitment = memKeys.subarray(96, 128);
|
25
|
-
const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment);
|
25
|
+
const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitment, 32);
|
26
26
|
return new IdentityCredential(idTrapdoor, idNullifier, idSecretHash, idCommitment, idCommitmentBigInt);
|
27
27
|
}
|
28
28
|
}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { cipherDecrypt as cipherDecrypt_1 } from '
|
2
|
-
import { kdf as kdf_2 } from '
|
3
|
-
import { normalizePassword as normalizePassword_1 } from '
|
1
|
+
import { cipherDecrypt as cipherDecrypt_1 } from '../../node_modules/@chainsafe/bls-keystore/lib/cipher.js';
|
2
|
+
import { kdf as kdf_2 } from '../../node_modules/@chainsafe/bls-keystore/lib/kdf.js';
|
3
|
+
import { normalizePassword as normalizePassword_1 } from '../../node_modules/@chainsafe/bls-keystore/lib/password.js';
|
4
4
|
import { keccak256 } from '../../../../node_modules/ethereum-cryptography/esm/keccak.js';
|
5
5
|
import { hexToBytes } from '../../../../node_modules/ethereum-cryptography/esm/utils.js';
|
6
6
|
import { concatBytes, bytesToHex } from '../../../../node_modules/@noble/hashes/esm/utils.js';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import '
|
1
|
+
import '../../node_modules/@chainsafe/bls-keystore/lib/index.js';
|
2
2
|
import '../../../interfaces/dist/protocols.js';
|
3
3
|
import '../../../interfaces/dist/connection_manager.js';
|
4
4
|
import '../../../interfaces/dist/health_indicator.js';
|
@@ -45,12 +45,8 @@ function writeUIntLE(buf, value, offset, byteLength, noAssert) {
|
|
45
45
|
* @returns BigInt
|
46
46
|
*/
|
47
47
|
function buildBigIntFromUint8Array(array, byteOffset = 0) {
|
48
|
-
|
49
|
-
|
50
|
-
for (let i = byteOffset; i < array.length; i++) {
|
51
|
-
hex += array[i].toString(16).padStart(2, "0");
|
52
|
-
}
|
53
|
-
return BigInt("0x" + hex);
|
48
|
+
const dataView = new DataView(array.buffer);
|
49
|
+
return dataView.getBigUint64(byteOffset, true);
|
54
50
|
}
|
55
51
|
/**
|
56
52
|
* Fills with zeros to set length
|
package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/checksum.js
RENAMED
@@ -1,8 +1,8 @@
|
|
1
|
-
import { commonjsGlobal } from '
|
2
|
-
import { __exports as checksum$1 } from '
|
1
|
+
import { commonjsGlobal } from '../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { __exports as checksum$1 } from '../../../../../../_virtual/checksum.js';
|
3
3
|
import '../node_modules/ethereum-cryptography/sha256.js';
|
4
4
|
import { u as utilsExports } from '../node_modules/ethereum-cryptography/utils.js';
|
5
|
-
import { __exports as sha256 } from '
|
5
|
+
import { __exports as sha256 } from '../../../../../../_virtual/sha256.js';
|
6
6
|
|
7
7
|
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
8
8
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/cipher.js
RENAMED
@@ -1,10 +1,10 @@
|
|
1
|
-
import { commonjsGlobal } from '
|
2
|
-
import { __exports as cipher } from '
|
1
|
+
import { commonjsGlobal } from '../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { __exports as cipher } from '../../../../../../_virtual/cipher.js';
|
3
3
|
import '../node_modules/ethereum-cryptography/random.js';
|
4
4
|
import '../node_modules/ethereum-cryptography/aes.js';
|
5
5
|
import { u as utilsExports } from '../node_modules/ethereum-cryptography/utils.js';
|
6
|
-
import { __exports as random } from '
|
7
|
-
import { __exports as aes } from '
|
6
|
+
import { __exports as random } from '../../../../../../_virtual/random.js';
|
7
|
+
import { __exports as aes } from '../../../../../../_virtual/aes.js';
|
8
8
|
|
9
9
|
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
10
10
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/class.js
RENAMED
@@ -1,15 +1,15 @@
|
|
1
|
-
import { commonjsGlobal } from '
|
2
|
-
import { __exports as _class } from '
|
1
|
+
import { commonjsGlobal } from '../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { __exports as _class } from '../../../../../../_virtual/class.js';
|
3
3
|
import './kdf.js';
|
4
4
|
import './checksum.js';
|
5
5
|
import './cipher.js';
|
6
6
|
import './functional.js';
|
7
7
|
import './schema-validation.js';
|
8
|
-
import { __exports as kdf } from '
|
9
|
-
import { __exports as checksum } from '
|
10
|
-
import { __exports as cipher } from '
|
11
|
-
import { __exports as functional } from '
|
12
|
-
import { __exports as schemaValidation } from '
|
8
|
+
import { __exports as kdf } from '../../../../../../_virtual/kdf.js';
|
9
|
+
import { __exports as checksum } from '../../../../../../_virtual/checksum.js';
|
10
|
+
import { __exports as cipher } from '../../../../../../_virtual/cipher.js';
|
11
|
+
import { __exports as functional } from '../../../../../../_virtual/functional.js';
|
12
|
+
import { __exports as schemaValidation } from '../../../../../../_virtual/schema-validation.js';
|
13
13
|
|
14
14
|
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
15
15
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/functional.js
RENAMED
@@ -1,15 +1,15 @@
|
|
1
|
-
import { commonjsGlobal } from '
|
2
|
-
import { __exports as functional } from '
|
3
|
-
import require$$0 from '
|
1
|
+
import { commonjsGlobal } from '../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { __exports as functional } from '../../../../../../_virtual/functional.js';
|
3
|
+
import require$$0 from '../../../../../../_virtual/index2.js';
|
4
4
|
import './kdf.js';
|
5
5
|
import './checksum.js';
|
6
6
|
import './cipher.js';
|
7
7
|
import './password.js';
|
8
8
|
import { u as utilsExports } from '../node_modules/ethereum-cryptography/utils.js';
|
9
|
-
import { __exports as kdf } from '
|
10
|
-
import { __exports as checksum } from '
|
11
|
-
import { __exports as cipher } from '
|
12
|
-
import { __exports as password } from '
|
9
|
+
import { __exports as kdf } from '../../../../../../_virtual/kdf.js';
|
10
|
+
import { __exports as checksum } from '../../../../../../_virtual/checksum.js';
|
11
|
+
import { __exports as cipher } from '../../../../../../_virtual/cipher.js';
|
12
|
+
import { __exports as password } from '../../../../../../_virtual/password.js';
|
13
13
|
|
14
14
|
(function (exports) {
|
15
15
|
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/index.js
RENAMED
@@ -1,13 +1,13 @@
|
|
1
|
-
import { commonjsGlobal } from '
|
2
|
-
import { __exports as lib } from '
|
1
|
+
import { commonjsGlobal } from '../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { __exports as lib } from '../../../../../../_virtual/index.js';
|
3
3
|
import './types.js';
|
4
4
|
import './functional.js';
|
5
5
|
import './class.js';
|
6
6
|
import './schema-validation.js';
|
7
|
-
import { __exports as types } from '
|
8
|
-
import { __exports as functional } from '
|
9
|
-
import { __exports as _class } from '
|
10
|
-
import { __exports as schemaValidation } from '
|
7
|
+
import { __exports as types } from '../../../../../../_virtual/types.js';
|
8
|
+
import { __exports as functional } from '../../../../../../_virtual/functional.js';
|
9
|
+
import { __exports as _class } from '../../../../../../_virtual/class.js';
|
10
|
+
import { __exports as schemaValidation } from '../../../../../../_virtual/schema-validation.js';
|
11
11
|
|
12
12
|
(function (exports) {
|
13
13
|
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/kdf.js
RENAMED
@@ -1,12 +1,12 @@
|
|
1
|
-
import { commonjsGlobal } from '
|
2
|
-
import { __exports as kdf$1 } from '
|
1
|
+
import { commonjsGlobal } from '../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { __exports as kdf$1 } from '../../../../../../_virtual/kdf.js';
|
3
3
|
import '../node_modules/ethereum-cryptography/random.js';
|
4
4
|
import '../node_modules/ethereum-cryptography/pbkdf2.js';
|
5
5
|
import '../node_modules/ethereum-cryptography/scrypt.js';
|
6
6
|
import { u as utilsExports } from '../node_modules/ethereum-cryptography/utils.js';
|
7
|
-
import { __exports as random } from '
|
8
|
-
import { __exports as pbkdf2 } from '
|
9
|
-
import { __exports as scrypt } from '
|
7
|
+
import { __exports as random } from '../../../../../../_virtual/random.js';
|
8
|
+
import { __exports as pbkdf2 } from '../../../../../../_virtual/pbkdf2.js';
|
9
|
+
import { __exports as scrypt } from '../../../../../../_virtual/scrypt.js';
|
10
10
|
|
11
11
|
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
12
12
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
package/bundle/{node_modules → packages/rln/node_modules}/@chainsafe/bls-keystore/lib/password.js
RENAMED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { __exports as password } from '
|
1
|
+
import { __exports as password } from '../../../../../../_virtual/password.js';
|
2
2
|
import { u as utilsExports } from '../node_modules/ethereum-cryptography/utils.js';
|
3
3
|
|
4
4
|
Object.defineProperty(password, "__esModule", { value: true });
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { __exports as schemaValidationGenerated } from '
|
1
|
+
import { __exports as schemaValidationGenerated } from '../../../../../../_virtual/schema-validation-generated.js';
|
2
2
|
|
3
3
|
Object.defineProperty(schemaValidationGenerated, "__esModule", { value: true });
|
4
4
|
schemaValidationGenerated.Keystore = void 0;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { __exports as schemaValidation } from '
|
1
|
+
import { __exports as schemaValidation } from '../../../../../../_virtual/schema-validation.js';
|
2
2
|
import './schema-validation-generated.js';
|
3
|
-
import { __exports as schemaValidationGenerated } from '
|
3
|
+
import { __exports as schemaValidationGenerated } from '../../../../../../_virtual/schema-validation-generated.js';
|
4
4
|
|
5
5
|
Object.defineProperty(schemaValidation, "__esModule", { value: true });
|
6
6
|
schemaValidation.isValidKeystore = schemaValidation.validateKeystore = schemaValidation.schemaValidationErrors = void 0;
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { __exports as aes } from '
|
2
|
-
import '
|
1
|
+
import { __exports as aes } from '../../../../../../../_virtual/aes.js';
|
2
|
+
import '../../../../@noble/hashes/cryptoBrowser.js';
|
3
3
|
import { u as utilsExports } from './utils.js';
|
4
|
-
import { __exports as cryptoBrowser } from '
|
4
|
+
import { __exports as cryptoBrowser } from '../../../../../../../_virtual/cryptoBrowser.js';
|
5
5
|
|
6
6
|
Object.defineProperty(aes, "__esModule", { value: true });
|
7
7
|
aes.decrypt = aes.encrypt = void 0;
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import { __exports as pbkdf2$1 } from '
|
2
|
-
import '
|
3
|
-
import '
|
4
|
-
import '
|
1
|
+
import { __exports as pbkdf2$1 } from '../../../../../../../_virtual/pbkdf2.js';
|
2
|
+
import '../../../../@noble/hashes/pbkdf2.js';
|
3
|
+
import '../../../../@noble/hashes/sha256.js';
|
4
|
+
import '../../../../@noble/hashes/sha512.js';
|
5
5
|
import { u as utilsExports } from './utils.js';
|
6
|
-
import { __exports as pbkdf2$2 } from '
|
7
|
-
import { __exports as sha256 } from '
|
8
|
-
import { __exports as sha512 } from '
|
6
|
+
import { __exports as pbkdf2$2 } from '../../../../../../../_virtual/pbkdf22.js';
|
7
|
+
import { __exports as sha256 } from '../../../../../../../_virtual/sha2562.js';
|
8
|
+
import { __exports as sha512 } from '../../../../../../../_virtual/sha512.js';
|
9
9
|
|
10
10
|
Object.defineProperty(pbkdf2$1, "__esModule", { value: true });
|
11
11
|
pbkdf2$1.pbkdf2Sync = pbkdf2$1.pbkdf2 = void 0;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { __exports as random } from '
|
2
|
-
import '
|
3
|
-
import { __exports as utils } from '
|
1
|
+
import { __exports as random } from '../../../../../../../_virtual/random.js';
|
2
|
+
import '../../../../@noble/hashes/utils.js';
|
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;
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { __exports as scrypt$1 } from '
|
2
|
-
import '
|
1
|
+
import { __exports as scrypt$1 } from '../../../../../../../_virtual/scrypt.js';
|
2
|
+
import '../../../../@noble/hashes/scrypt.js';
|
3
3
|
import { u as utilsExports } from './utils.js';
|
4
|
-
import { __exports as scrypt$2 } from '
|
4
|
+
import { __exports as scrypt$2 } from '../../../../../../../_virtual/scrypt2.js';
|
5
5
|
|
6
6
|
Object.defineProperty(scrypt$1, "__esModule", { value: true });
|
7
7
|
scrypt$1.scryptSync = scrypt$1.scrypt = void 0;
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { __exports as sha256 } from '
|
2
|
-
import '
|
1
|
+
import { __exports as sha256 } from '../../../../../../../_virtual/sha256.js';
|
2
|
+
import '../../../../@noble/hashes/sha256.js';
|
3
3
|
import { u as utilsExports } from './utils.js';
|
4
|
-
import { __exports as sha256$1 } from '
|
4
|
+
import { __exports as sha256$1 } from '../../../../../../../_virtual/sha2562.js';
|
5
5
|
|
6
6
|
Object.defineProperty(sha256, "__esModule", { value: true });
|
7
7
|
sha256.sha256 = void 0;
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import { commonjsGlobal } from '
|
2
|
-
import { commonjsRequire } from '
|
3
|
-
import { __module as utils } from '
|
4
|
-
import '
|
5
|
-
import '
|
6
|
-
import { __exports as _assert } from '
|
7
|
-
import { __exports as utils$1 } from '
|
1
|
+
import { commonjsGlobal } from '../../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { commonjsRequire } from '../../../../../../../_virtual/_commonjs-dynamic-modules.js';
|
3
|
+
import { __module as utils } from '../../../../../../../_virtual/utils2.js';
|
4
|
+
import '../../../../@noble/hashes/_assert.js';
|
5
|
+
import '../../../../@noble/hashes/utils.js';
|
6
|
+
import { __exports as _assert } from '../../../../../../../_virtual/_assert.js';
|
7
|
+
import { __exports as utils$1 } from '../../../../../../../_virtual/utils.js';
|
8
8
|
|
9
9
|
utils.exports;
|
10
10
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { __exports as _assert } from '
|
1
|
+
import { __exports as _assert } from '../../../../../_virtual/_assert.js';
|
2
2
|
|
3
3
|
Object.defineProperty(_assert, "__esModule", { value: true });
|
4
4
|
_assert.output = _assert.exists = _assert.hash = _assert.bytes = _assert.bool = _assert.number = void 0;
|