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/cjs/doc.js
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports["default"] = void 0;
|
7
|
+
var _snarkjs = require("snarkjs");
|
8
|
+
var _path = require("path");
|
9
|
+
var _ramda = require("ramda");
|
10
|
+
var _encoder = require("./encoder.js");
|
11
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
12
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
13
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
14
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
15
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
16
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
17
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
18
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
19
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
20
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
|
21
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
22
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
23
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
24
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
25
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
26
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
27
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
28
|
+
var Doc = exports["default"] = /*#__PURE__*/function () {
|
29
|
+
function Doc(_ref) {
|
30
|
+
var _ref$size_val = _ref.size_val,
|
31
|
+
size_val = _ref$size_val === void 0 ? 8 : _ref$size_val,
|
32
|
+
_ref$size_path = _ref.size_path,
|
33
|
+
size_path = _ref$size_path === void 0 ? 4 : _ref$size_path,
|
34
|
+
_ref$size_json = _ref.size_json,
|
35
|
+
size_json = _ref$size_json === void 0 ? 256 : _ref$size_json,
|
36
|
+
wasm = _ref.wasm,
|
37
|
+
zkey = _ref.zkey;
|
38
|
+
_classCallCheck(this, Doc);
|
39
|
+
this.size_val = size_val;
|
40
|
+
this.size_path = size_path;
|
41
|
+
this.size_json = size_json;
|
42
|
+
this.wasm = wasm;
|
43
|
+
this.zkey = zkey;
|
44
|
+
}
|
45
|
+
return _createClass(Doc, [{
|
46
|
+
key: "getInputs",
|
47
|
+
value: function () {
|
48
|
+
var _getInputs = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref2) {
|
49
|
+
var query, json, path;
|
50
|
+
return _regenerator().w(function (_context) {
|
51
|
+
while (1) switch (_context.n) {
|
52
|
+
case 0:
|
53
|
+
query = _ref2.query, json = _ref2.json, path = _ref2.path;
|
54
|
+
return _context.a(2, {
|
55
|
+
json: (0, _encoder.pad)((0, _encoder.toSignal)((0, _encoder.encode)(json)), this.size_json),
|
56
|
+
path: (0, _encoder.pad)((0, _encoder.toSignal)((0, _encoder.encodePath)(path)), this.size_path),
|
57
|
+
val: (0, _ramda.isNil)(query) ? (0, _encoder.pad)((0, _encoder.toSignal)((0, _encoder.encodeVal)(this.getVal(json, path))), this.size_val) : (0, _encoder.pad)((0, _encoder.toSignal)((0, _encoder.encodeQuery)(query)), this.size_val)
|
58
|
+
});
|
59
|
+
}
|
60
|
+
}, _callee, this);
|
61
|
+
}));
|
62
|
+
function getInputs(_x) {
|
63
|
+
return _getInputs.apply(this, arguments);
|
64
|
+
}
|
65
|
+
return getInputs;
|
66
|
+
}()
|
67
|
+
}, {
|
68
|
+
key: "_getVal",
|
69
|
+
value: function _getVal(j, p) {
|
70
|
+
if (p.length === 0) {
|
71
|
+
return j;
|
72
|
+
} else {
|
73
|
+
var sp = p[0].split("[");
|
74
|
+
var _iterator = _createForOfIteratorHelper(sp),
|
75
|
+
_step;
|
76
|
+
try {
|
77
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
78
|
+
var v = _step.value;
|
79
|
+
if (/]$/.test(v)) {
|
80
|
+
j = j[v.replace(/]$/, "") * 1];
|
81
|
+
} else {
|
82
|
+
j = j[v];
|
83
|
+
}
|
84
|
+
}
|
85
|
+
} catch (err) {
|
86
|
+
_iterator.e(err);
|
87
|
+
} finally {
|
88
|
+
_iterator.f();
|
89
|
+
}
|
90
|
+
return this._getVal(j, p.slice(1));
|
91
|
+
}
|
92
|
+
}
|
93
|
+
}, {
|
94
|
+
key: "getVal",
|
95
|
+
value: function getVal(j, p) {
|
96
|
+
if (p === "") return j;
|
97
|
+
return this._getVal(j, p.split("."));
|
98
|
+
}
|
99
|
+
}, {
|
100
|
+
key: "genProof",
|
101
|
+
value: function () {
|
102
|
+
var _genProof = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref3) {
|
103
|
+
var json, path, query, inputs, _yield$groth16$fullPr, proof, publicSignals;
|
104
|
+
return _regenerator().w(function (_context2) {
|
105
|
+
while (1) switch (_context2.n) {
|
106
|
+
case 0:
|
107
|
+
json = _ref3.json, path = _ref3.path, query = _ref3.query;
|
108
|
+
_context2.n = 1;
|
109
|
+
return this.getInputs({
|
110
|
+
json: json,
|
111
|
+
path: path,
|
112
|
+
query: query
|
113
|
+
});
|
114
|
+
case 1:
|
115
|
+
inputs = _context2.v;
|
116
|
+
_context2.n = 2;
|
117
|
+
return _snarkjs.groth16.fullProve(inputs, this.wasm, this.zkey);
|
118
|
+
case 2:
|
119
|
+
_yield$groth16$fullPr = _context2.v;
|
120
|
+
proof = _yield$groth16$fullPr.proof;
|
121
|
+
publicSignals = _yield$groth16$fullPr.publicSignals;
|
122
|
+
return _context2.a(2, [].concat(_toConsumableArray(proof.pi_a.slice(0, 2)), _toConsumableArray(proof.pi_b[0].slice(0, 2).reverse()), _toConsumableArray(proof.pi_b[1].slice(0, 2).reverse()), _toConsumableArray(proof.pi_c.slice(0, 2)), _toConsumableArray(publicSignals)));
|
123
|
+
}
|
124
|
+
}, _callee2, this);
|
125
|
+
}));
|
126
|
+
function genProof(_x2) {
|
127
|
+
return _genProof.apply(this, arguments);
|
128
|
+
}
|
129
|
+
return genProof;
|
130
|
+
}()
|
131
|
+
}]);
|
132
|
+
}();
|