zkjson 0.6.0 → 1.0.2
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/README.md +537 -0
- package/assets/collection.png +0 -0
- package/assets/db.png +0 -0
- package/assets/encode.png +0 -0
- package/assets/query.png +0 -0
- package/assets/rollup.png +0 -0
- package/assets/structure.png +0 -0
- package/assets/weavedb.png +0 -0
- package/assets/zkjson.png +0 -0
- package/benchmark/components/ui/avatar.jsx +49 -0
- package/benchmark/components/ui/checkbox.jsx +17 -0
- package/benchmark/components/ui/close-button.jsx +20 -0
- package/benchmark/components/ui/color-mode.jsx +89 -0
- package/benchmark/components/ui/dialog.jsx +54 -0
- package/benchmark/components/ui/drawer.jsx +44 -0
- package/benchmark/components/ui/field.jsx +22 -0
- package/benchmark/components/ui/input-group.jsx +39 -0
- package/benchmark/components/ui/popover.jsx +49 -0
- package/benchmark/components/ui/provider.jsx +12 -0
- package/benchmark/components/ui/radio.jsx +17 -0
- package/benchmark/components/ui/slider.jsx +107 -0
- package/benchmark/components/ui/tooltip.jsx +35 -0
- package/benchmark/jsconfig.json +7 -0
- package/benchmark/lib/cbor.js +387 -0
- package/benchmark/lib/msgpack.js +651 -0
- package/benchmark/next.config.mjs +6 -0
- package/benchmark/package.json +22 -0
- package/benchmark/pages/_app.js +9 -0
- package/benchmark/pages/_document.js +13 -0
- package/benchmark/pages/api/hello.js +5 -0
- package/benchmark/pages/index.js +438 -0
- package/benchmark/public/favicon.ico +0 -0
- package/benchmark/public/file.svg +1 -0
- package/benchmark/public/globe.svg +1 -0
- package/benchmark/public/next.svg +1 -0
- package/benchmark/public/vercel.svg +1 -0
- package/benchmark/public/window.svg +1 -0
- package/benchmark/yarn.lock +2448 -0
- package/circom/collection/collection.circom +32 -0
- package/circom/collection/compile.sh +10 -0
- package/circom/collection/gen.js +34 -0
- package/circom/collection/generateInput.js +10 -0
- package/circom/collection/index.circom +4 -0
- package/circom/collection/test.js +21 -0
- package/circom/collection/verifier.sol +247 -0
- package/circom/db/compile.sh +10 -0
- package/circom/db/db.circom +39 -0
- package/circom/db/gen.js +30 -0
- package/circom/db/generateInput.js +10 -0
- package/circom/db/index.circom +4 -0
- package/circom/db/test.js +21 -0
- package/circom/db/verifier.sol +261 -0
- package/circom/ipfs/calculate_total.circom +17 -0
- package/circom/ipfs/compile.sh +10 -0
- package/circom/ipfs/gen.js +18 -0
- package/circom/ipfs/generateInput.js +10 -0
- package/circom/ipfs/index.circom +4 -0
- package/circom/ipfs/ipfs.circom +62 -0
- package/circom/ipfs/parse.circom +289 -0
- package/circom/ipfs/sha256.circom +99 -0
- package/circom/ipfs/test.js +167 -0
- package/circom/ipfs/verifier.sol +261 -0
- package/circom/json/compile.sh +10 -0
- package/circom/json/gen.js +22 -0
- package/circom/json/gen2.js +21 -0
- package/circom/json/generateInput.js +20 -0
- package/circom/json/index.circom +4 -0
- package/circom/json/json.circom +81 -0
- package/circom/json/test.js +100 -0
- package/circom/json/verifier.sol +247 -0
- package/circom/query/compile.sh +10 -0
- package/circom/query/gen.js +28 -0
- package/circom/query/generateInput.js +11 -0
- package/circom/query/index.circom +4 -0
- package/circom/query/query.circom +58 -0
- package/circom/query/test.js +20 -0
- package/circom/query/verifier.sol +177 -0
- package/circom/rollup/compile.sh +10 -0
- package/circom/rollup/gen.js +36 -0
- package/circom/rollup/generateInput.js +11 -0
- package/circom/rollup/index.circom +4 -0
- package/circom/rollup/rollup.circom +43 -0
- package/circom/rollup/test.js +35 -0
- package/circom/rollup/verifier.sol +240 -0
- package/circom/scripts/ceremony.js +39 -0
- package/circom/scripts/ceremony.sh +6 -0
- package/circom/scripts/compile.js +113 -0
- package/circom/scripts/compile.sh +16 -0
- package/circom/utils/uint.circom +512 -0
- package/circom/utils/utils.circom +628 -0
- package/demos/arweave/jsconfig.json +7 -0
- package/demos/arweave/lib/ZKArweave.json +617 -0
- package/demos/arweave/lib/encoder.js +375 -0
- package/demos/arweave/next.config.js +6 -0
- package/demos/arweave/package.json +26 -0
- package/demos/arweave/pages/_app.js +9 -0
- package/demos/arweave/pages/_document.js +19 -0
- package/demos/arweave/pages/api/arweave.js +31 -0
- package/demos/arweave/pages/api/hello.js +5 -0
- package/demos/arweave/pages/index.js +869 -0
- package/demos/arweave/public/circuit.wasm +0 -0
- package/demos/arweave/public/circuit_final.zkey +0 -0
- package/demos/arweave/public/verification_key.json +149 -0
- package/demos/arweave/vercel.json +7 -0
- package/demos/arweave/yarn.lock +2510 -0
- package/demos/simple/jsconfig.json +7 -0
- package/demos/simple/lib/encoder.js +375 -0
- package/demos/simple/next.config.js +6 -0
- package/demos/simple/package.json +24 -0
- package/demos/simple/pages/_app.js +9 -0
- package/demos/simple/pages/_document.js +13 -0
- package/demos/simple/pages/api/hello.js +5 -0
- package/demos/simple/pages/index.js +342 -0
- package/demos/simple/public/circuit.wasm +0 -0
- package/demos/simple/public/circuit_final.zkey +0 -0
- package/demos/simple/public/verification_key.json +149 -0
- package/demos/simple/yarn.lock +2519 -0
- package/docs/README.md +17 -0
- package/docs/simple-zkjson.md +210 -0
- package/docs/solidity-contracts.md +216 -0
- package/docs/zk-circuits.md +125 -0
- package/docs/zkdb-rollup.md +218 -0
- package/docs/zkjson-sdk.md +254 -0
- package/docs/zkjson-v1_5.md +365 -0
- package/package.json +16 -7
- package/sdk/contracts/NORollup.sol +13 -0
- package/sdk/package.json +15 -0
- package/sdk/yarn.lock +881 -0
- package/solidity/README.md +13 -0
- package/solidity/arguments.js +4 -0
- package/solidity/contracts/NORollup.sol +13 -0
- package/solidity/contracts/OPRollup.sol +14 -0
- package/solidity/contracts/ZKIPFS.sol +95 -0
- package/solidity/contracts/ZKJson.sol +21 -0
- package/solidity/contracts/ZKQuery.sol +286 -0
- package/solidity/contracts/ZKRollup.sol +35 -0
- package/solidity/contracts/apps/NORU.sol +66 -0
- package/solidity/contracts/apps/SimpleJSON.sol +64 -0
- package/solidity/contracts/apps/SimpleOPRU.sol +67 -0
- package/solidity/contracts/apps/SimpleRU.sol +67 -0
- package/solidity/contracts/apps/Token.sol +12 -0
- package/solidity/contracts/apps/ZKArweave.sol +89 -0
- package/solidity/contracts/apps/ZKBridge.sol +74 -0
- package/solidity/contracts/apps/ZKNFT.sol +63 -0
- package/solidity/contracts/verifiers/verifier_db.sol +275 -0
- package/solidity/contracts/verifiers/verifier_ipfs.sol +464 -0
- package/solidity/contracts/verifiers/verifier_json.sol +261 -0
- package/solidity/contracts/verifiers/verifier_rollup.sol +240 -0
- package/solidity/package.json +27 -0
- package/solidity/scripts/deploy.js +33 -0
- package/solidity/test/NORU.js +66 -0
- package/solidity/test/ZKArweave.js +97 -0
- package/solidity/test/arweave.js +55 -0
- package/solidity/test/bridge.js +71 -0
- package/solidity/test/simple.js +76 -0
- package/solidity/test/simpleOPRU.js +98 -0
- package/solidity/test/simpleRU.js +94 -0
- package/solidity/test/zknft.js +98 -0
- package/solidity/yarn.lock +4152 -0
- package/test/test.js +304 -0
- /package/{circomlibjs.js → sdk/circomlibjs.js} +0 -0
- /package/{collection.js → sdk/collection.js} +0 -0
- /package/{contracts → sdk/contracts}/OPRollup.sol +0 -0
- /package/{contracts → sdk/contracts}/ZKIPFS.sol +0 -0
- /package/{contracts → sdk/contracts}/ZKJson.sol +0 -0
- /package/{contracts → sdk/contracts}/ZKQuery.sol +0 -0
- /package/{contracts → sdk/contracts}/ZKRollup.sol +0 -0
- /package/{contracts → sdk/contracts}/apps/SimpleJSON.sol +0 -0
- /package/{contracts → sdk/contracts}/apps/SimpleOPRU.sol +0 -0
- /package/{contracts → sdk/contracts}/apps/SimpleRU.sol +0 -0
- /package/{contracts → sdk/contracts}/apps/Token.sol +0 -0
- /package/{contracts → sdk/contracts}/apps/ZKArweave.sol +0 -0
- /package/{contracts → sdk/contracts}/apps/ZKBridge.sol +0 -0
- /package/{contracts → sdk/contracts}/apps/ZKNFT.sol +0 -0
- /package/{contracts → sdk/contracts}/verifiers/verifier_db.sol +0 -0
- /package/{contracts → sdk/contracts}/verifiers/verifier_ipfs.sol +0 -0
- /package/{contracts → sdk/contracts}/verifiers/verifier_json.sol +0 -0
- /package/{contracts → sdk/contracts}/verifiers/verifier_rollup.sol +0 -0
- /package/{db.js → sdk/db.js} +0 -0
- /package/{doc.js → sdk/doc.js} +0 -0
- /package/{encoder-v1_5.js → sdk/encoder-v1_5.js} +0 -0
- /package/{encoder.js → sdk/encoder.js} +0 -0
- /package/{index.js → sdk/index.js} +0 -0
- /package/{json.js → sdk/json.js} +0 -0
- /package/{nft.js → sdk/nft.js} +0 -0
- /package/{parse.js → sdk/parse.js} +0 -0
- /package/{uint.js → sdk/uint.js} +0 -0
@@ -0,0 +1,438 @@
|
|
1
|
+
import { useEffect, useState } from "react"
|
2
|
+
import { BSON, EJSON, ObjectId } from "bson"
|
3
|
+
import { encode_x, u8 } from "zkjson/encoder-v2.js"
|
4
|
+
import { encode as enc, decode as dec } from "../lib/msgpack"
|
5
|
+
import { encode as enc2, decode as dec2 } from "../lib/cbor"
|
6
|
+
import { range } from "ramda"
|
7
|
+
import { Flex, Box } from "@chakra-ui/react"
|
8
|
+
|
9
|
+
function createJSON2(depth = 5, width = 5) {
|
10
|
+
const cache = new Map()
|
11
|
+
let stringIndex = 0
|
12
|
+
let counter = 0
|
13
|
+
let sequenceStart = 0
|
14
|
+
let sequenceLength = Math.floor(Math.random() * 15) + 15
|
15
|
+
const targetSize = 9800
|
16
|
+
const maxSize = 10200
|
17
|
+
let totalSize = 0
|
18
|
+
|
19
|
+
const commonKeys = [
|
20
|
+
"id",
|
21
|
+
"name",
|
22
|
+
"type",
|
23
|
+
"value",
|
24
|
+
"status",
|
25
|
+
"createdAt",
|
26
|
+
"updatedAt",
|
27
|
+
"metadata",
|
28
|
+
"info",
|
29
|
+
"description",
|
30
|
+
]
|
31
|
+
const commonValues = [
|
32
|
+
"active",
|
33
|
+
"inactive",
|
34
|
+
"pending",
|
35
|
+
"approved",
|
36
|
+
"rejected",
|
37
|
+
"processing",
|
38
|
+
"completed",
|
39
|
+
"error",
|
40
|
+
]
|
41
|
+
|
42
|
+
function getCachedString() {
|
43
|
+
if (Math.random() < 0.95) {
|
44
|
+
const key = commonKeys[Math.floor(Math.random() * commonKeys.length)]
|
45
|
+
if (!cache.has(key)) cache.set(key, stringIndex++)
|
46
|
+
return key
|
47
|
+
}
|
48
|
+
return Math.random().toString(36).substring(7)
|
49
|
+
}
|
50
|
+
|
51
|
+
function getCommonValue() {
|
52
|
+
return commonValues[Math.floor(Math.random() * commonValues.length)]
|
53
|
+
}
|
54
|
+
|
55
|
+
function getSequentialNumber() {
|
56
|
+
if (counter - sequenceStart >= sequenceLength) {
|
57
|
+
sequenceStart = counter
|
58
|
+
sequenceLength = Math.floor(Math.random() * 15) + 15
|
59
|
+
}
|
60
|
+
return counter++
|
61
|
+
}
|
62
|
+
|
63
|
+
// Modified to track size better and ensure we don't exit early
|
64
|
+
function createArray(level, remainingSize) {
|
65
|
+
if (remainingSize <= 0) return []
|
66
|
+
|
67
|
+
// Dynamic sizing - create smaller arrays when closer to target
|
68
|
+
const sizeFactor = Math.min(1, remainingSize / 5000)
|
69
|
+
const length = Math.floor((Math.random() * 100 + 50) * sizeFactor)
|
70
|
+
|
71
|
+
const arr = []
|
72
|
+
for (let i = 0; i < length && totalSize < maxSize; i++) {
|
73
|
+
const element = createRandom(level - 1, remainingSize / length)
|
74
|
+
arr.push(element)
|
75
|
+
|
76
|
+
// Update size tracking
|
77
|
+
const elementSize = JSON.stringify(element).length + 2 // +2 for commas and brackets
|
78
|
+
totalSize += elementSize
|
79
|
+
remainingSize -= elementSize
|
80
|
+
|
81
|
+
if (totalSize >= targetSize) break
|
82
|
+
}
|
83
|
+
return arr
|
84
|
+
}
|
85
|
+
|
86
|
+
function createObject(level, remainingSize) {
|
87
|
+
if (remainingSize <= 0) return {}
|
88
|
+
|
89
|
+
const obj = {}
|
90
|
+
// Dynamic sizing - create smaller objects when closer to target
|
91
|
+
const sizeFactor = Math.min(1, remainingSize / 5000)
|
92
|
+
const size = Math.floor((Math.random() * width + 6) * sizeFactor)
|
93
|
+
for (let i = 0; i < size && totalSize < maxSize; i++) {
|
94
|
+
const key = getCachedString()
|
95
|
+
if (Math.random() < 0.8) {
|
96
|
+
obj[key] = getCommonValue()
|
97
|
+
totalSize += key.length + getCommonValue().length + 5 // Accounting for quotes and separator
|
98
|
+
} else {
|
99
|
+
const value = createRandom(level - 1, remainingSize / size)
|
100
|
+
obj[key] = value
|
101
|
+
totalSize += key.length + JSON.stringify(value).length + 5
|
102
|
+
}
|
103
|
+
|
104
|
+
if (totalSize >= targetSize) break
|
105
|
+
}
|
106
|
+
return obj
|
107
|
+
}
|
108
|
+
|
109
|
+
function createRandom(level, remainingSize) {
|
110
|
+
if (remainingSize <= 0 || level <= 0) return getSequentialNumber()
|
111
|
+
|
112
|
+
// When close to target size, prefer simple values to avoid overshooting
|
113
|
+
if (remainingSize < 100) return getSequentialNumber()
|
114
|
+
|
115
|
+
return Math.random() < 0.5
|
116
|
+
? createArray(level, remainingSize)
|
117
|
+
: createObject(level, remainingSize)
|
118
|
+
}
|
119
|
+
|
120
|
+
let json
|
121
|
+
let attempts = 0
|
122
|
+
const maxAttempts = 5
|
123
|
+
|
124
|
+
do {
|
125
|
+
totalSize = 0
|
126
|
+
json = createRandom(depth, targetSize)
|
127
|
+
attempts++
|
128
|
+
|
129
|
+
// If we're still under size but have complex structure, pad with a simple array
|
130
|
+
if (totalSize < targetSize - 200 && attempts < maxAttempts) {
|
131
|
+
const padding = []
|
132
|
+
const remainingSize = targetSize - totalSize
|
133
|
+
const paddingLength = Math.floor(remainingSize / 3)
|
134
|
+
|
135
|
+
for (let i = 0; i < paddingLength && totalSize < targetSize; i++) {
|
136
|
+
padding.push(counter++)
|
137
|
+
totalSize += 3 // Rough estimate for numbers and commas
|
138
|
+
}
|
139
|
+
|
140
|
+
// Add padding to json if it's an object
|
141
|
+
if (typeof json === "object" && !Array.isArray(json)) {
|
142
|
+
json.padding = padding
|
143
|
+
} else if (Array.isArray(json)) {
|
144
|
+
json.push(...padding)
|
145
|
+
}
|
146
|
+
}
|
147
|
+
} while (totalSize < targetSize - 500 && attempts < maxAttempts)
|
148
|
+
|
149
|
+
return json
|
150
|
+
}
|
151
|
+
function randomPrimitive() {
|
152
|
+
const r = Math.random()
|
153
|
+
if (r < 0.25) return Math.floor(Math.random() * 101)
|
154
|
+
else if (r < 0.5) return randomString(Math.floor(Math.random() * 10) + 1)
|
155
|
+
else if (r < 0.75) return Math.random() < 0.5
|
156
|
+
else return null
|
157
|
+
}
|
158
|
+
|
159
|
+
function randomString(length) {
|
160
|
+
const chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
161
|
+
let s = ""
|
162
|
+
for (let i = 0; i < length; i++) {
|
163
|
+
s += chars.charAt(Math.floor(Math.random() * chars.length))
|
164
|
+
}
|
165
|
+
return s
|
166
|
+
}
|
167
|
+
|
168
|
+
function createJSON(depth = 0) {
|
169
|
+
const maxDepth = 3
|
170
|
+
if (depth >= maxDepth) {
|
171
|
+
return randomPrimitive()
|
172
|
+
}
|
173
|
+
|
174
|
+
if (Math.random() < 0.5) {
|
175
|
+
const numKeys = Math.floor(Math.random() * 4) + 1
|
176
|
+
const obj = {}
|
177
|
+
for (let i = 0; i < numKeys; i++) {
|
178
|
+
const key = randomString(Math.floor(Math.random() * 6) + 1)
|
179
|
+
obj[key] = createJSON(depth + 1)
|
180
|
+
}
|
181
|
+
return obj
|
182
|
+
} else {
|
183
|
+
const len = Math.floor(Math.random() * 4) + 1
|
184
|
+
const arr = []
|
185
|
+
for (let i = 0; i < len; i++) {
|
186
|
+
arr.push(createJSON(depth + 1))
|
187
|
+
}
|
188
|
+
return arr
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
function toB(uint8Array) {
|
193
|
+
return Array.from(uint8Array)
|
194
|
+
.map(byte => byte.toString(2).padStart(8, "0"))
|
195
|
+
.join("")
|
196
|
+
}
|
197
|
+
|
198
|
+
let u = new u8()
|
199
|
+
export default function Home({}) {
|
200
|
+
const [jsons, setJSONs] = useState("")
|
201
|
+
const [zk, setZK] = useState([])
|
202
|
+
const [msg, setMSG] = useState([])
|
203
|
+
const [cbor, setCBOR] = useState([])
|
204
|
+
const [bson, setBSON] = useState([])
|
205
|
+
const [json, setJSON] = useState([])
|
206
|
+
useEffect(() => {
|
207
|
+
let jsons = []
|
208
|
+
for (let i = 0; i < 10; i++) jsons.push(createJSON2())
|
209
|
+
setJSONs(jsons)
|
210
|
+
}, [])
|
211
|
+
useEffect(() => {
|
212
|
+
let _zk = []
|
213
|
+
let _msg = []
|
214
|
+
let _cbor = []
|
215
|
+
let _bson = []
|
216
|
+
let _json = []
|
217
|
+
for (const v of jsons) {
|
218
|
+
const encoded = encode_x(v, u)
|
219
|
+
const zklen = encoded.length
|
220
|
+
const encoded2 = enc(v)
|
221
|
+
const msglen = encoded2.byteLength
|
222
|
+
_msg.push({ len: msglen, diff: msglen - zklen })
|
223
|
+
_zk.push({ len: zklen, rate: msglen / zklen })
|
224
|
+
const encoded3 = enc2(v)
|
225
|
+
const cborlen = encoded3.byteLength
|
226
|
+
_cbor.push({ len: cborlen, diff: cborlen - zklen })
|
227
|
+
const encoded4 = BSON.serialize(Array.isArray(v) ? { "": v } : v)
|
228
|
+
const bsonlen = encoded4.byteLength
|
229
|
+
_bson.push({ len: bsonlen, diff: bsonlen - zklen })
|
230
|
+
const encoded5 = JSON.stringify(v)
|
231
|
+
const jsonlen = encoded5.length
|
232
|
+
_json.push({ len: jsonlen, diff: jsonlen - zklen })
|
233
|
+
}
|
234
|
+
setZK(_zk)
|
235
|
+
setMSG(_msg)
|
236
|
+
setCBOR(_cbor)
|
237
|
+
setBSON(_bson)
|
238
|
+
setJSON(_json)
|
239
|
+
}, [jsons])
|
240
|
+
return (
|
241
|
+
<Flex justify="center" fontSize="12px">
|
242
|
+
<Box w="1000px">
|
243
|
+
<Flex my={2} fontSize="16px">
|
244
|
+
<Box>zkJSON v2 Benchmark</Box>
|
245
|
+
<Box flex={1} />
|
246
|
+
<Box
|
247
|
+
as="a"
|
248
|
+
target="_blank"
|
249
|
+
href="https://github.com/weavedb/zkjson/blob/master/docs/zkjson-v2.md"
|
250
|
+
css={{ textDecoration: "underline" }}
|
251
|
+
>
|
252
|
+
Spec
|
253
|
+
</Box>
|
254
|
+
</Flex>
|
255
|
+
<Flex>
|
256
|
+
<Flex
|
257
|
+
onClick={() => {
|
258
|
+
let jsons = []
|
259
|
+
for (let i = 0; i < 10; i++) jsons.push(createJSON2())
|
260
|
+
setJSONs(jsons)
|
261
|
+
}}
|
262
|
+
my={4}
|
263
|
+
px={4}
|
264
|
+
py={2}
|
265
|
+
css={{
|
266
|
+
bg: "#eee",
|
267
|
+
borderRadius: "3px",
|
268
|
+
cursor: "pointer",
|
269
|
+
_hover: { opacity: 0.75 },
|
270
|
+
}}
|
271
|
+
>
|
272
|
+
Generate Pattened JSON
|
273
|
+
</Flex>
|
274
|
+
<Flex
|
275
|
+
ml={4}
|
276
|
+
onClick={() => {
|
277
|
+
let jsons = []
|
278
|
+
for (let i = 0; i < 10; i++) jsons.push(createJSON())
|
279
|
+
setJSONs(jsons)
|
280
|
+
}}
|
281
|
+
my={4}
|
282
|
+
px={4}
|
283
|
+
py={2}
|
284
|
+
css={{
|
285
|
+
bg: "#eee",
|
286
|
+
borderRadius: "3px",
|
287
|
+
cursor: "pointer",
|
288
|
+
_hover: { opacity: 0.75 },
|
289
|
+
}}
|
290
|
+
>
|
291
|
+
Generate Random JSON
|
292
|
+
</Flex>
|
293
|
+
</Flex>
|
294
|
+
<Flex mb={4}>
|
295
|
+
<Flex w="100px" p={2} justify="flex-end">
|
296
|
+
zkJSON
|
297
|
+
</Flex>
|
298
|
+
<Flex w="100px" p={2} justify="flex-end">
|
299
|
+
MsgPack
|
300
|
+
</Flex>
|
301
|
+
<Flex w="100px" p={2} justify="flex-end">
|
302
|
+
CBOR
|
303
|
+
</Flex>
|
304
|
+
<Flex w="100px" p={2} justify="flex-end">
|
305
|
+
BSON
|
306
|
+
</Flex>
|
307
|
+
<Flex w="100px" p={2} justify="flex-end">
|
308
|
+
JSON
|
309
|
+
</Flex>
|
310
|
+
<Flex w="500px" p={2} ml={6}>
|
311
|
+
Encoded Data
|
312
|
+
</Flex>
|
313
|
+
</Flex>
|
314
|
+
{range(0, zk.length).map(i => (
|
315
|
+
<Flex p={2}>
|
316
|
+
<Flex
|
317
|
+
w="100px"
|
318
|
+
px={2}
|
319
|
+
justify="flex-end"
|
320
|
+
align="flex-end"
|
321
|
+
direction="column"
|
322
|
+
>
|
323
|
+
<Box>{zk[i].len}</Box>
|
324
|
+
<Box fontSize="12px" color="#5137C5">
|
325
|
+
{Math.round(zk[i].rate)}x
|
326
|
+
</Box>
|
327
|
+
</Flex>
|
328
|
+
<Flex
|
329
|
+
w="100px"
|
330
|
+
px={2}
|
331
|
+
justify="flex-end"
|
332
|
+
align="flex-end"
|
333
|
+
direction="column"
|
334
|
+
>
|
335
|
+
<Box>{msg[i].len}</Box>
|
336
|
+
<Box
|
337
|
+
fontSize="12px"
|
338
|
+
color={msg[i].diff > 0 ? "crimson" : "#5137C5"}
|
339
|
+
>
|
340
|
+
{msg[i].diff < 0 ? "" : "+"}
|
341
|
+
{msg[i].diff}
|
342
|
+
</Box>
|
343
|
+
</Flex>
|
344
|
+
<Flex
|
345
|
+
w="100px"
|
346
|
+
px={2}
|
347
|
+
justify="flex-end"
|
348
|
+
align="flex-end"
|
349
|
+
direction="column"
|
350
|
+
>
|
351
|
+
<Box>{cbor[i].len}</Box>
|
352
|
+
<Box
|
353
|
+
fontSize="12px"
|
354
|
+
color={cbor[i].diff > 0 ? "crimson" : "#5137C5"}
|
355
|
+
>
|
356
|
+
{cbor[i].diff < 0 ? "" : "+"}
|
357
|
+
{cbor[i].diff}
|
358
|
+
</Box>
|
359
|
+
</Flex>
|
360
|
+
<Flex
|
361
|
+
w="100px"
|
362
|
+
px={2}
|
363
|
+
justify="flex-end"
|
364
|
+
align="flex-end"
|
365
|
+
direction="column"
|
366
|
+
>
|
367
|
+
<Box>{bson[i].len}</Box>
|
368
|
+
<Box
|
369
|
+
fontSize="12px"
|
370
|
+
color={bson[i].diff > 0 ? "crimson" : "#5137C5"}
|
371
|
+
>
|
372
|
+
{bson[i].diff < 0 ? "" : "+"}
|
373
|
+
{bson[i].diff}
|
374
|
+
</Box>
|
375
|
+
</Flex>
|
376
|
+
<Flex
|
377
|
+
w="100px"
|
378
|
+
px={2}
|
379
|
+
justify="flex-end"
|
380
|
+
align="flex-end"
|
381
|
+
direction="column"
|
382
|
+
>
|
383
|
+
<Box>{json[i].len}</Box>
|
384
|
+
<Box
|
385
|
+
fontSize="12px"
|
386
|
+
color={json[i].diff > 0 ? "crimson" : "#5137C5"}
|
387
|
+
>
|
388
|
+
{json[i].diff < 0 ? "" : "+"}
|
389
|
+
{json[i].diff}
|
390
|
+
</Box>
|
391
|
+
</Flex>
|
392
|
+
<Flex
|
393
|
+
ml={6}
|
394
|
+
px={2}
|
395
|
+
w="500px"
|
396
|
+
color="#666"
|
397
|
+
css={{
|
398
|
+
overflow: "hidden",
|
399
|
+
fontSize: "10px",
|
400
|
+
whiteSpace: "nowrap",
|
401
|
+
textOverflow: "ellipsis",
|
402
|
+
}}
|
403
|
+
>
|
404
|
+
{JSON.stringify(jsons[i])}
|
405
|
+
</Flex>
|
406
|
+
</Flex>
|
407
|
+
))}
|
408
|
+
<Flex mb={4}>
|
409
|
+
<Flex w="200px" py={2} justify="flex-end" color="#5137C5">
|
410
|
+
<u>x Times Smaller than MsgPack</u>
|
411
|
+
</Flex>
|
412
|
+
<Flex w="300px" py={2} justify="flex-end" color="crimson">
|
413
|
+
<u>+Bytes Bigger than zkJSON</u>
|
414
|
+
</Flex>
|
415
|
+
<Flex w="500px" p={2} ml={6}></Flex>
|
416
|
+
</Flex>
|
417
|
+
<Box my={4}>
|
418
|
+
<Box my={1}>
|
419
|
+
MessagePack is a self-contained JSON encoding algorithm that
|
420
|
+
produces the smallest encoded data sizes today.
|
421
|
+
</Box>
|
422
|
+
<Box my={1}>
|
423
|
+
zkJSON beats MessagePack by far in compression rate on pattened
|
424
|
+
JSON, sometimes resulting in more than 20x smaller sizes.
|
425
|
+
</Box>
|
426
|
+
<Box my={1}>
|
427
|
+
zkJSON beats MessagePack in 90% of cases with completely randomized
|
428
|
+
JSON, and almost ties in the rest of the cases.
|
429
|
+
</Box>
|
430
|
+
<Box my={1}>
|
431
|
+
CBOR produces slightly bigger sizes than MessagePack, BSON produces
|
432
|
+
even bigger sizes than the original JSON.
|
433
|
+
</Box>
|
434
|
+
</Box>
|
435
|
+
</Box>
|
436
|
+
</Flex>
|
437
|
+
)
|
438
|
+
}
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
|