// npm package
zkjson
Zero Knowledge Provable JSON
versions
65
maintainers
1
first publish
2024-01-16
publisher
asteroiddao
tarball
3,094,858 B
AUTO-PUBLISHED·1 version indexed·latest published 2026-05-27
// publisher campaignby asteroiddao
9 caught packages from this accountThis is not an isolated catch. The same publisher has shipped 8 other packages that our pipeline flagged — the shape of a coordinated campaign, not a one-off. Each link below opens that sibling's analysis.
// offending code· @0.8.6· 3 files flagged
- @0.8.6··AUTO-PUBLISHED·publisher: asteroiddaoheuristic 75/100static flags 1llm skippedmature-packageosv-flagged:MAL-2026-4739hex-decode
// offending code· 3 files flaggedpatterns: 1
--- package/src/db.js (excerpt) --- import newMemEmptyTrie from "./newMemEmptyTrie.js" import { groth16 } from "snarkjs" import { is, indexOf, range, isNil } from "ramda" import { pad, toSignal, encode, toIndex } from "./encoder.js" import Collection from "./collection.js" const to64 = hash => { const n = BigInt(hash) let hex = n.toString(16) if (hex.length % 2) hex = "0" + hex const buf = Buffer.from(hex, "hex") return buf.toString("base64") } export default class DB { constructor({ size_val = 8, size_path = 4, level = 168, size_json = 256, size_txs = 10, level_col = 8, wasm, zkey, wasmRU, zkeyRU, }) { this.wasm = wasm this.zkey = zkey this.wasmRU = wasmRU this.zkeyRU = zkeyRU this.level_col = level_col this.size_val = size_val this.size_path = size_path this.level = level this.size_json = size_json this.size_txs = size_txs this.count = 0 this.ids = [] } async init() { this.tree = await newMemEmptyTrie() this.cols = [] } parse(res, tree, level) { const isOld0 = res.isOld0 ? "1" : "0" const oldRoot = tree.F.toObject(res.oldRoot).toString() const newRoot = tree.F.toObject(res.newRoot).toString() const oldKey = res.isOld0 ? "0" : tree.F.toObject(res.oldKey).toString() const oldValue = res.isOld0 ? "0" : tree.F.toObject(res.oldValue).toString() let siblings = res.siblings for (let i = 0; i < siblings.length; i++) siblings[i] = tree.F.toObject(siblings[i]) w --- package/src/db_tree.js (excerpt) --- import newMemEmptyTrie from "./newMemEmptyTrie.js" import { is, indexOf, isNil } from "ramda" import Collection from "./collection_tree.js" import { toIndex } from "./encoder.js" const to64 = hash => { const n = BigInt(hash) let hex = n.toString(16) if (hex.length % 2) hex = "0" + hex const buf = Buffer.from(hex, "hex") return buf.toString("base64") } export default class DBTree { constructor({ size_json = 256, level_col = 24, size_val = 256, size_path = 32, level = 184, kv, }) { this.kv = kv this.level = level this.level_col = level_col this.size_json = size_json this.size_val = size_val this.size_path = size_path this.count = 0 this.ids = {} this.cols = [] } async init() { this.kvi = this.kv?.("db") this.tree = await newMemEmptyTrie(this.kvi) if (this.kvi) { const count = this.kvi.get("count") if (!isNil(count)) this.count = count } } hash(format) { const _hash = this.tree.F.toObject(this.tree.root) if (format === "base64") return to64(_hash.toString()) return _hash.toString() } async exists(num) { const ex = this.ids[num] || (await this.tree.find(num)).found if (ex) this.ids[num] = true return ex } async getID(num) { if (!isNil(num)) { if (await this.exists(num)) throw Error("id exists") return num } else { while (await this.exists(this.count)) this.count++ return this.count } } async addCol --- package/src/encoder.js (excerpt) --- import { clone, isNil, includes, splitEvery, flatten } from "ramda" const ops = { $eq: 10, $ne: 11, $gt: 12, $gte: 13, $lt: 14, $lte: 15, $in: 16, $nin: 17, $contains: 18, $contains_any: 19, $contains_all: 20, $contains_none: 21, } const opMap = {} for (let k in ops) opMap[ops[k]] = k const base64Map = { A: "00", B: "01", C: "02", D: "03", E: "04", F: "05", G: "06", H: "07", I: "08", J: "09", K: "10", L: "11", M: "12", N: "13", O: "14", P: "15", Q: "16", R: "17", S: "18", T: "19", U: "20", V: "21", W: "22", X: "23", Y: "24", Z: "25", a: "26", b: "27", c: "28", d: "29", e: "30", f: "31", g: "32", h: "33", i: "34", j: "35", k: "36", l: "37", m: "38", n: "39", o: "40", p: "41", q: "42", r: "43", s: "44", t: "45", u: "46", v: "47", w: "48", x: "49", y: "50", z: "51", 0: "52", 1: "53", 2: "54", 3: "55", 4: "56", 5: "57", 6: "58", 7: "59", 8: "60", 9: "61", "-": "62", _: "63", } let strMap = {} for (const k in base64Map) strMap[base64Map[k]] = k function pad(arr, max = 0) { arr = arr.map(n => n.toString()) for (let i = arr.length; i < max; i++) { arr.push("0") } return arr } function encodePath(path) { const parts = [] let str = "" let num = 0 for (const s of path) { if (num == 2 && !(s == "." || s == "[")) throw Error() if (s == ".") { if (num == 2) { num = 0 } else { part
