@waku/rln 0.1.6-a7f52e4.0 → 0.1.6-a8ca168.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.
Files changed (51) hide show
  1. package/bundle/_virtual/utils.js +2 -2
  2. package/bundle/_virtual/utils2.js +2 -2
  3. package/bundle/index.js +1 -1
  4. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/_sha2.js +1 -1
  5. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/hmac.js +1 -1
  6. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/pbkdf2.js +1 -1
  7. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/scrypt.js +1 -1
  8. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/sha256.js +1 -1
  9. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/sha512.js +1 -1
  10. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/@noble/hashes/utils.js +1 -1
  11. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +1 -1
  12. package/bundle/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +2 -2
  13. package/bundle/packages/core/dist/lib/message/version_0.js +1 -4
  14. package/bundle/packages/rln/dist/contract/constants.js +7 -1
  15. package/bundle/packages/rln/dist/contract/rln_base_contract.js +12 -5
  16. package/bundle/packages/rln/dist/credentials_manager.js +13 -8
  17. package/bundle/packages/rln/dist/identity.js +2 -2
  18. package/bundle/packages/rln/dist/keystore/keystore.js +2 -2
  19. package/bundle/packages/rln/dist/message.js +11 -0
  20. package/bundle/packages/rln/dist/utils/bytes.js +3 -12
  21. package/dist/.tsbuildinfo +1 -1
  22. package/dist/contract/constants.d.ts +6 -0
  23. package/dist/contract/constants.js +6 -0
  24. package/dist/contract/constants.js.map +1 -1
  25. package/dist/contract/rln_base_contract.d.ts +6 -1
  26. package/dist/contract/rln_base_contract.js +12 -5
  27. package/dist/contract/rln_base_contract.js.map +1 -1
  28. package/dist/credentials_manager.js +13 -8
  29. package/dist/credentials_manager.js.map +1 -1
  30. package/dist/identity.js +2 -2
  31. package/dist/identity.js.map +1 -1
  32. package/dist/keystore/keystore.js +2 -2
  33. package/dist/keystore/keystore.js.map +1 -1
  34. package/dist/message.d.ts +5 -4
  35. package/dist/message.js +2 -0
  36. package/dist/message.js.map +1 -1
  37. package/dist/utils/bytes.d.ts +1 -6
  38. package/dist/utils/bytes.js +2 -11
  39. package/dist/utils/bytes.js.map +1 -1
  40. package/dist/utils/index.d.ts +1 -1
  41. package/dist/utils/index.js +1 -1
  42. package/dist/utils/index.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/contract/constants.ts +9 -0
  45. package/src/contract/rln_base_contract.ts +19 -5
  46. package/src/credentials_manager.ts +21 -8
  47. package/src/identity.ts +2 -3
  48. package/src/keystore/keystore.ts +2 -2
  49. package/src/message.ts +7 -4
  50. package/src/utils/bytes.ts +5 -11
  51. package/src/utils/index.ts +1 -1
package/src/message.ts CHANGED
@@ -1,7 +1,9 @@
1
+ import { message } from "@waku/core";
1
2
  import type {
2
3
  IDecodedMessage,
3
4
  IMessage,
4
- IRateLimitProof
5
+ IRateLimitProof,
6
+ IRlnMessage
5
7
  } from "@waku/interfaces";
6
8
  import * as utils from "@waku/utils/bytes";
7
9
 
@@ -13,12 +15,13 @@ export function toRLNSignal(contentTopic: string, msg: IMessage): Uint8Array {
13
15
  return new Uint8Array([...(msg.payload ?? []), ...contentTopicBytes]);
14
16
  }
15
17
 
16
- export class RlnMessage<T extends IDecodedMessage> implements IDecodedMessage {
18
+ export class RlnMessage<T extends IDecodedMessage> implements IRlnMessage {
17
19
  public pubsubTopic = "";
20
+ public version = message.version_0.Version;
18
21
 
19
22
  public constructor(
20
- public rlnInstance: RLNInstance,
21
- public msg: T,
23
+ private rlnInstance: RLNInstance,
24
+ private msg: T,
22
25
  public rateLimitProof: IRateLimitProof | undefined
23
26
  ) {}
24
27
 
@@ -56,17 +56,11 @@ export function writeUIntLE(
56
56
  return buf;
57
57
  }
58
58
 
59
- /**
60
- * Transforms Uint8Array into BigInt
61
- * @param array: Uint8Array
62
- * @returns BigInt
63
- */
64
- export function buildBigIntFromUint8Array(array: Uint8Array): bigint {
65
- let hex = "";
66
- for (let i = 0; i < array.length; i++) {
67
- hex = array[i].toString(16).padStart(2, "0") + hex; // Reverse order for big-endian
68
- }
69
- return BigInt("0x" + hex);
59
+ export function buildBigIntFromUint8ArrayLE(bytes: Uint8Array): bigint {
60
+ return bytes.reduce(
61
+ (acc, byte, i) => acc + BigInt(byte) * (1n << (8n * BigInt(i))),
62
+ 0n
63
+ );
70
64
  }
71
65
 
72
66
  /**
@@ -2,7 +2,7 @@ export { extractMetaMaskSigner } from "./metamask.js";
2
2
  export {
3
3
  concatenate,
4
4
  writeUIntLE,
5
- buildBigIntFromUint8Array,
5
+ buildBigIntFromUint8ArrayLE,
6
6
  zeroPadLE
7
7
  } from "./bytes.js";
8
8
  export { sha256, poseidonHash } from "./hash.js";