snarkjs/build/snarkjs.min.js

11 lines
694 KiB
JavaScript
Raw Normal View History

2021-09-02 23:29:06 +03:00
var snarkjs=function(A){"use strict";const I=[0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4];function t(A,I){return I&&10!=I?16==I?"0x"==A.slice(0,2)?BigInt(A):BigInt("0x"+A):void 0:BigInt(A)}const i=t;function g(A,I){return BigInt(A)<<BigInt(I)}function e(A,I){return BigInt(A)>>BigInt(I)}const C=g,n=e;var Q=Object.freeze({__proto__:null,fromString:t,e:i,fromArray:function(A,I){let t=BigInt(0);I=BigInt(I);for(let i=0;i<A.length;i++)t=t*I+BigInt(A[i]);return t},bitLength:function(A){const t=A.toString(16);return 4*(t.length-1)+I[parseInt(t[0],16)]},isNegative:function(A){return BigInt(A)<BigInt(0)},isZero:function(A){return!A},shiftLeft:g,shiftRight:e,shl:C,shr:n,isOdd:function(A){return(BigInt(A)&BigInt(1))==BigInt(1)},naf:function(A){let I=BigInt(A);const t=[];for(;I;){if(I&BigInt(1)){const A=2-Number(I%BigInt(4));t.push(A),I-=BigInt(A)}else t.push(0);I>>=BigInt(1)}return t},bits:function(A){let I=BigInt(A);const t=[];for(;I;)I&BigInt(1)?t.push(1):t.push(0),I>>=BigInt(1);return t},toNumber:function(A){if(A>BigInt(Number.MAX_SAFE_INTEGER))throw new Error("Number too big");return Number(A)},toArray:function(A,I){const t=[];let i=BigInt(A);for(I=BigInt(I);i;)t.unshift(Number(i%I)),i/=I;return t},add:function(A,I){return BigInt(A)+BigInt(I)},sub:function(A,I){return BigInt(A)-BigInt(I)},neg:function(A){return-BigInt(A)},mul:function(A,I){return BigInt(A)*BigInt(I)},square:function(A){return BigInt(A)*BigInt(A)},pow:function(A,I){return BigInt(A)**BigInt(I)},exp:function(A,I){return BigInt(A)**BigInt(I)},abs:function(A){return BigInt(A)>=0?BigInt(A):-BigInt(A)},div:function(A,I){return BigInt(A)/BigInt(I)},mod:function(A,I){return BigInt(A)%BigInt(I)},eq:function(A,I){return BigInt(A)==BigInt(I)},neq:function(A,I){return BigInt(A)!=BigInt(I)},lt:function(A,I){return BigInt(A)<BigInt(I)},gt:function(A,I){return BigInt(A)>BigInt(I)},leq:function(A,I){return BigInt(A)<=BigInt(I)},geq:function(A,I){return BigInt(A)>=BigInt(I)},band:function(A,I){return BigInt(A)&BigInt(I)},bor:function(A,I){return BigInt(A)|BigInt(I)},bxor:function(A,I){return BigInt(A)^BigInt(I)},land:function(A,I){return BigInt(A)&&BigInt(I)},lor:function(A,I){return BigInt(A)||BigInt(I)},lnot:function(A){return!BigInt(A)}}),B="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function r(A){var I={exports:{}};return A(I,I.exports),I.exports}var o=r((function(A){var I=function(A){var t=1e7,i=9007199254740992,g=E(i),e="0123456789abcdefghijklmnopqrstuvwxyz",C="function"==typeof BigInt;function n(A,I,t,i){return void 0===A?n[0]:void 0!==I&&(10!=+I||t)?O(A,I,t,i):z(A)}function Q(A,I){this.value=A,this.sign=I,this.isSmall=!1}function B(A){this.value=A,this.sign=A<0,this.isSmall=!0}function r(A){this.value=A}function o(A){return-i<A&&A<i}function E(A){return A<1e7?[A]:A<1e14?[A%1e7,Math.floor(A/1e7)]:[A%1e7,Math.floor(A/1e7)%1e7,Math.floor(A/1e14)]}function a(A){s(A);var I=A.length;if(I<4&&U(A,g)<0)switch(I){case 0:return 0;case 1:return A[0];case 2:return A[0]+A[1]*t;default:return A[0]+(A[1]+A[2]*t)*t}return A}function s(A){for(var I=A.length;0===A[--I];);A.length=I+1}function h(A){for(var I=new Array(A),t=-1;++t<A;)I[t]=0;return I}function f(A){return A>0?Math.floor(A):Math.ceil(A)}function w(A,I){var i,g,e=A.length,C=I.length,n=new Array(e),Q=0,B=t;for(g=0;g<C;g++)Q=(i=A[g]+I[g]+Q)>=B?1:0,n[g]=i-Q*B;for(;g<e;)Q=(i=A[g]+Q)===B?1:0,n[g++]=i-Q*B;return Q>0&&n.push(Q),n}function D(A,I){return A.length>=I.length?w(A,I):w(I,A)}function c(A,I){var i,g,e=A.length,C=new Array(e),n=t;for(g=0;g<e;g++)i=A[g]-n+I,I=Math.floor(i/n),C[g]=i-I*n,I+=1;for(;I>0;)C[g++]=I%n,I=Math.floor(I/n);return C}function u(A,I){var i,g,e=A.length,C=I.length,n=new Array(e),Q=0,B=t;for(i=0;i<C;i++)(g=A[i]-Q-I[i])<0?(g+=B,Q=1):Q=0,n[i]=g;for(i=C;i<e;i++){if(!((g=A[i]-Q)<0)){n[i++]=g;break}g+=B,n[i]=g}for(;i<e;i++)n[i]=A[i];return s(n),n}function l(A,I,i){var g,e,C=A.length,n=new Array(C),r=-I,o=t;for(g=0;g<C;g++)e=A[g]+r,r=Math.floor(e/o),e%=o,n[g]=e<0?e+o:e;return"number"==typeof(n=a(n))?(i&&(n=-n),new B(n)):new Q(n,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
*/
var YC=r((function(A){!function(){var I="input is invalid type",t="object"==typeof window,i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var g=!t&&"object"==typeof self;!i.JS_SHA3_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node?i=B:g&&(i=self);var e=!i.JS_SHA3_NO_COMMON_JS&&A.exports,C=!i.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!=typeof ArrayBuffer,n="0123456789abcdef".split(""),Q=[4,1024,262144,67108864],r=[0,8,16,24],o=[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],E=[224,256,384,512],a=[128,256],s=["hex","buffer","arrayBuffer","array","digest"],h={128:168,256:136};!i.JS_SHA3_NO_NODE_JS&&Array.isArray||(Array.isArray=function(A){return"[object Array]"===Object.prototype.toString.call(A)}),!C||!i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView||(ArrayBuffer.isView=function(A){return"object"==typeof A&&A.buffer&&A.buffer.constructor===ArrayBuffer});for(var f=function(A,I,t){return function(i){return new b(A,I,A).update(i)[t]()}},w=function(A,I,t){return function(i,g){return new b(A,I,g).update(i)[t]()}},D=function(A,I,t){return function(I,i,g,e){return p["cshake"+A].update(I,i,g,e)[t]()}},c=function(A,I,t){return function(I,i,g,e){return p["kmac"+A].update(I,i,g,e)[t]()}},u=function(A,I,t,i){for(var g=0;g<s.length;++g){var e=s[g];A[e]=I(t,i,e)}return A},l=function(A,I){var t=f(A,I,"hex");return t.create=function(){return new b(A,I,A)},t.update=function(A){return t.create().update(A)},u(t,f,A,I)},y=[{name:"keccak",padding:[1,256,65536,16777216],bits:E,createMethod:l},{name:"sha3",padding:[6,1536,393216,100663296],bits:E,createMethod:l},{name:"shake",padding:[31,7936,2031616,520093696],bits:a,createMethod:function(A,I){var t=w(A,I,"hex");return t.create=function(t){return new b(A,I,t)},t.update=function(A,I){return t.create(I).update(A)},u(t,w,A,I)}},{name:"cshake",padding:Q,bits:a,createMethod:function(A,I){var t=h[A],i=D(A,0,"hex");return i.create=function(i,g,e){return g||e?new b(A,I,i).bytepad([g,e],t):p["shake"+A].create(i)},i.update=function(A,I,t,g){return i.create(I,t,g).update(A)},u(i,D,A,I)}},{name:"kmac",padding:Q,bits:a,createMethod:function(A,I){var t=h[A],i=c(A,0,"hex");return i.create=function(i,g,e){return new L(A,I,g).bytepad(["KMAC",e],t).bytepad([i],t)},i.update=function(A,I,t,g){return i.create(A,t,g).update(I)},u(i,c,A,I)}}],p={},F=[],M=0;M<y.length;++M)for(var m=y[M],d=m.bits,G=0;G<d.length;++G){var H=m.name+"_"+d[G];if(F.push(H),p[H]=m.createMethod(d[G],m.padding),"sha3"!==m.name){var U=m.name+d[G];F.push(U),p[U]=p[H]}}function b(A,I,t){this.blocks=[],this.s=[],this.padding=I,this.outputBits=t,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(A<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=t>>5,this.extraBytes=(31&t)>>3;for(var i=0;i<50;++i)this.s[i]=0}function L(A,I,t){b.call(this,A,I,t)}b.prototype.update=function(A){if(this.finalized)throw new Error("finalize already called");var t,i=typeof A;if("string"!==i){if("object"!==i)throw new Error(I);if(null===A)throw new Error(I);if(C&&A.constructor===ArrayBuffer)A=new Uint8Array(A);else if(!(Array.isArray(A)||C&&ArrayBuffer.isView(A)))throw new Error(I);t=!0}for(var g,e,n=this.blocks,Q=this.byteCount,B=A.length,o=this.blockCount,E=0,a=this.s;E<B;){if(this.reset)for(this.reset=!1,n[0]=this.block,g=1;g<o+1;++g)n[g]=0;if(t)for(g=this.start;E<B&&g<Q;++E)n[g>>2]|=A[E]<<r[3&g++];else for(g=this.start;E<B&&g<Q;++E)(e=A.charCodeAt(E))<128?n[g>>2]|=e<<r[3&g++]:e<2048?(n[g>>2]|=(192|e>>6)<<r[3&g++],n[g>>2]|=(128|63&e)<<r[3&g++]):e<55296||e>=57344?(n[g>>2]|=(224|e>>12)<<r[3&g++],n[g>>2]|=(128|e>>6&63)<<r[3&g++],n[g>>2]|=(128|63&e)<<r[3&g++]):(e=65536+((1023&e)<<10|1023&A.charCodeAt(++E)),n[g>>2]|=(240|e>>18)<<r[3&g++],n[g>>2]|=(128|e>>12&63)<<r[3&g++],n[g>>2]|=(128|e>>6&63)<<r[3&g++],n[g>>2]|=(128|6