@waku/rln 0.1.6-b58de3a.0 → 0.1.6-c7a2055.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/rln/dist/contract/constants.js +1 -7
- package/bundle/packages/rln/dist/contract/rln_base_contract.js +3 -10
- package/bundle/packages/rln/dist/credentials_manager.js +8 -13
- package/bundle/packages/rln/dist/identity.js +2 -2
- package/bundle/packages/rln/dist/keystore/keystore.js +10 -16
- package/bundle/packages/rln/dist/utils/bytes.js +9 -3
- package/dist/.tsbuildinfo +1 -1
- package/dist/contract/constants.d.ts +0 -6
- package/dist/contract/constants.js +0 -6
- package/dist/contract/constants.js.map +1 -1
- package/dist/contract/rln_base_contract.d.ts +0 -5
- package/dist/contract/rln_base_contract.js +3 -10
- package/dist/contract/rln_base_contract.js.map +1 -1
- package/dist/credentials_manager.js +8 -13
- package/dist/credentials_manager.js.map +1 -1
- package/dist/identity.js +2 -2
- package/dist/identity.js.map +1 -1
- package/dist/keystore/keystore.js +10 -16
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/utils/bytes.d.ts +6 -1
- package/dist/utils/bytes.js +8 -2
- 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 +0 -9
- package/src/contract/rln_base_contract.ts +3 -17
- package/src/credentials_manager.ts +8 -21
- package/src/identity.ts +2 -2
- package/src/keystore/keystore.ts +16 -36
- package/src/utils/bytes.ts +11 -5
- package/src/utils/index.ts +1 -1
package/src/keystore/keystore.ts
CHANGED
@@ -14,7 +14,7 @@ import {
|
|
14
14
|
import _ from "lodash";
|
15
15
|
import { v4 as uuidV4 } from "uuid";
|
16
16
|
|
17
|
-
import {
|
17
|
+
import { buildBigIntFromUint8Array } from "../utils/bytes.js";
|
18
18
|
|
19
19
|
import { decryptEipKeystore, keccak256Checksum } from "./cipher.js";
|
20
20
|
import { isCredentialValid, isKeystoreValid } from "./schema_validator.js";
|
@@ -246,9 +246,6 @@ export class Keystore {
|
|
246
246
|
private static fromBytesToIdentity(
|
247
247
|
bytes: Uint8Array
|
248
248
|
): undefined | KeystoreEntity {
|
249
|
-
function fromLittleEndian(bytes: Uint8Array): Uint8Array {
|
250
|
-
return new Uint8Array(bytes).reverse();
|
251
|
-
}
|
252
249
|
try {
|
253
250
|
const str = bytesToUtf8(bytes);
|
254
251
|
const obj = JSON.parse(str);
|
@@ -256,32 +253,22 @@ export class Keystore {
|
|
256
253
|
// TODO: add runtime validation of nwaku credentials
|
257
254
|
return {
|
258
255
|
identity: {
|
259
|
-
IDCommitment:
|
260
|
-
|
261
|
-
_.get(obj, "identityCredential.idCommitment", [])
|
262
|
-
)
|
256
|
+
IDCommitment: Keystore.fromArraylikeToBytes(
|
257
|
+
_.get(obj, "identityCredential.idCommitment", [])
|
263
258
|
),
|
264
|
-
IDTrapdoor:
|
265
|
-
|
266
|
-
_.get(obj, "identityCredential.idTrapdoor", [])
|
267
|
-
)
|
259
|
+
IDTrapdoor: Keystore.fromArraylikeToBytes(
|
260
|
+
_.get(obj, "identityCredential.idTrapdoor", [])
|
268
261
|
),
|
269
|
-
IDNullifier:
|
270
|
-
|
271
|
-
_.get(obj, "identityCredential.idNullifier", [])
|
272
|
-
)
|
262
|
+
IDNullifier: Keystore.fromArraylikeToBytes(
|
263
|
+
_.get(obj, "identityCredential.idNullifier", [])
|
273
264
|
),
|
274
|
-
IDCommitmentBigInt:
|
275
|
-
fromLittleEndian(
|
276
|
-
Keystore.fromArraylikeToBytes(
|
277
|
-
_.get(obj, "identityCredential.idCommitment", [])
|
278
|
-
)
|
279
|
-
)
|
280
|
-
),
|
281
|
-
IDSecretHash: fromLittleEndian(
|
265
|
+
IDCommitmentBigInt: buildBigIntFromUint8Array(
|
282
266
|
Keystore.fromArraylikeToBytes(
|
283
|
-
_.get(obj, "identityCredential.
|
267
|
+
_.get(obj, "identityCredential.idCommitment", [])
|
284
268
|
)
|
269
|
+
),
|
270
|
+
IDSecretHash: Keystore.fromArraylikeToBytes(
|
271
|
+
_.get(obj, "identityCredential.idSecretHash", [])
|
285
272
|
)
|
286
273
|
},
|
287
274
|
membership: {
|
@@ -334,21 +321,14 @@ export class Keystore {
|
|
334
321
|
// follows nwaku implementation
|
335
322
|
// https://github.com/waku-org/nwaku/blob/f05528d4be3d3c876a8b07f9bb7dfaae8aa8ec6e/waku/waku_keystore/protocol_types.nim#L98
|
336
323
|
private static fromIdentityToBytes(options: KeystoreEntity): Uint8Array {
|
337
|
-
function toLittleEndian(bytes: Uint8Array): Uint8Array {
|
338
|
-
return new Uint8Array(bytes).reverse();
|
339
|
-
}
|
340
324
|
return utf8ToBytes(
|
341
325
|
JSON.stringify({
|
342
326
|
treeIndex: options.membership.treeIndex,
|
343
327
|
identityCredential: {
|
344
|
-
idCommitment: Array.from(
|
345
|
-
|
346
|
-
),
|
347
|
-
|
348
|
-
idSecretHash: Array.from(
|
349
|
-
toLittleEndian(options.identity.IDSecretHash)
|
350
|
-
),
|
351
|
-
idTrapdoor: Array.from(toLittleEndian(options.identity.IDTrapdoor))
|
328
|
+
idCommitment: Array.from(options.identity.IDCommitment),
|
329
|
+
idNullifier: Array.from(options.identity.IDNullifier),
|
330
|
+
idSecretHash: Array.from(options.identity.IDSecretHash),
|
331
|
+
idTrapdoor: Array.from(options.identity.IDTrapdoor)
|
352
332
|
},
|
353
333
|
membershipContract: {
|
354
334
|
chainId: options.membership.chainId,
|
package/src/utils/bytes.ts
CHANGED
@@ -56,11 +56,17 @@ export function writeUIntLE(
|
|
56
56
|
return buf;
|
57
57
|
}
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
/**
|
60
|
+
* Transforms Uint8Array into BigInt
|
61
|
+
* @param array: Uint8Array
|
62
|
+
* @returns BigInt
|
63
|
+
*/
|
64
|
+
export function buildBigIntFromUint8Array(
|
65
|
+
array: Uint8Array,
|
66
|
+
byteOffset: number = 0
|
67
|
+
): bigint {
|
68
|
+
const dataView = new DataView(array.buffer);
|
69
|
+
return dataView.getBigUint64(byteOffset, true);
|
64
70
|
}
|
65
71
|
|
66
72
|
/**
|
package/src/utils/index.ts
CHANGED