@waku/rln 0.1.5-9901863.0 → 0.1.5-aaa7a0c.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/packages/rln/dist/contract/constants.js +1 -1
- package/bundle/packages/rln/dist/contract/rln_base_contract.js +4 -4
- package/bundle/packages/rln/dist/credentials_manager.js +10 -28
- package/bundle/packages/rln/dist/identity.js +0 -8
- package/bundle/packages/rln/dist/keystore/keystore.js +29 -17
- package/bundle/packages/rln/dist/zerokit.js +5 -5
- package/dist/.tsbuildinfo +1 -1
- package/dist/contract/constants.d.ts +1 -1
- package/dist/contract/constants.js +1 -1
- package/dist/contract/constants.js.map +1 -1
- package/dist/contract/rln_base_contract.js +4 -4
- package/dist/contract/rln_base_contract.js.map +1 -1
- package/dist/credentials_manager.d.ts +3 -9
- package/dist/credentials_manager.js +10 -28
- package/dist/credentials_manager.js.map +1 -1
- package/dist/identity.d.ts +0 -1
- package/dist/identity.js +0 -8
- package/dist/identity.js.map +1 -1
- package/dist/keystore/keystore.d.ts +1 -0
- package/dist/keystore/keystore.js +29 -17
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/rln.js.map +1 -1
- package/dist/zerokit.d.ts +3 -3
- package/dist/zerokit.js +5 -5
- package/dist/zerokit.js.map +1 -1
- package/package.json +1 -1
- package/src/contract/constants.ts +1 -1
- package/src/contract/rln_base_contract.ts +4 -4
- package/src/credentials_manager.ts +10 -34
- package/src/identity.ts +0 -9
- package/src/keystore/keystore.ts +51 -29
- package/src/rln.ts +1 -0
- package/src/zerokit.ts +3 -3
package/src/keystore/keystore.ts
CHANGED
@@ -14,7 +14,6 @@ import {
|
|
14
14
|
import _ from "lodash";
|
15
15
|
import { v4 as uuidV4 } from "uuid";
|
16
16
|
|
17
|
-
import { IdentityCredential } from "../identity.js";
|
18
17
|
import { buildBigIntFromUint8Array } from "../utils/bytes.js";
|
19
18
|
|
20
19
|
import { decryptEipKeystore, keccak256Checksum } from "./cipher.js";
|
@@ -251,32 +250,32 @@ export class Keystore {
|
|
251
250
|
const str = bytesToUtf8(bytes);
|
252
251
|
const obj = JSON.parse(str);
|
253
252
|
|
254
|
-
//
|
255
|
-
const { idTrapdoor, idNullifier, idSecretHash, idCommitment } = _.get(
|
256
|
-
obj,
|
257
|
-
"identityCredential",
|
258
|
-
{}
|
259
|
-
);
|
260
|
-
|
261
|
-
const idTrapdoorArray = new Uint8Array(idTrapdoor || []);
|
262
|
-
const idNullifierArray = new Uint8Array(idNullifier || []);
|
263
|
-
const idSecretHashArray = new Uint8Array(idSecretHash || []);
|
264
|
-
const idCommitmentArray = new Uint8Array(idCommitment || []);
|
265
|
-
const idCommitmentBigInt = buildBigIntFromUint8Array(idCommitmentArray);
|
266
|
-
|
253
|
+
// TODO: add runtime validation of nwaku credentials
|
267
254
|
return {
|
268
|
-
identity:
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
255
|
+
identity: {
|
256
|
+
IDCommitment: Keystore.fromArraylikeToBytes(
|
257
|
+
_.get(obj, "identityCredential.idCommitment", [])
|
258
|
+
),
|
259
|
+
IDTrapdoor: Keystore.fromArraylikeToBytes(
|
260
|
+
_.get(obj, "identityCredential.idTrapdoor", [])
|
261
|
+
),
|
262
|
+
IDNullifier: Keystore.fromArraylikeToBytes(
|
263
|
+
_.get(obj, "identityCredential.idNullifier", [])
|
264
|
+
),
|
265
|
+
IDCommitmentBigInt: buildBigIntFromUint8Array(
|
266
|
+
Keystore.fromArraylikeToBytes(
|
267
|
+
_.get(obj, "identityCredential.idCommitment", [])
|
268
|
+
)
|
269
|
+
),
|
270
|
+
IDSecretHash: Keystore.fromArraylikeToBytes(
|
271
|
+
_.get(obj, "identityCredential.idSecretHash", [])
|
272
|
+
)
|
273
|
+
},
|
275
274
|
membership: {
|
276
275
|
treeIndex: _.get(obj, "treeIndex"),
|
277
276
|
chainId: _.get(obj, "membershipContract.chainId"),
|
278
277
|
address: _.get(obj, "membershipContract.address"),
|
279
|
-
rateLimit: _.get(obj, "
|
278
|
+
rateLimit: _.get(obj, "membershipContract.rateLimit")
|
280
279
|
}
|
281
280
|
};
|
282
281
|
} catch (err) {
|
@@ -285,6 +284,30 @@ export class Keystore {
|
|
285
284
|
}
|
286
285
|
}
|
287
286
|
|
287
|
+
private static fromArraylikeToBytes(
|
288
|
+
obj:
|
289
|
+
| number[]
|
290
|
+
| {
|
291
|
+
[key: number]: number;
|
292
|
+
}
|
293
|
+
): Uint8Array {
|
294
|
+
if (Array.isArray(obj)) {
|
295
|
+
return new Uint8Array(obj);
|
296
|
+
}
|
297
|
+
|
298
|
+
const bytes = [];
|
299
|
+
let index = 0;
|
300
|
+
let lastElement = obj[index];
|
301
|
+
|
302
|
+
while (lastElement !== undefined) {
|
303
|
+
bytes.push(lastElement);
|
304
|
+
index += 1;
|
305
|
+
lastElement = obj[index];
|
306
|
+
}
|
307
|
+
|
308
|
+
return new Uint8Array(bytes);
|
309
|
+
}
|
310
|
+
|
288
311
|
// follows nwaku implementation
|
289
312
|
// https://github.com/waku-org/nwaku/blob/f05528d4be3d3c876a8b07f9bb7dfaae8aa8ec6e/waku/waku_keystore/protocol_types.nim#L111
|
290
313
|
private static computeMembershipHash(info: MembershipInfo): MembershipHash {
|
@@ -298,18 +321,17 @@ export class Keystore {
|
|
298
321
|
private static fromIdentityToBytes(options: KeystoreEntity): Uint8Array {
|
299
322
|
return utf8ToBytes(
|
300
323
|
JSON.stringify({
|
301
|
-
membershipContract: {
|
302
|
-
chainId: options.membership.chainId,
|
303
|
-
address: options.membership.address
|
304
|
-
},
|
305
324
|
treeIndex: options.membership.treeIndex,
|
306
325
|
identityCredential: {
|
307
|
-
|
326
|
+
idCommitment: Array.from(options.identity.IDCommitment),
|
308
327
|
idNullifier: Array.from(options.identity.IDNullifier),
|
309
328
|
idSecretHash: Array.from(options.identity.IDSecretHash),
|
310
|
-
|
329
|
+
idTrapdoor: Array.from(options.identity.IDTrapdoor)
|
311
330
|
},
|
312
|
-
|
331
|
+
membershipContract: {
|
332
|
+
chainId: options.membership.chainId,
|
333
|
+
address: options.membership.address
|
334
|
+
}
|
313
335
|
})
|
314
336
|
);
|
315
337
|
}
|
package/src/rln.ts
CHANGED
package/src/zerokit.ts
CHANGED
@@ -16,7 +16,7 @@ export class Zerokit {
|
|
16
16
|
public constructor(
|
17
17
|
private readonly zkRLN: number,
|
18
18
|
private readonly witnessCalculator: WitnessCalculator,
|
19
|
-
private readonly
|
19
|
+
private readonly _rateLimit: number = DEFAULT_RATE_LIMIT
|
20
20
|
) {}
|
21
21
|
|
22
22
|
public get getZkRLN(): number {
|
@@ -27,8 +27,8 @@ export class Zerokit {
|
|
27
27
|
return this.witnessCalculator;
|
28
28
|
}
|
29
29
|
|
30
|
-
public get
|
31
|
-
return this.
|
30
|
+
public get rateLimit(): number {
|
31
|
+
return this._rateLimit;
|
32
32
|
}
|
33
33
|
|
34
34
|
public generateIdentityCredentials(): IdentityCredential {
|