snarkjs/build/snarkjs.min.js

11 lines
621 KiB
JavaScript
Raw Normal View History

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