zkjson 0.6.4 → 0.7.1
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/cjs/circomlibjs.js +149 -0
- package/cjs/collection.js +196 -0
- package/cjs/db.js +731 -0
- package/cjs/doc.js +132 -0
- package/cjs/encoder-v1_5.js +1731 -0
- package/cjs/encoder.js +668 -0
- package/cjs/index.js +64 -0
- package/cjs/json.js +54 -0
- package/cjs/nft.js +164 -0
- package/cjs/parse.js +256 -0
- package/cjs/uint.js +580 -0
- package/{circomlibjs.js → esm/circomlibjs.js} +27 -35
- package/{collection.js → esm/collection.js} +4 -6
- package/{db.js → esm/db.js} +8 -10
- package/{doc.js → esm/doc.js} +7 -7
- package/{encoder-v1_5.js → esm/encoder-v1_5.js} +3 -3
- package/{encoder.js → esm/encoder.js} +2 -2
- package/esm/index.js +7 -0
- package/{json.js → esm/json.js} +2 -2
- package/{nft.js → esm/nft.js} +11 -9
- package/esm/package.json +3 -0
- package/{parse.js → esm/parse.js} +4 -4
- package/{uint.js → esm/uint.js} +1 -1
- package/package.json +21 -5
- package/index.js +0 -6
- /package/{contracts → esm/contracts}/NORollup.sol +0 -0
- /package/{contracts → esm/contracts}/OPRollup.sol +0 -0
- /package/{contracts → esm/contracts}/ZKIPFS.sol +0 -0
- /package/{contracts → esm/contracts}/ZKJson.sol +0 -0
- /package/{contracts → esm/contracts}/ZKQuery.sol +0 -0
- /package/{contracts → esm/contracts}/ZKRollup.sol +0 -0
- /package/{contracts → esm/contracts}/apps/SimpleJSON.sol +0 -0
- /package/{contracts → esm/contracts}/apps/SimpleOPRU.sol +0 -0
- /package/{contracts → esm/contracts}/apps/SimpleRU.sol +0 -0
- /package/{contracts → esm/contracts}/apps/Token.sol +0 -0
- /package/{contracts → esm/contracts}/apps/ZKArweave.sol +0 -0
- /package/{contracts → esm/contracts}/apps/ZKBridge.sol +0 -0
- /package/{contracts → esm/contracts}/apps/ZKNFT.sol +0 -0
- /package/{contracts → esm/contracts}/verifiers/verifier_db.sol +0 -0
- /package/{contracts → esm/contracts}/verifiers/verifier_ipfs.sol +0 -0
- /package/{contracts → esm/contracts}/verifiers/verifier_json.sol +0 -0
- /package/{contracts → esm/contracts}/verifiers/verifier_rollup.sol +0 -0
package/{doc.js → esm/doc.js}
RENAMED
@@ -1,16 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import { groth16 } from "snarkjs"
|
2
|
+
import { resolve } from "path"
|
3
|
+
import { isNil } from "ramda"
|
4
|
+
import {
|
5
5
|
encodeQuery,
|
6
6
|
pad,
|
7
7
|
toSignal,
|
8
8
|
encode,
|
9
9
|
encodePath,
|
10
10
|
encodeVal,
|
11
|
-
}
|
11
|
+
} from "./encoder.js"
|
12
12
|
|
13
|
-
|
13
|
+
export default class Doc {
|
14
14
|
constructor({ size_val = 8, size_path = 4, size_json = 256, wasm, zkey }) {
|
15
15
|
this.size_val = size_val
|
16
16
|
this.size_path = size_path
|
@@ -48,7 +48,7 @@ module.exports = class Doc {
|
|
48
48
|
}
|
49
49
|
async genProof({ json, path, query }) {
|
50
50
|
const inputs = await this.getInputs({ json, path, query })
|
51
|
-
const { proof, publicSignals } = await
|
51
|
+
const { proof, publicSignals } = await groth16.fullProve(
|
52
52
|
inputs,
|
53
53
|
this.wasm,
|
54
54
|
this.zkey,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
import {
|
2
2
|
clone,
|
3
3
|
uniq,
|
4
4
|
sortBy,
|
@@ -16,7 +16,7 @@ const {
|
|
16
16
|
includes,
|
17
17
|
splitEvery,
|
18
18
|
flatten,
|
19
|
-
}
|
19
|
+
} from "ramda"
|
20
20
|
const ops = {
|
21
21
|
$eq: 10,
|
22
22
|
$ne: 11,
|
@@ -1299,7 +1299,7 @@ const unshift = (vals, _num) => {
|
|
1299
1299
|
}
|
1300
1300
|
return addedCount
|
1301
1301
|
}
|
1302
|
-
|
1302
|
+
export {
|
1303
1303
|
from128s,
|
1304
1304
|
to128s,
|
1305
1305
|
to128,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
import { clone, isNil, includes, splitEvery, flatten } from "ramda"
|
2
2
|
const ops = {
|
3
3
|
$eq: 10,
|
4
4
|
$ne: 11,
|
@@ -564,7 +564,7 @@ function decodeQuery(v) {
|
|
564
564
|
return [op, decodeVal(v.slice(1))]
|
565
565
|
}
|
566
566
|
|
567
|
-
|
567
|
+
export {
|
568
568
|
encode,
|
569
569
|
decode,
|
570
570
|
encodePath,
|
package/esm/index.js
ADDED
package/{json.js → esm/json.js}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
import { pad, toSignal, encode, encodePath, encodeVal } from "./encoder"
|
2
2
|
|
3
|
-
|
3
|
+
export default class Json {
|
4
4
|
constructor({ size_val = 8, size_path = 4, size_json = 256 }) {
|
5
5
|
this.size_val = size_val
|
6
6
|
this.size_path = size_path
|
package/{nft.js → esm/nft.js}
RENAMED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
import { hash } from "fast-sha256"
|
2
|
+
import { groth16 } from "snarkjs"
|
3
|
+
import { query, pad, path, val } from "./encoder.js"
|
4
|
+
import { push, arr } from "./uint.js"
|
5
|
+
import { parse } from "./parse.js"
|
6
6
|
|
7
7
|
function coerce(o) {
|
8
8
|
if (o instanceof Uint8Array && o.constructor.name === "Uint8Array") return o
|
@@ -71,7 +71,7 @@ function toCID(source) {
|
|
71
71
|
return str
|
72
72
|
}
|
73
73
|
|
74
|
-
|
74
|
+
export default class NFT {
|
75
75
|
constructor({
|
76
76
|
size_val = 34,
|
77
77
|
size_path = 5,
|
@@ -106,7 +106,7 @@ module.exports = class NFT {
|
|
106
106
|
const _path = this.path(pth)
|
107
107
|
const _val = Array.isArray(cond) ? this.query(pth, cond) : this.val(pth)
|
108
108
|
const inputs = { path: _path, val: _val, encoded }
|
109
|
-
const { proof, publicSignals } = await
|
109
|
+
const { proof, publicSignals } = await groth16.fullProve(
|
110
110
|
inputs,
|
111
111
|
this.wasm,
|
112
112
|
this.zkey,
|
@@ -121,7 +121,9 @@ module.exports = class NFT {
|
|
121
121
|
}
|
122
122
|
cid() {
|
123
123
|
const str = new TextEncoder().encode(JSON.stringify(this.json))
|
124
|
-
const
|
125
|
-
return toCID(
|
124
|
+
const hashBytes = hash(str)
|
125
|
+
return toCID(
|
126
|
+
new Uint8Array([18, hashBytes.length, ...Array.from(hashBytes)]),
|
127
|
+
)
|
126
128
|
}
|
127
129
|
}
|
package/esm/package.json
ADDED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
import {
|
2
2
|
toArray,
|
3
3
|
concat,
|
4
4
|
sum,
|
@@ -7,12 +7,12 @@ const {
|
|
7
7
|
pushArray,
|
8
8
|
length,
|
9
9
|
next,
|
10
|
-
arr
|
10
|
+
arr as _arr,
|
11
11
|
push,
|
12
12
|
pop,
|
13
13
|
last,
|
14
14
|
bn,
|
15
|
-
}
|
15
|
+
} from "./uint.js"
|
16
16
|
const _null_ = [110, 117, 108, 108]
|
17
17
|
const _true_ = [116, 114, 117, 101]
|
18
18
|
const _false_ = [102, 97, 108, 115, 101]
|
@@ -311,4 +311,4 @@ const parse = (str, size = 100, digit = 9) => {
|
|
311
311
|
return json
|
312
312
|
}
|
313
313
|
|
314
|
-
|
314
|
+
export { parse }
|
package/{uint.js → esm/uint.js}
RENAMED
package/package.json
CHANGED
@@ -1,9 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"name": "zkjson",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.7.1",
|
4
4
|
"description": "Zero Knowledge Provable JSON",
|
5
|
-
"
|
6
|
-
|
5
|
+
"exports": {
|
6
|
+
".": {
|
7
|
+
"require": "./cjs/index.js",
|
8
|
+
"import": "./esm/index.js"
|
9
|
+
},
|
10
|
+
"./utint": {
|
11
|
+
"require": "./cjs/uint.js",
|
12
|
+
"import": "./esm/uint.js"
|
13
|
+
}
|
14
|
+
},
|
7
15
|
"dependencies": {
|
8
16
|
"blake-hash": "^2.0.0",
|
9
17
|
"blake2b": "^2.1.3",
|
@@ -11,5 +19,13 @@
|
|
11
19
|
"ffjavascript": "^0.2.45",
|
12
20
|
"ramda": "^0.29.1",
|
13
21
|
"snarkjs": "^0.7.3"
|
14
|
-
}
|
15
|
-
|
22
|
+
},
|
23
|
+
"devDependencies": {
|
24
|
+
"@babel/cli": "^7.24.8",
|
25
|
+
"@babel/core": "^7.25.2",
|
26
|
+
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
|
27
|
+
"@babel/preset-env": "^7.25.3"
|
28
|
+
},
|
29
|
+
"main": "cjs/index.js",
|
30
|
+
"module": "esm/index.js"
|
31
|
+
}
|
package/index.js
DELETED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|