zkjson 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- package/doc.js +13 -3
- package/encoder.js +5 -1
- package/package.json +1 -1
package/doc.js
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
const snarkjs = require("snarkjs")
|
2
2
|
const { resolve } = require("path")
|
3
|
-
const {
|
3
|
+
const { isNil } = require("ramda")
|
4
|
+
const {
|
5
|
+
encodeQuery,
|
6
|
+
pad,
|
7
|
+
toSignal,
|
8
|
+
encode,
|
9
|
+
encodePath,
|
10
|
+
encodeVal,
|
11
|
+
} = require("./encoder")
|
4
12
|
|
5
13
|
module.exports = class Doc {
|
6
14
|
constructor({ size_val = 5, size_path = 5, size_json = 256, wasm, zkey }) {
|
@@ -10,11 +18,13 @@ module.exports = class Doc {
|
|
10
18
|
this.wasm = wasm
|
11
19
|
this.zkey = zkey
|
12
20
|
}
|
13
|
-
async getInputs({ json, path }) {
|
21
|
+
async getInputs({ query, json, path }) {
|
14
22
|
return {
|
15
23
|
json: pad(toSignal(encode(json)), this.size_json),
|
16
24
|
path: pad(toSignal(encodePath(path)), this.size_path),
|
17
|
-
val:
|
25
|
+
val: isNil(query)
|
26
|
+
? pad(toSignal(encodeVal(this.getVal(json, path))), this.size_val)
|
27
|
+
: pad(toSignal(encodeQuery(query)), this.size_val),
|
18
28
|
}
|
19
29
|
}
|
20
30
|
_getVal(j, p) {
|
package/encoder.js
CHANGED
@@ -8,6 +8,10 @@ const ops = {
|
|
8
8
|
$lte: 15,
|
9
9
|
$in: 16,
|
10
10
|
$nin: 17,
|
11
|
+
$contains: 18,
|
12
|
+
$contains_any: 19,
|
13
|
+
$contains_all: 20,
|
14
|
+
$contains_none: 21,
|
11
15
|
}
|
12
16
|
const opMap = {}
|
13
17
|
for (let k in ops) opMap[ops[k]] = k
|
@@ -473,7 +477,7 @@ function encodeQuery(v) {
|
|
473
477
|
if (!Array.isArray(v)) throw Error("query must be an array")
|
474
478
|
const op = v[0]
|
475
479
|
if (isNil(ops[op])) throw Error(`query not supported: ${op}`)
|
476
|
-
return [ops[op], ...encodeVal(v
|
480
|
+
return [ops[op], ...encodeVal(v[1])]
|
477
481
|
}
|
478
482
|
|
479
483
|
function decodeQuery(v) {
|