Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local a=type(package)=="table"and type(package.preload)=="table"and package.preload or{}local require=require;if type(require)~="function"then local b={}local c={}require=function(d)local e=c[d]if e~=nil then if e==b then error("loop or previous error loading module '"..d.."'",2)end;return e end;c[d]=b;local f=a[d]if f then e=f(d)else error("cannot load '"..d.."'",2)end;if e==nil then e=true end;c[d]=e;return e end end;a["urandom"]=function(...)local g=require("sha256")local h=os.pullEvent;local i=fs.open;local j=tostring(math.random())..tostring(os.epoch("utc"))local k=1024;local l="/.urandom"if fs.exists(l)then local m=fs.open(l,"rb")j=j..m.readAll()m.close()end;local n=g.digest(j)if not os.urandom then os.pullEvent=function(o)while true do local p={h()}local q=#j;j={j,p[1],tostring(p[2]),tostring(p[3]),tostring(p[4]),tostring(os.epoch("utc")),tostring({})}j=table.concat(j,"|")if#j>k then n=g.digest(j)j=tostring(n)end;if not o or o==p[1]then return unpack(p)end end end;fs.open=function(r,s)local t=fs.exists(r)and fs.getSize(r)or 0;j={j,r,s,tostring(t)}j=table.concat(j)os.queueEvent("file")os.pullEvent()local m=i(l,"wb")m.write(tostring(g.hmac("save",n)))m.close()n=g.digest(n)return i(r,s)end;os.urandom=function()os.queueEvent("random")os.pullEvent()local e=g.hmac("out",n)n=g.digest(n)return e end end end;a["sha256"]=function(...)local u=2^32;local v=bit32 and bit32.band or bit.band;local w=bit32 and bit32.bnot or bit.bnot;local bxor=bit32 and bit32.bxor or bit.bxor;local x=bit32 and bit32.lshift or bit.blshift;local y=unpack;local function z(A,B)local C=A/2^B;local D=C%1;return C-D+D*u end;local function E(F,G)local C=F/2^G;return C-C%1 end;local H={0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19}local I={0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967,0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2}local function J(K)local L,M=0,0;if 0xFFFFFFFF-L<K then M=M+1;L=K-(0xFFFFFFFF-L)-1 else L=L+K end;return M,L end;local function N(O,P)return x(O[P]or 0,24)+x(O[P+1]or 0,16)+x(O[P+2]or 0,8)+(O[P+3]or 0)end;local function Q(R)local S=#R;local T={}R[#R+1]=0x80;while#R%64~=56 do R[#R+1]=0 end;local U=math.ceil(#R/64)for P=1,U do T[P]={}for V=1,16 do T[P][V]=N(R,1+(P-1)*64+(V-1)*4)end end;T[U][15],T[U][16]=J(S*8)return T end;local function W(X,Y)for V=17,64 do local Z=X[V-15]local _=bxor(bxor(z(X[V-15],7),z(X[V-15],18)),E(X[V-15],3))local a0=bxor(bxor(z(X[V-2],17),z(X[V-2],19)),E(X[V-2],10))X[V]=(X[V-16]+_+X[V-7]+a0)%u end;local a1,B,a2,a3,a4,D,a5,a6=y(Y)for V=1,64 do local a7=bxor(bxor(z(a4,6),z(a4,11)),z(a4,25))local a8=bxor(v(a4,D),v(w(a4),a5))local a9=(a6+a7+a8+I[V]+X[V])%u;local aa=bxor(bxor(z(a1,2),z(a1,13)),z(a1,22))local ab=bxor(bxor(v(a1,B),v(a1,a2)),v(B,a2))local ac=(aa+ab)%u;a6,a5,D,a4,a3,a2,B,a1=a5,D,a4,(a3+a9)%u,a2,B,a1,(a9+ac)%u end;Y[1]=(Y[1]+a1)%u;Y[2]=(Y[2]+B)%u;Y[3]=(Y[3]+a2)%u;Y[4]=(Y[4]+a3)%u;Y[5]=(Y[5]+a4)%u;Y[6]=(Y[6]+D)%u;Y[7]=(Y[7]+a5)%u;Y[8]=(Y[8]+a6)%u;return Y end;local ad={__tostring=function(a1)return string.char(unpack(a1))end,__index={toHex=function(self,C)return"%02x":rep(#self):format(unpack(self))end,isEqual=function(self,ae)if type(ae)~="table"then return false end;if#self~=#ae then return false end;local af=0;for P=1,#self do af=bit32.bor(af,bxor(self[P],ae[P]))end;return af==0 end}}local function ag(ae,A)local B={}for P=1,A do B[(P-1)*4+1]=v(E(ae[P],24),0xFF)B[(P-1)*4+2]=v(E(ae[P],16),0xFF)B[(P-1)*4+3]=v(E(ae[P],8),0xFF)B[(P-1)*4+4]=v(ae[P],0xFF)end;return setmetatable(B,ad)end;local function ah(R)R=R or""R=type(R)=="string"and{R:byte(1,-1)}or R;R=Q(R)local Y={y(H)}for P=1,#R do Y=W(R[P],Y)end;return ag(Y,8)end;local function ai(R,aj)local R=type(R)=="table"and{y(R)}or{tostring(R):byte(1,-1)}local aj=type(aj)=="table"and{y(aj)}or{tostring(aj):byte(1,-1)}local ak=64;aj=#aj>ak and ah(aj)or aj;local al={}local am={}local an={}for P=1,ak do al[P]=bxor(0x36,aj[P]or 0)am[P]=bxor(0x5C,aj[P]or 0)end;for P=1,#R do al[ak+P]=R[P]end;al=ah(al)for P=1,ak do an[P]=am[P]an[ak+P]=al[P]end;return ah(an)end;local function ao(ap,aq,ar,as)local aq=type(aq)=="table"and aq or{tostring(aq):byte(1,-1)}local at=32;local as=as or 32;local au=1;local av={}while as>0 do local aw={}local ax={y(aq)}local ay=as>at and at or as;ax[#ax+1]=v(E(au,24),0xFF)ax[#ax+1]=v(E(au,16),0xFF)ax[#ax+1]=v(E(au,8),0xFF)ax[#ax+1]=v(au,0xFF)for V=1,ar do ax=ai(ax,ap)for az=1,ay do aw[az]=bxor(ax[az],aw[az]or 0)end;if V%200==0 then os.queueEvent("PBKDF2",V)coroutine.yield("PBKDF2")end end;as=as-ay;au=au+1;for az=1,ay do av[#av+1]=aw[az]end end;return setmetatable(av,ad)end;return{pbkdf2=ao,digest=ah,hmac=ai}end;a["fq"]=function(...)local A=0xffff;local aA=0x10000;local aB={1372,62520,47765,8105,45059,9616,65535,65535,65535,65535,65535,65532}local aC={1372,62520,47765,8105,45059,9616,65535,65535,65535,65535,65535,65532,0,0,0,0,0,0,0,0,0,0,0,0}local ad={__tostring=function(a1)return string.char(unpack(a1))end,__index={toHex=function(self,C)return"%02x":rep(#self):format(unpack(self))end,isEqual=function(self,ae)if type(ae)~="table"then return false end;if#self~=#ae then return false end;local af=0;for P=1,#self do af=bit32.bor(af,bxor(self[P],ae[P]))end;return af==0 end}}local function aD(a1,B)for P=1,12 do if a1[P]~=B[P]then return false end end;return true end;local function aE(a1,B)for P=12,1,-1 do if a1[P]>B[P]then return 1 elseif a1[P]<B[P]then return-1 end end;return 0 end;local function aF(a1,B)for P=24,1,-1 do if a1[P]>B[P]then return 1 elseif a1[P]<B[P]then return-1 end end;return 0 end;local function aG(aH)local e={}for P=0,11 do local aA=aH[P+1]%256;e[2*P+1]=aA;e[2*P+2]=(aH[P+1]-aA)/256 end;return setmetatable(e,ad)end;local function aI(aJ)local e={}for P=0,11 do e[P+1]=aJ[2*P+1]%256;e[P+1]=e[P+1]+aJ[2*P+2]*256 end;return e end;local function aK(a1,B)local aL=a1[1]-B[1]local aM=a1[2]-B[2]local aN=a1[3]-B[3]local aO=a1[4]-B[4]local aP=a1[5]-B[5]local aQ=a1[6]-B[6]local aR=a1[7]-B[7]local aS=a1[8]-B[8]local aT=a1[9]-B[9]local aU=a1[10]-B[10]local aV=a1[11]-B[11]local aW=a1[12]-B[12]if aL<0 then aM=aM-1;aL=aL+aA end;if aM<0 then aN=aN-1;aM=aM+aA end;if aN<0 then aO=aO-1;aN=aN+aA end;if aO<0 then aP=aP-1;aO=aO+aA end;if aP<0 then aQ=aQ-1;aP=aP+aA end;if aQ<0 then aR=aR-1;aQ=aQ+aA end;if aR<0 then aS=aS-1;aR=aR+aA end;if aS<0 then aT=aT-1;aS=aS+aA end;if aT<0 then aU=aU-1;aT=aT+aA end;if aU<0 then aV=aV-1;aU=aU+aA end;if aV<0 then aW=aW-1;aV=aV+aA end;local e={aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW}return e end;local function aX(a1)local e={unpack(a1)}if aE(e,aB)>=0 then e=aK(e,aB)end;return e end;local function aY(a1,B)local aL=a1[1]+B[1]local aM=a1[2]+B[2]local aN=a1[3]+B[3]local aO=a1[4]+B[4]local aP=a1[5]+B[5]local aQ=a1[6]+B[6]local aR=a1[7]+B[7]local aS=a1[8]+B[8]local aT=a1[9]+B[9]local aU=a1[10]+B[10]local aV=a1[11]+B[11]local aW=a1[12]+B[12]if aL>A then aM=aM+1;aL=aL-aA end;if aM>A then aN=aN+1;aM=aM-aA end;if aN>A then aO=aO+1;aN=aN-aA end;if aO>A then aP=aP+1;aO=aO-aA end;if aP>A then aQ=aQ+1;aP=aP-aA end;if aQ>A then aR=aR+1;aQ=aQ-aA end;if aR>A then aS=aS+1;aR=aR-aA end;if aS>A then aT=aT+1;aS=aS-aA end;if aT>A then aU=aU+1;aT=aT-aA end;if aU>A then aV=aV+1;aU=aU-aA end;if aV>A then aW=aW+1;aV=aV-aA end;local e={aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW}return aX(e)end;local function aZ(a1,B)local e=aK(a1,B)if e[12]<0 then e=aY(e,aB)end;return e end;local function a_(a1,B)local aL=a1[1]+B[1]local aM=a1[2]+B[2]local aN=a1[3]+B[3]local aO=a1[4]+B[4]local aP=a1[5]+B[5]local aQ=a1[6]+B[6]local aR=a1[7]+B[7]local aS=a1[8]+B[8]local aT=a1[9]+B[9]local aU=a1[10]+B[10]local aV=a1[11]+B[11]local aW=a1[12]+B[12]local b0=a1[13]+B[13]local b1=a1[14]+B[14]local b2=a1[15]+B[15]local b3=a1[16]+B[16]local b4=a1[17]+B[17]local b5=a1[18]+B[18]local b6=a1[19]+B[19]local b7=a1[20]+B[20]local b8=a1[21]+B[21]local b9=a1[22]+B[22]local ba=a1[23]+B[23]local bb=a1[24]+B[24]if aL>A then aM=aM+1;aL=aL-aA end;if aM>A then aN=aN+1;aM=aM-aA end;if aN>A then aO=aO+1;aN=aN-aA end;if aO>A then aP=aP+1;aO=aO-aA end;if aP>A then aQ=aQ+1;aP=aP-aA end;if aQ>A then aR=aR+1;aQ=aQ-aA end;if aR>A then aS=aS+1;aR=aR-aA end;if aS>A then aT=aT+1;aS=aS-aA end;if aT>A then aU=aU+1;aT=aT-aA end;if aU>A then aV=aV+1;aU=aU-aA end;if aV>A then aW=aW+1;aV=aV-aA end;if aW>A then b0=b0+1;aW=aW-aA end;if b0>A then b1=b1+1;b0=b0-aA end;if b1>A then b2=b2+1;b1=b1-aA end;if b2>A then b3=b3+1;b2=b2-aA end;if b3>A then b4=b4+1;b3=b3-aA end;if b4>A then b5=b5+1;b4=b4-aA end;if b5>A then b6=b6+1;b5=b5-aA end;if b6>A then b7=b7+1;b6=b6-aA end;if b7>A then b8=b8+1;b7=b7-aA end;if b8>A then b9=b9+1;b8=b8-aA end;if b9>A then ba=ba+1;b9=b9-aA end;if ba>A then bb=bb+1;ba=ba-aA end;local e={aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,ba,bb}return e end;local function bc(a1,B)local aL=a1[1]-B[1]local aM=a1[2]-B[2]local aN=a1[3]-B[3]local aO=a1[4]-B[4]local aP=a1[5]-B[5]local aQ=a1[6]-B[6]local aR=a1[7]-B[7]local aS=a1[8]-B[8]local aT=a1[9]-B[9]local aU=a1[10]-B[10]local aV=a1[11]-B[11]local aW=a1[12]-B[12]local b0=a1[13]-B[13]local b1=a1[14]-B[14]local b2=a1[15]-B[15]local b3=a1[16]-B[16]local b4=a1[17]-B[17]local b5=a1[18]-B[18]local b6=a1[19]-B[19]local b7=a1[20]-B[20]local b8=a1[21]-B[21]local b9=a1[22]-B[22]local ba=a1[23]-B[23]local bb=a1[24]-B[24]if aL<0 then aM=aM-1;aL=aL+aA end;if aM<0 then aN=aN-1;aM=aM+aA end;if aN<0 then aO=aO-1;aN=aN+aA end;if aO<0 then aP=aP-1;aO=aO+aA end;if aP<0 then aQ=aQ-1;aP=aP+aA end;if aQ<0 then aR=aR-1;aQ=aQ+aA end;if aR<0 then aS=aS-1;aR=aR+aA end;if aS<0 then aT=aT-1;aS=aS+aA end;if aT<0 then aU=aU-1;aT=aT+aA end;if aU<0 then aV=aV-1;aU=aU+aA end;if aV<0 then aW=aW-1;aV=aV+aA end;if aW<0 then b0=b0-1;aW=aW+aA end;if b0<0 then b1=b1-1;b0=b0+aA end;if b1<0 then b2=b2-1;b1=b1+aA end;if b2<0 then b3=b3-1;b2=b2+aA end;if b3<0 then b4=b4-1;b3=b3+aA end;if b4<0 then b5=b5-1;b4=b4+aA end;if b5<0 then b6=b6-1;b5=b5+aA end;if b6<0 then b7=b7-1;b6=b6+aA end;if b7<0 then b8=b8-1;b7=b7+aA end;if b8<0 then b9=b9-1;b8=b8+aA end;if b9<0 then ba=ba-1;b9=b9+aA end;if ba<0 then bb=bb-1;ba=ba+aA end;local e={aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,ba,bb}return e end;local function bd(a1,B)local be,bf,bg,bh,bi,bj,bk,bl,bm,bn,bo,bp=unpack(a1)local bq,br,bs,bt,bu,bv,bw,bx,by,bz,bA,bB=unpack(B)local aL=be*bq;local aM=be*br;aM=aM+bf*bq;local aN=be*bs;aN=aN+bf*br;aN=aN+bg*bq;local aO=be*bt;aO=aO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3+b2/aA;b3=b3-b3%1;b2=b2%aA;b4=b4+b3/aA;b4=b4-b4%1;b3=b3%aA;b5=b5+b4/aA;b5=b5-b5%1;b4=b4%aA;b6=b6+b5/aA;b6=b6-b6%1;b5=b5%aA;b7=b7+b6/aA;b7=b7-b7%1;b6=b6%aA;b8=b8+b7/aA;b8=b8-b8%1;b7=b7%aA;b9=b9+b8/aA;b9=b9-b9%1;b8=b8%aA;ba=ba+b9/aA;ba=ba-ba%1;b9=b9%aA;bb=bb+ba/aA;bb=bb-bb%1;ba=ba%aA;local e={aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,ba,bb}return e end;local function bC(a1)local e={unpack(a1)}while aF(e,aC)>=0 do local aC={unpack(aC)}local bD=a_(aC,aC)while aF(e,bD)>0 do aC=bD;bD=a_(bD,bD)end;e=bc(e,aC)end;e={unpack(e,1,12)}return e end;local function bE(a1,B)return bC(bd(a1,B))end;return{fromBytes=aI,bytes=aG,sub=aZ,mul=bE,eq=aD,cmp=aE}end;a["fp"]=function(...)local A=0xffff;local aA=0x10000;local bF={3,0,0,0,0,0,0,0,0,0,0,65533}local bG={21845,21845,21845,21845,21845,21845,21845,21845,21845,21845,21845,43690}local aM={44014,58358,19452,6484,45852,58974,63348,64806,65292,65454,65508,21512}local function aD(a1,B)for P=1,12 do if a1[P]~=B[P]then return false end end;return true end;local function aX(a1)local aL=a1[1]local aM=a1[2]local aN=a1[3]local aO=a1[4]local aP=a1[5]local aQ=a1[6]local aR=a1[7]local aS=a1[8]local aT=a1[9]local aU=a1[10]local aV=a1[11]local aW=a1[12]if aW<65533 or aW==65533 and aL<3 then return{unpack(a1)}end;aL=aL-3;aW=aW-65533;if aL<0 then aM=aM-1;aL=aL+aA end;if aM<0 then aN=aN-1;aM=aM+aA end;if aN<0 then aO=aO-1;aN=aN+aA end;if aO<0 then aP=aP-1;aO=aO+aA end;if aP<0 then aQ=aQ-1;aP=aP+aA end;if aQ<0 then aR=aR-1;aQ=aQ+aA end;if aR<0 then aS=aS-1;aR=aR+aA end;if aS<0 then aT=aT-1;aS=aS+aA end;if aT<0 then aU=aU-1;aT=aT+aA end;if aU<0 then aV=aV-1;aU=aU+aA end;if aV<0 then aW=aW-1;aV=aV+aA end;return{aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW}end;local function aY(a1,B)local aL=a1[1]+B[1]local aM=a1[2]+B[2]local aN=a1[3]+B[3]local aO=a1[4]+B[4]local aP=a1[5]+B[5]local aQ=a1[6]+B[6]local aR=a1[7]+B[7]local aS=a1[8]+B[8]local aT=a1[9]+B[9]local aU=a1[10]+B[10]local aV=a1[11]+B[11]local aW=a1[12]+B[12]if aL>A then aM=aM+1;aL=aL-aA end;if aM>A then aN=aN+1;aM=aM-aA end;if aN>A then aO=aO+1;aN=aN-aA end;if aO>A then aP=aP+1;aO=aO-aA end;if aP>A then aQ=aQ+1;aP=aP-aA end;if aQ>A then aR=aR+1;aQ=aQ-aA end;if aR>A then aS=aS+1;aR=aR-aA end;if aS>A then aT=aT+1;aS=aS-aA end;if aT>A then aU=aU+1;aT=aT-aA end;if aU>A then aV=aV+1;aU=aU-aA end;if aV>A then aW=aW+1;aV=aV-aA end;local e={aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW}return aX(e)end;local function bH(a1)local aL=a1[1]local aM=a1[2]local aN=a1[3]local aO=a1[4]local aP=a1[5]local aQ=a1[6]local aR=a1[7]local aS=a1[8]local aT=a1[9]local aU=a1[10]local aV=a1[11]local aW=a1[12]aL=aL/2;aL=aL-aL%1;aL=aL+aM%2*0x8000;aM=aM/2;aM=aM-aM%1;aM=aM+aN%2*0x8000;aN=aN/2;aN=aN-aN%1;aN=aN+aO%2*0x8000;aO=aO/2;aO=aO-aO%1;aO=aO+aP%2*0x8000;aP=aP/2;aP=aP-aP%1;aP=aP+aQ%2*0x8000;aQ=aQ/2;aQ=aQ-aQ%1;aQ=aQ+aR%2*0x8000;aR=aR/2;aR=aR-aR%1;aR=aR+aS%2*0x8000;aS=aS/2;aS=aS-aS%1;aS=aS+aT%2*0x8000;aT=aT/2;aT=aT-aT%1;aT=aT+aU%2*0x8000;aU=aU/2;aU=aU-aU%1;aU=aU+aV%2*0x8000;aV=aV/2;aV=aV-aV%1;aV=aV+aW%2*0x8000;aW=aW/2;aW=aW-aW%1;local e={aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW}return e end;local function aK(a1,B)local aL=a1[1]-B[1]local aM=a1[2]-B[2]local aN=a1[3]-B[3]local aO=a1[4]-B[4]local aP=a1[5]-B[5]local aQ=a1[6]-B[6]local aR=a1[7]-B[7]local aS=a1[8]-B[8]local aT=a1[9]-B[9]local aU=a1[10]-B[10]local aV=a1[11]-B[11]local aW=a1[12]-B[12]if aL<0 then aM=aM-1;aL=aL+aA end;if aM<0 then aN=aN-1;aM=aM+aA end;if aN<0 then aO=aO-1;aN=aN+aA end;if aO<0 then aP=aP-1;aO=aO+aA end;if aP<0 then aQ=aQ-1;aP=aP+aA end;if aQ<0 then aR=aR-1;aQ=aQ+aA end;if aR<0 then aS=aS-1;aR=aR+aA end;if aS<0 then aT=aT-1;aS=aS+aA end;if aT<0 then aU=aU-1;aT=aT+aA end;if aU<0 then aV=aV-1;aU=aU+aA end;if aV<0 then aW=aW-1;aV=aV+aA end;local e={aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW}return e end;local function aZ(a1,B)local aL=a1[1]-B[1]local aM=a1[2]-B[2]local aN=a1[3]-B[3]local aO=a1[4]-B[4]local aP=a1[5]-B[5]local aQ=a1[6]-B[6]local aR=a1[7]-B[7]local aS=a1[8]-B[8]local aT=a1[9]-B[9]local aU=a1[10]-B[10]local aV=a1[11]-B[11]local aW=a1[12]-B[12]if aL<0 then aM=aM-1;aL=aL+aA end;if aM<0 then aN=aN-1;aM=aM+aA end;if aN<0 then aO=aO-1;aN=aN+aA end;if aO<0 then aP=aP-1;aO=aO+aA end;if aP<0 then aQ=aQ-1;aP=aP+aA end;if aQ<0 then aR=aR-1;aQ=aQ+aA end;if aR<0 then aS=aS-1;aR=aR+aA end;if aS<0 then aT=aT-1;aS=aS+aA end;if aT<0 then aU=aU-1;aT=aT+aA end;if aU<0 then aV=aV-1;aU=aU+aA end;if aV<0 then aW=aW-1;aV=aV+aA end;local e={aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW}if aW<0 then e=aY(e,bF)end;return e end;local function a_(a1,B)local aL=a1[1]+B[1]local aM=a1[2]+B[2]local aN=a1[3]+B[3]local aO=a1[4]+B[4]local aP=a1[5]+B[5]local aQ=a1[6]+B[6]local aR=a1[7]+B[7]local aS=a1[8]+B[8]local aT=a1[9]+B[9]local aU=a1[10]+B[10]local aV=a1[11]+B[11]local aW=a1[12]+B[12]local b0=a1[13]+B[13]local b1=a1[14]+B[14]local b2=a1[15]+B[15]local b3=a1[16]+B[16]local b4=a1[17]+B[17]local b5=a1[18]+B[18]local b6=a1[19]+B[19]local b7=a1[20]+B[20]local b8=a1[21]+B[21]local b9=a1[22]+B[22]local ba=a1[23]+B[23]local bb=a1[24]+B[24]if aL>A then aM=aM+1;aL=aL-aA end;if aM>A then aN=aN+1;aM=aM-aA end;if aN>A then aO=aO+1;aN=aN-aA end;if aO>A then aP=aP+1;aO=aO-aA end;if aP>A then aQ=aQ+1;aP=aP-aA end;if aQ>A then aR=aR+1;aQ=aQ-aA end;if aR>A then aS=aS+1;aR=aR-aA end;if aS>A then aT=aT+1;aS=aS-aA end;if aT>A then aU=aU+1;aT=aT-aA end;if aU>A then aV=aV+1;aU=aU-aA end;if aV>A then aW=aW+1;aV=aV-aA end;if aW>A then b0=b0+1;aW=aW-aA end;if b0>A then b1=b1+1;b0=b0-aA end;if b1>A then b2=b2+1;b1=b1-aA end;if b2>A then b3=b3+1;b2=b2-aA end;if b3>A then b4=b4+1;b3=b3-aA end;if b4>A then b5=b5+1;b4=b4-aA end;if b5>A then b6=b6+1;b5=b5-aA end;if b6>A then b7=b7+1;b6=b6-aA end;if b7>A then b8=b8+1;b7=b7-aA end;if b8>A then b9=b9+1;b8=b8-aA end;if b9>A then ba=ba+1;b9=b9-aA end;if ba>A then bb=bb+1;ba=ba-aA end;local e={aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,ba,bb}return e end;local function bd(a1,B)local be,bf,bg,bh,bi,bj,bk,bl,bm,bn,bo,bp=unpack(a1)local bq,br,bs,bt,bu,bv,bw,bx,by,bz,bA,bB=unpack(B)local aL=be*bq;local aM=be*br;aM=aM+bf*bq;local aN=be*bs;aN=aN+bf*br;aN=aN+bg*bq;local aO=be*bt;aO=aO+bf*bs;aO=aO+bg*br;aO=aO+bh*bq;local aP=be*bu;aP=aP+bf*bt;aP=aP+bg*bs;aP=aP+bh*br;aP=aP+bi*bq;local aQ=be*bv;aQ=aQ+bf*bu;aQ=aQ+bg*bt;aQ=aQ+bh*bs;aQ=aQ+bi*br;aQ=aQ+bj*bq;local aR=be*bw;aR=aR+bf*bv;aR=aR+bg*bu;aR=aR+bh*bt;aR=aR+bi*bs;aR=aR+bj*br;aR=aR+bk*bq;local aS=be*bx;aS=aS+bf*bw;aS=aS+bg*bv;aS=aS+bh*bu;aS=aS+bi*bt;aS=aS+bj*bs;aS=aS+bk*br;aS=aS+bl*bq;local aT=be*by;aT=aT+bf*bx;aT=aT+bg*bw;aT=aT+bh*bv;aT=aT+bi*bu;aT=aT+bj*bt;aT=aT+bk*bs;aT=aT+bl*br;aT=aT+bm*bq;local aU=be*bz;aU=aU+bf*by;aU=aU+bg*bx;aU=aU+bh*bw;aU=aU+bi*bv;aU=aU+bj*bu;aU=aU+bk*bt;aU=aU+bl*bs;aU=aU+bm*br;aU=aU+bn*bq;local aV=be*bA;aV=aV+bf*bz;aV=aV+bg*by;aV=aV+bh*bx;aV=aV+bi*bw;aV=aV+bj*bv;aV=aV+bk*bu;aV=aV+bl*bt;aV=aV+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=aN%aA;aP=aP+aO/aA;aP=aP-aP%1;aO=aO%aA;aQ=aQ+aP/aA;aQ=aQ-aQ%1;aP=aP%aA;aR=aR+aQ/aA;aR=aR-aR%1;aQ=aQ%aA;aS=aS+aR/aA;aS=aS-aS%1;aR=aR%aA;aT=aT+aS/aA;aT=aT-aT%1;aS=aS%aA;aU=aU+aT/aA;aU=aU-aU%1;aT=aT%aA;aV=aV+aU/aA;aV=aV-aV%1;aU=aU%aA;aW=aW+aV/aA;aW=aW-aW%1;aV=aV%aA;b0=b0+aW/aA;b0=b0-b0%1;aW=aW%aA;b1=b1+b0/aA;b1=b1-b1%1;b0=b0%aA;b2=b2+b1/aA;b2=b2-b2%1;b1=b1%aA;b3=b3+b2/aA;b3=b3-b3%1;b2=b2%aA;b4=b4+b3/aA;b4=b4-b4%1;b3=b3%aA;b5=b5+b4/aA;b5=b5-b5%1;b4=b4%aA;b6=b6+b5/aA;b6=b6-b6%1;b5=b5%aA;b7=b7+b6/aA;b7=b7-b7%1;b6=b6%aA;b8=b8+b7/aA;b8=b8-b8%1;b7=b7%aA;b9=b9+b8/aA;b9=b9-b9%1;b8=b8%aA;ba=ba+b9/aA;ba=ba-ba%1;b9=b9%aA;bb=bb+ba/aA;bb=bb-bb%1;ba=ba%aA;local e={aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,ba,bb}return e end;local function bI(bJ)local aA={unpack(bd({unpack(bJ,1,12)},bG),1,12)}local ae={unpack(a_(bJ,bd(aA,bF)),13,24)}return aX(ae)end;local function bE(a1,B)return bI(bd(a1,B))end;local function bK(a1)local be,bf,bg,bh,bi,bj,bk,bl,bm,bn,bo,bp=unpack(a1)local aL=be*be;local aM=be*bf*2;local aN=be*bg*2;aN=aN+bf*bf;local aO=be*bh*2;aO=aO+bf*bg*2;local aP=be*bi*2;aP=aP+bf*bh*2;aP=aP+bg*bg;local aQ=be*bj*2;aQ=aQ+bf*bi*2;aQ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/aA;aQ=aQ-aQ%1;aP=aP%aA;aR=aR+aQ/aA;aR=aR-aR%1;aQ=aQ%aA;aS=aS+aR/aA;aS=aS-aS%1;aR=aR%aA;aT=aT+aS/aA;aT=aT-aT%1;aS=aS%aA;aU=aU+aT/aA;aU=aU-aU%1;aT=aT%aA;aV=aV+aU/aA;aV=aV-aV%1;aU=aU%aA;aW=aW+aV/aA;aW=aW-aW%1;aV=aV%aA;b0=b0+aW/aA;b0=b0-b0%1;aW=aW%aA;b1=b1+b0/aA;b1=b1-b1%1;b0=b0%aA;b2=b2+b1/aA;b2=b2-b2%1;b1=b1%aA;b3=b3+b2/aA;b3=b3-b3%1;b2=b2%aA;b4=b4+b3/aA;b4=b4-b4%1;b3=b3%aA;b5=b5+b4/aA;b5=b5-b5%1;b4=b4%aA;b6=b6+b5/aA;b6=b6-b6%1;b5=b5%aA;b7=b7+b6/aA;b7=b7-b7%1;b6=b6%aA;b8=b8+b7/aA;b8=b8-b8%1;b7=b7%aA;b9=b9+b8/aA;b9=b9-b9%1;b8=b8%aA;ba=ba+b9/aA;ba=ba-ba%1;b9=b9%aA;bb=bb+ba/aA;bb=bb-bb%1;ba=ba%aA;local e={aL,aM,aN,aO,aP,aQ,aR,aS,aT,aU,aV,aW,b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,ba,bb}return bI(e)end;local function bL(a1)return bE(a1,aM)end;local function bM(a1)local a1={unpack(a1)}for P=13,24 do a1[P]=0 end;return bI(a1)end;return{eq=aD,mul=bE,sqr=bK,add=aY,sub=aZ,shr=bH,mont=bL,invMont=bM,sub192=aK}end;a["empty"]=function(...)end;a["elliptic"]=function(...)fp=require("fp")local aD=fp.eq;local bE=fp.mul;local bK=fp.sqr;local aY=fp.add;local aZ=fp.sub;local bH=fp.shr;local bL=fp.mont;local bM=fp.invMont;local aK=fp.sub192;local bN=192;local bO={1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1}local bP={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0}local bQ={0,0,0,0,0,0,0,0,0,0,0,0}local bR=bL({1,0,0,0,0,0,0,0,0,0,0,0})local bF=bL({3,0,0,0,0,0,0,0,0,0,0,65533})local bS={bL({30457,58187,5603,63215,8936,58151,26571,7272,26680,23486,32353,59456}),bL({3,0,0,0,0,0,0,0,0,0,0,0}),bL({1,0,0,0,0,0,0,0,0,0,0,0})}local bT={bS}local a3=bL({108,0,0,0,0,0,0,0,0,0,0,0})local ad={__tostring=function(a1)return string.char(unpack(a1))end,__index={toHex=function(self,C)return"%02x":rep(#self):format(unpack(self))end,isEqual=function(self,ae)if type(ae)~="table"then return false end;if#self~=#ae then return false end;local af=0;for P=1,#self do af=bit32.bor(af,bxor(self[P],ae[P]))end;return af==0 end}}local function bU(a1,ae)local a1={unpack(a1)}local e={unpack(bR)}for P=1,bN do if ae[P]==1 then e=bE(e,a1)end;a1=bE(a1,a1)end;return e end;local function bV(bW)local bX,bY,bZ=unpack(bW)local B=aY(bX,bY)local b_=bK(B)local Y=bK(bX)local c0=bK(bY)local c1=aY(Y,c0)local H=bK(bZ)local c2=aZ(c1,aY(H,H))local c3=bE(aZ(b_,c1),c2)local c4=bE(c1,aZ(Y,c0))local c5=bE(c1,c2)local c6={c3,c4,c5}return c6 end;local function c7(bW,c8)local bX,bY,bZ=unpack(bW)local c9,ca,cb=unpack(c8)local cc=bE(bZ,cb)local b_=bK(cc)local Y=bE(bX,c9)local c0=bE(bY,ca)local c1=bE(a3,bE(Y,c0))local cd=aZ(b_,c1)local bS=aY(b_,c1)local c3=bE(cc,bE(cd,aZ(bE(aY(bX,bY),aY(c9,ca)),aY(Y,c0))))local c4=bE(cc,bE(bS,aZ(c0,Y)))local c5=bE(cd,bS)local c6={c3,c4,c5}return c6 end;local function ce(bW)local bX,bY,bZ=unpack(bW)local c3=aZ(bF,bX)local c4={unpack(bY)}local c5={unpack(bZ)}local c6={c3,c4,c5}return c6 end;local function cf(bW,c8)return c7(bW,ce(c8))end;local function cg(bW)local bX,bY,bZ=unpack(bW)local cc=bU(bZ,bO)local c3=bE(bX,cc)local c4=bE(bY,cc)local c5={unpack(bR)}local c6={c3,c4,c5}return c6 end;local function ch(bW,c8)local bX,bY,bZ=unpack(bW)local c9,ca,cb=unpack(c8)local ci=bE(bX,cb)local cj=bE(bY,cb)local ck=bE(c9,bZ)local cl=bE(ca,bZ)return aD(ci,ck)and aD(cj,cl)end;local function cm(bW)local bX,bY,bZ=unpack(bW)local cn=bK(bX)local co=bK(bY)local cp=bK(bZ)local cq=bK(cp)local a1=aY(cn,co)a1=bE(a1,cp)local B=bE(a3,bE(cn,co))B=aY(cq,B)return aD(a1,B)end;local function cr(a3)local e=a3[1]%32;if e>=16 then e=e-32 end;return e end;local function cs(a3)local ae={}local a3={unpack(a3)}while a3[12]>=0 and not aD(a3,bQ)do if a3[1]%2==1 then ae[#ae+1]=cr(a3)a3=aK(a3,{ae[#ae],0,0,0,0,0,0,0,0,0,0,0})else ae[#ae+1]=0 end;a3=bH(a3)end;return ae end;local function ct(C,bW)local cu=cs(C)local cv={bW}local c8=bV(bW)for P=3,31,2 do cv[P]=c7(cv[P-2],c8)end;local cw={{unpack(bQ)},{unpack(bR)},{unpack(bR)}}for P=#cu,1,-1 do cw=bV(cw)if cu[P]>0 then cw=c7(cw,cv[cu[P]])elseif cu[P]<0 then cw=cf(cw,cv[-cu[P]])end end;return cw end;for P=2,196 do bT[P]=bV(bT[P-1])end;local function cx(C)local e={{unpack(bQ)},{unpack(bR)},{unpack(bR)}}local az=1;for P=1,12 do local X=C[P]for V=1,16 do if X%2==1 then e=c7(e,bT[az])end;az=az+1;X=X/2;X=X-X%1 end end;return e end;local function cy(bW)bW=cg(bW)local e={}local aH,cz=unpack(bW)e[1]=aH[1]%2;for P=1,12 do local aA=cz[P]%256;e[2*P]=aA;e[2*P+1]=(cz[P]-aA)/256 end;return setmetatable(e,ad)end;local function cA(aJ)local cz={}for P=1,12 do cz[P]=aJ[2*P]cz[P]=cz[P]+aJ[2*P+1]*256 end;local cB=bK(cz)local cC=aZ(cB,bR)local Z=aZ(bE(a3,cB),bR)local cD=bK(cC)local cE=bE(cC,cD)local cF=bE(cE,cD)local cG=bE(Z,bK(Z))local X=bE(cF,cG)local aH=bE(cE,bE(Z,bU(X,bP)))if aH[1]%2~=aJ[1]then aH=aZ(bF,aH)end;local c6={aH,cz,{unpack(bR)}}return c6 end;return{G=bS,pointAdd=c7,pointNeg=ce,pointSub=cf,pointEq=ch,pointIsOnCurve=cm,scalarMul=ct,scalarMulG=cx,pointEncode=cy,pointDecode=cA}end;a["ecc"]=function(...)local cH=require("fq")local cI=require("elliptic")local g=require("sha256")require("urandom")local aB={1372,62520,47765,8105,45059,9616,65535,65535,65535,65535,65535,65532}local cJ=24;local cK=24;local function cL(cM)local cN=g.hmac({0x00},cM)local aH;repeat cN=g.digest(cN)aH=cH.fromBytes(cN)until cH.cmp(aH,aB)<=0;return aH end;local function cO(cM)local aH=cL(cM)local cP=cI.scalarMulG(aH)local cQ=cI.pointEncode(cP)return cQ end;local function cR()local cS=os.urandom()local cT=cO(cS)return cT,cS end;local function cU(cM,cQ)local cP=cI.pointDecode(cQ)local aH=cL(cM)local cV=cI.scalarMul(aH,cP)cV=cI.pointScale(cV)local cW=cH.bytes(cV[2])local cW=g.digest(cW)return cW end;local function cX(cM,cY)cY=type(cY)=="table"and string.char(unpack(cY))or cY;cM=type(cM)=="table"and string.char(unpack(cM))or cM;local cZ=tostring(os.epoch("utc"))local aH=cL(cM)local az=cL(cY..cZ..cM)local c_=cI.scalarMulG(az)c_=string.char(unpack(cI.pointEncode(c_)))local a4=cL(c_..cY)local C=cH.sub(az,cH.mul(aH,a4))a4=cH.bytes(a4)C=cH.bytes(C)local d0=a4;for P=1,#C do d0[#d0+1]=C[P]end;return d0 end;local function d1(cQ,cY,d0)local cP=cI.pointDecode(cQ)local a4={unpack(d0,1,cK)}local C={unpack(d0,cK+1,cK+cJ)}a4=cH.fromBytes(a4)C=cH.fromBytes(C)local c_=cI.pointAdd(cI.scalarMulG(C),cI.scalarMul(a4,cP))c_=string.char(unpack(cI.pointEncode(c_)))local d2=cL(c_..cY)return cH.eq(d2,a4)end;return{publicKey=cO,exchange=cU,sign=cX,verify=d1,keypair=cR}end;return require
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement