@waku/rln 0.0.10 → 0.0.11
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/package.json +2 -2
- package/src/message.ts +1 -1
- package/src/rln.ts +28 -0
- package/bundle/assets/rln-fb4d7b4b.wasm +0 -0
- package/bundle/assets/rln_final-a641c06e.zkey +0 -0
- package/bundle/assets/rln_wasm_bg-72ac39a3.wasm +0 -0
- package/bundle/index.js +0 -47356
- package/dist/.tsbuildinfo +0 -1
- package/dist/byte_utils.d.ts +0 -1
- package/dist/byte_utils.js +0 -24
- package/dist/byte_utils.js.map +0 -1
- package/dist/codec.d.ts +0 -22
- package/dist/codec.js +0 -55
- package/dist/codec.js.map +0 -1
- package/dist/epoch.d.ts +0 -3
- package/dist/epoch.js +0 -16
- package/dist/epoch.js.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -12
- package/dist/index.js.map +0 -1
- package/dist/message.d.ts +0 -14
- package/dist/message.js +0 -34
- package/dist/message.js.map +0 -1
- package/dist/resources/rln.wasm +0 -0
- package/dist/resources/rln_final.zkey +0 -0
- package/dist/resources/verification_key.d.ts +0 -12
- package/dist/resources/verification_key.js +0 -121
- package/dist/resources/verification_key.js.map +0 -1
- package/dist/rln.d.ts +0 -34
- package/dist/rln.js +0 -137
- package/dist/rln.js.map +0 -1
- package/dist/witness_calculator.d.ts +0 -16
- package/dist/witness_calculator.js +0 -291
- package/dist/witness_calculator.js.map +0 -1
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@waku/rln",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.11",
|
4
4
|
"description": "Rate Limit Nullifier for js-waku",
|
5
5
|
"types": "./dist/index.d.ts",
|
6
6
|
"module": "./dist/index.js",
|
@@ -125,6 +125,6 @@
|
|
125
125
|
]
|
126
126
|
},
|
127
127
|
"dependencies": {
|
128
|
-
"@waku/zerokit-rln-wasm": "^0.0.
|
128
|
+
"@waku/zerokit-rln-wasm": "^0.0.4"
|
129
129
|
}
|
130
130
|
}
|
package/src/message.ts
CHANGED
@@ -18,7 +18,7 @@ export class RlnMessage<T extends Message> implements Message {
|
|
18
18
|
|
19
19
|
public verify(): boolean | undefined {
|
20
20
|
return this.rateLimitProof
|
21
|
-
? this.rlnInstance.
|
21
|
+
? this.rlnInstance.verifyWithRoots(this.rateLimitProof, toRLNSignal(this)) // this.rlnInstance.verifyRLNProof once issue status-im/nwaku#1248 is fixed
|
22
22
|
: undefined;
|
23
23
|
}
|
24
24
|
|
package/src/rln.ts
CHANGED
@@ -129,6 +129,10 @@ export class RLNInstance {
|
|
129
129
|
zerokitRLN.insertMember(this.zkRLN, idCommitment);
|
130
130
|
}
|
131
131
|
|
132
|
+
getMerkleRoot(): Uint8Array {
|
133
|
+
return zerokitRLN.getRoot(this.zkRLN);
|
134
|
+
}
|
135
|
+
|
132
136
|
serializeMessage(
|
133
137
|
uint8Msg: Uint8Array,
|
134
138
|
memIndex: number,
|
@@ -197,4 +201,28 @@ export class RLNInstance {
|
|
197
201
|
concatenate(pBytes, msgLen, msg)
|
198
202
|
);
|
199
203
|
}
|
204
|
+
|
205
|
+
verifyWithRoots(
|
206
|
+
proof: RateLimitProof | Uint8Array,
|
207
|
+
msg: Uint8Array
|
208
|
+
): boolean {
|
209
|
+
let pBytes: Uint8Array;
|
210
|
+
if (proof instanceof Uint8Array) {
|
211
|
+
pBytes = proof;
|
212
|
+
} else {
|
213
|
+
pBytes = proofToBytes(proof);
|
214
|
+
}
|
215
|
+
|
216
|
+
// calculate message length
|
217
|
+
const msgLen = writeUIntLE(new Uint8Array(8), msg.length, 0, 8);
|
218
|
+
|
219
|
+
// obtain root
|
220
|
+
const root = zerokitRLN.getRoot(this.zkRLN);
|
221
|
+
|
222
|
+
return zerokitRLN.verifyWithRoots(
|
223
|
+
this.zkRLN,
|
224
|
+
concatenate(pBytes, msgLen, msg),
|
225
|
+
root
|
226
|
+
);
|
227
|
+
}
|
200
228
|
}
|
Binary file
|
Binary file
|
Binary file
|