snarkjs/build/snarkjs.min.js

11 lines
412 KiB
JavaScript
Raw Normal View History

2022-01-30 19:58:33 +03:00
var snarkjs=function(t){"use strict";const e=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];function a(t,e){return e&&10!=e?16==e?"0x"==t.slice(0,2)?BigInt(t):BigInt("0x"+t):void 0:BigInt(t)}const i=a;function o(t,e){return BigInt(t)<<BigInt(e)}function n(t,e){return BigInt(t)>>BigInt(e)}const r=o,c=n;var l=Object.freeze({__proto__:null,fromString:a,e:i,fromArray:function(t,e){let a=BigInt(0);e=BigInt(e);for(let i=0;i<t.length;i++)a=a*e+BigInt(t[i]);return a},bitLength:function(t){const a=t.toString(16);return 4*(a.length-1)+e[parseInt(a[0],16)]},isNegative:function(t){return BigInt(t)<BigInt(0)},isZero:function(t){return!t},shiftLeft:o,shiftRight:n,shl:r,shr:c,isOdd:function(t){return(BigInt(t)&BigInt(1))==BigInt(1)},naf:function(t){let e=BigInt(t);const a=[];for(;e;){if(e&BigInt(1)){const t=2-Number(e%BigInt(4));a.push(t),e-=BigInt(t)}else a.push(0);e>>=BigInt(1)}return a},bits:function(t){let e=BigInt(t);const a=[];for(;e;)e&BigInt(1)?a.push(1):a.push(0),e>>=BigInt(1);return a},toNumber:function(t){if(t>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("Number too big");return Number(t)},toArray:function(t,e){const a=[];let i=BigInt(t);for(e=BigInt(e);i;)a.unshift(Number(i%e)),i/=e;return a},add:function(t,e){return BigInt(t)+BigInt(e)},sub:function(t,e){return BigInt(t)-BigInt(e)},neg:function(t){return-BigInt(t)},mul:function(t,e){return BigInt(t)*BigInt(e)},square:function(t){return BigInt(t)*BigInt(t)},pow:function(t,e){return BigInt(t)**BigInt(e)},exp:function(t,e){return BigInt(t)**BigInt(e)},abs:function(t){return BigInt(t)>=0?BigInt(t):-BigInt(t)},div:function(t,e){return BigInt(t)/BigInt(e)},mod:function(t,e){return BigInt(t)%BigInt(e)},eq:function(t,e){return BigInt(t)==BigInt(e)},neq:function(t,e){return BigInt(t)!=BigInt(e)},lt:function(t,e){return BigInt(t)<BigInt(e)},gt:function(t,e){return BigInt(t)>BigInt(e)},leq:function(t,e){return BigInt(t)<=BigInt(e)},geq:function(t,e){return BigInt(t)>=BigInt(e)},band:function(t,e){return BigInt(t)&BigInt(e)},bor:function(t,e){return BigInt(t)|BigInt(e)},bxor:function(t,e){return BigInt(t)^BigInt(e)},land:function(t,e){return BigInt(t)&&BigInt(e)},lor:function(t,e){return BigInt(t)||BigInt(e)},lnot:function(t){return!BigInt(t)}}),s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function d(t){var e={exports:{}};return t(e,e.exports),e.exports}var u=d((function(t){var e=function(t){var a=1e7,i=9007199254740992,o=g(i),n="0123456789abcdefghijklmnopqrstuvwxyz",r="function"==typeof BigInt;function c(t,e,a,i){return void 0===t?c[0]:void 0!==e&&(10!=+e||a)?K(t,e,a,i):Z(t)}function l(t,e){this.value=t,this.sign=e,this.isSmall=!1}function s(t){this.value=t,this.sign=t<0,this.isSmall=!0}function d(t){this.value=t}function u(t){return-i<t&&t<i}function g(t){return t<1e7?[t]:t<1e14?[t%1e7,Math.floor(t/1e7)]:[t%1e7,Math.floor(t/1e7)%1e7,Math.floor(t/1e14)]}function f(t){_(t);var e=t.length;if(e<4&&S(t,o)<0)switch(e){case 0:return 0;case 1:return t[0];case 2:return t[0]+t[1]*a;default:return t[0]+(t[1]+t[2]*a)*a}return t}function _(t){for(var e=t.length;0===t[--e];);t.length=e+1}function p(t){for(var e=new Array(t),a=-1;++a<t;)e[a]=0;return e}function h(t){return t>0?Math.floor(t):Math.ceil(t)}function m(t,e){var i,o,n=t.length,r=e.length,c=new Array(n),l=0,s=a;for(o=0;o<r;o++)l=(i=t[o]+e[o]+l)>=s?1:0,c[o]=i-l*s;for(;o<n;)l=(i=t[o]+l)===s?1:0,c[o++]=i-l*s;return l>0&&c.push(l),c}function L(t,e){return t.length>=e.length?m(t,e):m(e,t)}function w(t,e){var i,o,n=t.length,r=new Array(n),c=a;for(o=0;o<n;o++)i=t[o]-c+e,e=Math.floor(i/c),r[o]=i-e*c,e+=1;for(;e>0;)r[o++]=e%c,e=Math.floor(e/c);return r}function A(t,e){var i,o,n=t.length,r=e.length,c=new Array(n),l=0,s=a;for(i=0;i<r;i++)(o=t[i]-l-e[i])<0?(o+=s,l=1):l=0,c[i]=o;for(i=r;i<n;i++){if(!((o=t[i]-l)<0)){c[i++]=o;break}o+=s,c[i]=o}for(;i<n;i++)c[i]=t[i];return _(c),c}function b(t,e,i){var o,n,r=t.length,c=new Array(r),d=-e,u=a;for(o=0;o<r;o++)n=t[o]+d,d=Math.floor(n/u),n%=u,c[o]=n<0?n+u:n;return"number"==typeof(c=f(c))?(i&&(c=-c),new s(c)):new l(c,i)
2021-05-31 14:21:07 +03:00
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
* @version 0.8.0
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2015-2018
* @license MIT
*/
2022-01-19 23:59:11 +03:00
var Co=d((function(t){!function(){var e="input is invalid type",a="object"==typeof window,i=a?window:{};i.JS_SHA3_NO_WINDOW&&(a=!1);var o=!a&&"object"==typeof self;!i.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?i=s:o&&(i=self);var n=!i.JS_SHA3_NO_COMMON_JS&&t.exports,r=!i.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,c="0123456789abcdef".split(""),l=[4,1024,262144,67108864],d=[0,8,16,24],u=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],g=[224,256,384,512],f=[128,256],_=["hex","buffer","arrayBuffer","array","digest"],p={128:168,256:136};!i.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)}),!r||!i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(t){return"object"==typeof t&&t.buffer&&t.buffer.constructor===ArrayBuffer});for(var h=function(t,e,a){return function(i){return new G(t,e,t).update(i)[a]()}},m=function(t,e,a){return function(i,o){return new G(t,e,o).update(i)[a]()}},L=function(t,e,a){return function(e,i,o,n){return I["cshake"+t].update(e,i,o,n)[a]()}},w=function(t,e,a){return function(e,i,o,n){return I["kmac"+t].update(e,i,o,n)[a]()}},A=function(t,e,a,i){for(var o=0;o<_.length;++o){var n=_[o];t[n]=e(a,i,n)}return t},b=function(t,e){var a=h(t,e,"hex");return a.create=function(){return new G(t,e,t)},a.update=function(t){return a.create().update(t)},A(a,h,t,e)},y=[{name:"keccak",padding:[1,256,65536,16777216],bits:g,createMethod:b},{name:"sha3",padding:[6,1536,393216,100663296],bits:g,createMethod:b},{name:"shake",padding:[31,7936,2031616,520093696],bits:f,createMethod:function(t,e){var a=m(t,e,"hex");return a.create=function(a){return new G(t,e,a)},a.update=function(t,e){return a.create(e).update(t)},A(a,m,t,e)}},{name:"cshake",padding:l,bits:f,createMethod:function(t,e){var a=p[t],i=L(t,0,"hex");return i.create=function(i,o,n){return o||n?new G(t,e,i).bytepad([o,n],a):I["shake"+t].create(i)},i.update=function(t,e,a,o){return i.create(e,a,o).update(t)},A(i,L,t,e)}},{name:"kmac",padding:l,bits:f,createMethod:function(t,e){var a=p[t],i=w(t,0,"hex");return i.create=function(i,o,n){return new P(t,e,o).bytepad(["KMAC",n],a).bytepad([i],a)},i.update=function(t,e,a,o){return i.create(t,a,o).update(e)},A(i,w,t,e)}}],I={},C=[],F=0;F<y.length;++F)for(var x=y[F],v=x.bits,E=0;E<v.length;++E){var B=x.name+"_"+v[E];if(C.push(B),I[B]=x.createMethod(v[E],x.padding),"sha3"!==x.name){var S=x.name+v[E];C.push(S),I[S]=I[B]}}function G(t,e,a){this.blocks=[],this.s=[],this.padding=e,this.outputBits=a,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(t<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=a>>5,this.extraBytes=(31&a)>>3;for(var i=0;i<50;++i)this.s[i]=0}function P(t,e,a){G.call(this,t,e,a)}G.prototype.update=function(t){if(this.finalized)throw new Error("finalize already called");var a,i=typeof t;if("string"!==i){if("object"!==i)throw new Error(e);if(null===t)throw new Error(e);if(r&&t.constructor===ArrayBuffer)t=new Uint8Array(t);else if(!(Array.isArray(t)||r&&ArrayBuffer.isView(t)))throw new Error(e);a=!0}for(var o,n,c=this.blocks,l=this.byteCount,s=t.length,u=this.blockCount,g=0,f=this.s;g<s;){if(this.reset)for(this.reset=!1,c[0]=this.block,o=1;o<u+1;++o)c[o]=0;if(a)for(o=this.start;g<s&&o<l;++g)c[o>>2]|=t[g]<<d[3&o++];else for(o=this.start;g<s&&o<l;++g)(n=t.charCodeAt(g))<128?c[o>>2]|=n<<d[3&o++]:n<2048?(c[o>>2]|=(192|n>>6)<<d[3&o++],c[o>>2]|=(128|63&n)<<d[3&o++]):n<55296||n>=57344?(c[o>>2]|=(224|n>>12)<<d[3&o++],c[o>>2]|=(128|n>>6&63)<<d[3&o++],c[o>>2]|=(128|63&n)<<d[3&o++]):(n=65536+((1023&n)<<10|1023&t.charCodeAt(++g)),c[o>>2]|=(240|n>>18)<<d[3&o++],c[o>>2]|=(128|n>>12&63)<<d[3&o++],c[o>>2]|=(128|n>>6&63)<<d[3&o++],c[o>>2]|=(128|6