daily pastebin goal
79%
SHARE
TWEET

ecc

a guest Aug 18th, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. local e=
  3. type(package)=="table"and type(package.preload)=="table"and package.preload or{}local t=require
  4. if type(t)~="function"then local a={}local o={}
  5. t=function(i)local n=o[i]
  6. if n~=nil then if n==a then
  7. error(
  8. "loop or previous error loading module '"..i.."'",2)end;return n end;o[i]=a;local s=e[i]if s then n=s(i)else
  9. error("cannot load '"..i.."'",2)end;if n==nil then n=true end;o[i]=n;return n end end
  10. e["src.urandom"]=function(...)local a=t("sha256")local o=os.pullEvent;local i=fs.open
  11. local n=
  12. tostring(math.random())..tostring(os.epoch("utc"))local s=1024;local h="/.urandom"if fs.exists(h)then local d=fs.open(h,"rb")
  13. n=n..d.readAll()d.close()end;local r=a.digest(n)
  14. if
  15. not os.urandom then
  16. os.pullEvent=function(d)
  17. while true do local l={o()}local u=#n
  18. n={n,l[1],tostring(l[2]),tostring(l[3]),tostring(l[4]),tostring(os.epoch("utc")),tostring({})}n=table.concat(n,"|")
  19. if#n>s then r=a.digest(n)n=tostring(r)end;if not d or d==l[1]then return unpack(l)end end end
  20. fs.open=function(d,l)
  21. local u=fs.exists(d)and fs.getSize(d)or 0;n={n,d,l,tostring(u)}n=table.concat(n)
  22. os.queueEvent("file")os.pullEvent()local c=i(h,"wb")
  23. c.write(tostring(a.hmac("save",r)))c.close()r=a.digest(r)return i(d,l)end
  24. os.urandom=function()os.queueEvent("random")os.pullEvent()
  25. local d=a.hmac("out",r)r=a.digest(r)return d end end end
  26. e["src.sha256"]=function(...)local a=2^32
  27. local o=bit32 and bit32.band or bit.band;local i=bit32 and bit32.bnot or bit.bnot;local n=
  28. bit32 and bit32.bxor or bit.bxor
  29. local s=bit32 and bit32.lshift or bit.blshift;local h=unpack
  30. local function r(k,q)local j=k/ (2^q)local x=j%1;return(j-x)+x*a end;local function d(k,q)local j=k/ (2^q)return j-j%1 end
  31. local l={0x6a09e667,0xbb67ae85,0x3c6ef372,0xa54ff53a,0x510e527f,0x9b05688c,0x1f83d9ab,0x5be0cd19}
  32. local u={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}
  33. local function c(k)local q,j=0,0;if 0xFFFFFFFF-q<k then j=j+1
  34. q=k- (0xFFFFFFFF-q)-1 else q=q+k end;return j,q end
  35. local function m(k,q)return
  36. s((k[q]or 0),24)+s((k[q+1]or 0),16)+
  37. s((k[q+2]or 0),8)+ (k[q+3]or 0)end
  38. local function f(k)local q=#k;local j={}k[#k+1]=0x80;while#k%64 ~=56 do k[#k+1]=0 end;local x=math.ceil(#
  39. k/64)
  40. for z=1,x do j[z]={}for _=1,16 do j[z][_]=m(k,1+ ((z-1)*64)+
  41. ((_-1)*4))end end;j[x][15],j[x][16]=c(q*8)return j end
  42. local function w(k,q)
  43. for I=17,64 do local N=k[I-15]
  44. local S=n(n(r(k[I-15],7),r(k[I-15],18)),d(k[I-15],3))
  45. local H=n(n(r(k[I-2],17),r(k[I-2],19)),d(k[I-2],10))k[I]=(k[I-16]+S+k[I-7]+H)%a end;local j,x,z,_,E,T,A,O=h(q)
  46. for I=1,64 do local N=n(n(r(E,6),r(E,11)),r(E,25))
  47. local S=n(o(E,T),o(i(E),A))local H=(O+N+S+u[I]+k[I])%a
  48. local R=n(n(r(j,2),r(j,13)),r(j,22))local D=n(n(o(j,x),o(j,z)),o(x,z))local L=(R+D)%a;O,A,T,E,_,z,x,j=A,T,E,(_+
  49. H)%a,z,x,j,(H+L)%a end;q[1]=(q[1]+j)%a;q[2]=(q[2]+x)%a
  50. q[3]=(q[3]+z)%a;q[4]=(q[4]+_)%a;q[5]=(q[5]+E)%a
  51. q[6]=(q[6]+T)%a;q[7]=(q[7]+A)%a;q[8]=(q[8]+O)%a;return q end
  52. local y={__tostring=function(k)return string.char(unpack(k))end,__index={toHex=function(k,q)return("%02x"):rep(
  53. #k):format(unpack(k))end,isEqual=function(k,q)if
  54. type(q)~="table"then return false end;if#k~=#q then return false end;local j=0;for x=1,
  55. #k do j=bit32.bor(j,n(k[x],q[x]))end
  56. return j==0 end}}
  57. local function p(k,q)local j={}for x=1,q do j[(x-1)*4+1]=o(d(k[x],24),0xFF)
  58. j[(x-1)*4+2]=o(d(k[x],16),0xFF)j[(x-1)*4+3]=o(d(k[x],8),0xFF)
  59. j[(x-1)*4+4]=o(k[x],0xFF)end;return
  60. setmetatable(j,y)end
  61. local function v(k)k=k or""
  62. k=type(k)=="string"and{k:byte(1,-1)}or k;k=f(k)local q={h(l)}for j=1,#k do q=w(k[j],q)end;return p(q,8)end
  63. local function b(k,q)local k=type(k)=="table"and{h(k)}or
  64. {tostring(k):byte(1,-1)}
  65. local q=type(q)=="table"and
  66. {h(q)}or{tostring(q):byte(1,-1)}local j=64;q=#q>j and v(q)or q;local x={}local z={}local _={}for E=1,j do
  67. x[E]=n(0x36,q[E]or 0)z[E]=n(0x5C,q[E]or 0)end;for E=1,#k do
  68. x[j+E]=k[E]end;x=v(x)for E=1,j do _[E]=z[E]_[j+E]=x[E]end;return v(_)end
  69. local function g(k,q,j,x)
  70. local q=type(q)=="table"and q or{tostring(q):byte(1,-1)}local z=32;local x=x or 32;local _=1;local E={}
  71. while x>0 do local T={}local A={h(q)}
  72. local O=x>z and z or x;A[#A+1]=o(d(_,24),0xFF)A[#A+1]=o(d(_,16),0xFF)
  73. A[#A+1]=o(d(_,8),0xFF)A[#A+1]=o(_,0xFF)
  74. for I=1,j do A=b(A,k)
  75. for N=1,O do T[N]=n(A[N],T[N]or 0)end;if I%200 ==0 then os.queueEvent("PBKDF2",I)
  76. coroutine.yield("PBKDF2")end end;x=x-O;_=_+1;for I=1,O do E[#E+1]=T[I]end end;return setmetatable(E,y)end;return{pbkdf2=g,digest=v,hmac=b}end
  77. e["src.fq"]=function(...)local a=0xffff;local o=0x10000
  78. local i={1372,62520,47765,8105,45059,9616,65535,65535,65535,65535,65535,65532}
  79. local n={1372,62520,47765,8105,45059,9616,65535,65535,65535,65535,65535,65532,0,0,0,0,0,0,0,0,0,0,0,0}
  80. local s={__tostring=function(k)return string.char(unpack(k))end,__index={toHex=function(k,q)return("%02x"):rep(
  81. #k):format(unpack(k))end,isEqual=function(k,q)if
  82. type(q)~="table"then return false end;if#k~=#q then return false end;local j=0
  83. for x=1,
  84. #k do j=bit32.bor(j,bxor(k[x],q[x]))end;return j==0 end}}
  85. local function h(k,q)for j=1,12 do if k[j]~=q[j]then return false end end;return true end;local function r(k,q)
  86. for j=12,1,-1 do if k[j]>q[j]then return 1 elseif k[j]<q[j]then return-1 end end;return 0 end;local function d(k,q)
  87. for j=24,1,-1 do if
  88. k[j]>q[j]then return 1 elseif k[j]<q[j]then return-1 end end;return 0 end
  89. local function l(k)local q={}for j=0,11 do local o=
  90. k[j+1]%256;q[2*j+1]=o
  91. q[2*j+2]=(k[j+1]-o)/256 end;return setmetatable(q,s)end
  92. local function u(k)local q={}for j=0,11 do q[j+1]=k[2*j+1]%256
  93. q[j+1]=q[j+1]+k[2*j+2]*256 end;return q end
  94. local function c(k,q)local j=k[1]-q[1]local x=k[2]-q[2]local z=k[3]-q[3]
  95. local _=k[4]-q[4]local E=k[5]-q[5]local T=k[6]-q[6]local A=k[7]-q[7]
  96. local O=k[8]-q[8]local I=k[9]-q[9]local N=k[10]-q[10]local S=k[11]-q[11]
  97. local H=k[12]-q[12]if j<0 then x=x-1;j=j+o end;if x<0 then z=z-1;x=x+o end
  98. if z<0 then _=_-1;z=z+o end;if _<0 then E=E-1;_=_+o end;if E<0 then T=T-1;E=E+o end
  99. if T<0 then A=A-1;T=T+o end;if A<0 then O=O-1;A=A+o end;if O<0 then I=I-1;O=O+o end
  100. if I<0 then N=N-1;I=I+o end;if N<0 then S=S-1;N=N+o end;if S<0 then H=H-1;S=S+o end
  101. local R={j,x,z,_,E,T,A,O,I,N,S,H}return R end
  102. local function m(k)local q={unpack(k)}if r(q,i)>=0 then q=c(q,i)end;return q end
  103. local function f(k,q)local j=k[1]+q[1]local x=k[2]+q[2]local z=k[3]+q[3]
  104. local _=k[4]+q[4]local E=k[5]+q[5]local T=k[6]+q[6]local A=k[7]+q[7]
  105. local O=k[8]+q[8]local I=k[9]+q[9]local N=k[10]+q[10]local S=k[11]+q[11]
  106. local H=k[12]+q[12]if j>a then x=x+1;j=j-o end;if x>a then z=z+1;x=x-o end
  107. if z>a then _=_+1;z=z-o end;if _>a then E=E+1;_=_-o end;if E>a then T=T+1;E=E-o end
  108. if T>a then A=A+1;T=T-o end;if A>a then O=O+1;A=A-o end;if O>a then I=I+1;O=O-o end
  109. if I>a then N=N+1;I=I-o end;if N>a then S=S+1;N=N-o end;if S>a then H=H+1;S=S-o end
  110. local R={j,x,z,_,E,T,A,O,I,N,S,H}return m(R)end
  111. local function w(k,q)local j=c(k,q)if j[12]<0 then j=f(j,i)end;return j end
  112. local function y(k,q)local j=k[1]+q[1]local x=k[2]+q[2]local z=k[3]+q[3]
  113. local _=k[4]+q[4]local E=k[5]+q[5]local T=k[6]+q[6]local A=k[7]+q[7]
  114. local O=k[8]+q[8]local I=k[9]+q[9]local N=k[10]+q[10]local S=k[11]+q[11]
  115. local H=k[12]+q[12]local R=k[13]+q[13]local D=k[14]+q[14]local L=k[15]+q[15]local U=k[16]+
  116. q[16]local C=k[17]+q[17]local M=k[18]+q[18]
  117. local F=k[19]+q[19]local W=k[20]+q[20]local Y=k[21]+q[21]local P=k[22]+q[22]local V=k[23]+
  118. q[23]local B=k[24]+q[24]if j>a then x=x+1;j=j-o end;if x>a then z=z+1;x=x-
  119. o end;if z>a then _=_+1;z=z-o end;if _>a then E=E+1;_=_-o end;if
  120. E>a then T=T+1;E=E-o end;if T>a then A=A+1;T=T-o end
  121. if A>a then O=O+1;A=A-o end;if O>a then I=I+1;O=O-o end;if I>a then N=N+1;I=I-o end
  122. if N>a then S=S+1;N=N-o end;if S>a then H=H+1;S=S-o end;if H>a then R=R+1;H=H-o end
  123. if R>a then D=D+1;R=R-o end;if D>a then L=L+1;D=D-o end;if L>a then U=U+1;L=L-o end
  124. if U>a then C=C+1;U=U-o end;if C>a then M=M+1;C=C-o end;if M>a then F=F+1;M=M-o end
  125. if F>a then W=W+1;F=F-o end;if W>a then Y=Y+1;W=W-o end;if Y>a then P=P+1;Y=Y-o end
  126. if P>a then V=V+1;P=P-o end;if V>a then B=B+1;V=V-o end
  127. local G={j,x,z,_,E,T,A,O,I,N,S,H,R,D,L,U,C,M,F,W,Y,P,V,B}return G end
  128. local function p(k,q)local j=k[1]-q[1]local x=k[2]-q[2]local z=k[3]-q[3]
  129. local _=k[4]-q[4]local E=k[5]-q[5]local T=k[6]-q[6]local A=k[7]-q[7]
  130. local O=k[8]-q[8]local I=k[9]-q[9]local N=k[10]-q[10]local S=k[11]-q[11]
  131. local H=k[12]-q[12]local R=k[13]-q[13]local D=k[14]-q[14]local L=k[15]-q[15]local U=k[16]-
  132. q[16]local C=k[17]-q[17]local M=k[18]-q[18]
  133. local F=k[19]-q[19]local W=k[20]-q[20]local Y=k[21]-q[21]local P=k[22]-q[22]local V=k[23]-
  134. q[23]local B=k[24]-q[24]if j<0 then x=x-1;j=j+o end;if x<0 then z=z-1;x=x+
  135. o end;if z<0 then _=_-1;z=z+o end;if _<0 then E=E-1;_=_+o end;if
  136. E<0 then T=T-1;E=E+o end;if T<0 then A=A-1;T=T+o end
  137. if A<0 then O=O-1;A=A+o end;if O<0 then I=I-1;O=O+o end;if I<0 then N=N-1;I=I+o end
  138. if N<0 then S=S-1;N=N+o end;if S<0 then H=H-1;S=S+o end;if H<0 then R=R-1;H=H+o end
  139. if R<0 then D=D-1;R=R+o end;if D<0 then L=L-1;D=D+o end;if L<0 then U=U-1;L=L+o end
  140. if U<0 then C=C-1;U=U+o end;if C<0 then M=M-1;C=C+o end;if M<0 then F=F-1;M=M+o end
  141. if F<0 then W=W-1;F=F+o end;if W<0 then Y=Y-1;W=W+o end;if Y<0 then P=P-1;Y=Y+o end
  142. if P<0 then V=V-1;P=P+o end;if V<0 then B=B-1;V=V+o end
  143. local G={j,x,z,_,E,T,A,O,I,N,S,H,R,D,L,U,C,M,F,W,Y,P,V,B}return G end
  144. local function v(k,q)local j,x,z,_,E,T,A,O,I,N,S,H=unpack(k)local R,D,L,U,C,M,F,W,Y,P,V,B=unpack(q)local G=j*R;local K=j*D
  145. K=K+x*R;local Q=j*L;Q=Q+x*D;Q=Q+z*R;local J=j*U;J=J+x*L;J=J+z*D;J=J+_*R;local X=j*C
  146. X=X+x*U;X=X+z*L;X=X+_*D;X=X+E*R;local Z=j*M;Z=Z+x*C;Z=Z+z*U;Z=Z+_*L;Z=Z+E*D;Z=
  147. Z+T*R;local ee=j*F;ee=ee+x*M;ee=ee+z*C;ee=ee+_*U;ee=ee+E*L
  148. ee=ee+T*D;ee=ee+A*R;local et=j*W;et=et+x*F;et=et+z*M;et=et+_*C;et=et+E*U
  149. et=et+T*L;et=et+A*D;et=et+O*R;local ea=j*Y;ea=ea+x*W;ea=ea+z*F;ea=ea+_*M
  150. ea=ea+E*C;ea=ea+T*U;ea=ea+A*L;ea=ea+O*D;ea=ea+I*R;local eo=j*P;eo=eo+x*Y
  151. eo=eo+z*W;eo=eo+_*F;eo=eo+E*M;eo=eo+T*C;eo=eo+A*U;eo=eo+O*L;eo=eo+I*D;eo=eo+
  152. N*R;local ei=j*V;ei=ei+x*P;ei=ei+z*Y;ei=ei+_*W;ei=ei+E*F
  153. ei=ei+T*M;ei=ei+A*C;ei=ei+O*U;ei=ei+I*L;ei=ei+N*D;ei=ei+S*R;local en=j*B
  154. en=en+x*V;en=en+z*P;en=en+_*Y;en=en+E*W;en=en+T*F;en=en+A*M;en=en+O*C;en=en+
  155. I*U;en=en+N*L;en=en+S*D;en=en+H*R;local es=x*B;es=es+z*V
  156. es=es+_*P;es=es+E*Y;es=es+T*W;es=es+A*F;es=es+O*M;es=es+I*C;es=es+N*U;es=es+
  157. S*L;es=es+H*D;local eh=z*B;eh=eh+_*V;eh=eh+E*P;eh=eh+T*Y
  158. eh=eh+A*W;eh=eh+O*F;eh=eh+I*M;eh=eh+N*C;eh=eh+S*U;eh=eh+H*L;local er=_*B
  159. er=er+E*V;er=er+T*P;er=er+A*Y;er=er+O*W;er=er+I*F;er=er+N*M;er=er+S*C;er=er+
  160. H*U;local ed=E*B;ed=ed+T*V;ed=ed+A*P;ed=ed+O*Y;ed=ed+I*W
  161. ed=ed+N*F;ed=ed+S*M;ed=ed+H*C;local el=T*B;el=el+A*V;el=el+O*P;el=el+I*Y
  162. el=el+N*W;el=el+S*F;el=el+H*M;local eu=A*B;eu=eu+O*V;eu=eu+I*P;eu=eu+N*Y
  163. eu=eu+S*W;eu=eu+H*F;local ec=O*B;ec=ec+I*V;ec=ec+N*P;ec=ec+S*Y;ec=ec+H*W
  164. local em=I*B;em=em+N*V;em=em+S*P;em=em+H*Y;local ef=N*B;ef=ef+S*V;ef=ef+H*P
  165. local ew=S*B;ew=ew+H*V;local ey=H*B;local ep=0;K=K+ (G/o)K=K-K%1;G=G%o;Q=Q+ (K/o)
  166. Q=Q-Q%1;K=K%o;J=J+ (Q/o)J=J-J%1;Q=Q%o;X=X+ (J/o)X=X-X%1;J=J%o
  167. Z=Z+ (X/o)Z=Z-Z%1;X=X%o;ee=ee+ (Z/o)ee=ee-ee%1;Z=Z%o;et=et+ (ee/o)et=et-et%
  168. 1;ee=ee%o;ea=ea+ (et/o)ea=ea-ea%1;et=et%o
  169. eo=eo+ (ea/o)eo=eo-eo%1;ea=ea%o;ei=ei+ (eo/o)ei=ei-ei%1;eo=eo%o
  170. en=en+ (ei/o)en=en-en%1;ei=ei%o;es=es+ (en/o)es=es-es%1;en=en%o
  171. eh=eh+ (es/o)eh=eh-eh%1;es=es%o;er=er+ (eh/o)er=er-er%1;eh=eh%o
  172. ed=ed+ (er/o)ed=ed-ed%1;er=er%o;el=el+ (ed/o)el=el-el%1;ed=ed%o
  173. eu=eu+ (el/o)eu=eu-eu%1;el=el%o;ec=ec+ (eu/o)ec=ec-ec%1;eu=eu%o
  174. em=em+ (ec/o)em=em-em%1;ec=ec%o;ef=ef+ (em/o)ef=ef-ef%1;em=em%o
  175. ew=ew+ (ef/o)ew=ew-ew%1;ef=ef%o;ey=ey+ (ew/o)ey=ey-ey%1;ew=ew%o
  176. ep=ep+ (ey/o)ep=ep-ep%1;ey=ey%o
  177. local ev={G,K,Q,J,X,Z,ee,et,ea,eo,ei,en,es,eh,er,ed,el,eu,ec,em,ef,ew,ey,ep}return ev end
  178. local function b(k)local q={unpack(k)}
  179. while d(q,n)>=0 do local n={unpack(n)}local j=y(n,n)while
  180. d(q,j)>0 do n=j;j=y(j,j)end;q=p(q,n)end;q={unpack(q,1,12)}return q end;local function g(k,q)return b(v(k,q))end
  181. return{fromBytes=u,bytes=l,sub=w,mul=g,eq=h,cmp=r}end
  182. e["src.fp"]=function(...)local a=0xffff;local o=0x10000;local i={3,0,0,0,0,0,0,0,0,0,0,65533}
  183. local n={21845,21845,21845,21845,21845,21845,21845,21845,21845,21845,21845,43690}
  184. local s={44014,58358,19452,6484,45852,58974,63348,64806,65292,65454,65508,21512}
  185. local function h(g,k)for q=1,12 do if g[q]~=k[q]then return false end end;return true end
  186. local function r(g)local k=g[1]local s=g[2]local q=g[3]local j=g[4]local x=g[5]local z=g[6]local _=g[7]local E=g[8]
  187. local T=g[9]local A=g[10]local O=g[11]local I=g[12]if I<65533 or I==65533 and k<3 then return
  188. {unpack(g)}end;k=k-3;I=I-65533
  189. if k<0 then s=s-1;k=k+o end;if s<0 then q=q-1;s=s+o end;if q<0 then j=j-1;q=q+o end
  190. if j<0 then x=x-1;j=j+o end;if x<0 then z=z-1;x=x+o end;if z<0 then _=_-1;z=z+o end
  191. if _<0 then E=E-1;_=_+o end;if E<0 then T=T-1;E=E+o end;if T<0 then A=A-1;T=T+o end
  192. if A<0 then O=O-1;A=A+o end;if O<0 then I=I-1;O=O+o end;return{k,s,q,j,x,z,_,E,T,A,O,I}end
  193. local function d(g,k)local q=g[1]+k[1]local s=g[2]+k[2]local j=g[3]+k[3]
  194. local x=g[4]+k[4]local z=g[5]+k[5]local _=g[6]+k[6]local E=g[7]+k[7]
  195. local T=g[8]+k[8]local A=g[9]+k[9]local O=g[10]+k[10]local I=g[11]+k[11]
  196. local N=g[12]+k[12]if q>a then s=s+1;q=q-o end;if s>a then j=j+1;s=s-o end
  197. if j>a then x=x+1;j=j-o end;if x>a then z=z+1;x=x-o end;if z>a then _=_+1;z=z-o end
  198. if _>a then E=E+1;_=_-o end;if E>a then T=T+1;E=E-o end;if T>a then A=A+1;T=T-o end
  199. if A>a then O=O+1;A=A-o end;if O>a then I=I+1;O=O-o end;if I>a then N=N+1;I=I-o end
  200. local S={q,s,j,x,z,_,E,T,A,O,I,N}return r(S)end
  201. local function l(g)local k=g[1]local s=g[2]local q=g[3]local j=g[4]local x=g[5]local z=g[6]local _=g[7]local E=g[8]
  202. local T=g[9]local A=g[10]local O=g[11]local I=g[12]k=k/2;k=k-k%1
  203. k=k+ (s%2)*0x8000;s=s/2;s=s-s%1;s=s+ (q%2)*0x8000;q=q/2;q=q-q%1;q=q+
  204. (j%2)*0x8000;j=j/2;j=j-j%1;j=j+ (x%2)*0x8000;x=x/2
  205. x=x-x%1;x=x+ (z%2)*0x8000;z=z/2;z=z-z%1
  206. z=z+ (_%2)*0x8000;_=_/2;_=_-_%1;_=_+ (E%2)*0x8000;E=E/2;E=E-E%1;E=E+
  207. (T%2)*0x8000;T=T/2;T=T-T%1;T=T+ (A%2)*0x8000;A=A/2
  208. A=A-A%1;A=A+ (O%2)*0x8000;O=O/2;O=O-O%1
  209. O=O+ (I%2)*0x8000;I=I/2;I=I-I%1;local N={k,s,q,j,x,z,_,E,T,A,O,I}return N end
  210. local function u(g,k)local q=g[1]-k[1]local s=g[2]-k[2]local j=g[3]-k[3]
  211. local x=g[4]-k[4]local z=g[5]-k[5]local _=g[6]-k[6]local E=g[7]-k[7]
  212. local T=g[8]-k[8]local A=g[9]-k[9]local O=g[10]-k[10]local I=g[11]-k[11]
  213. local N=g[12]-k[12]if q<0 then s=s-1;q=q+o end;if s<0 then j=j-1;s=s+o end
  214. if j<0 then x=x-1;j=j+o end;if x<0 then z=z-1;x=x+o end;if z<0 then _=_-1;z=z+o end
  215. if _<0 then E=E-1;_=_+o end;if E<0 then T=T-1;E=E+o end;if T<0 then A=A-1;T=T+o end
  216. if A<0 then O=O-1;A=A+o end;if O<0 then I=I-1;O=O+o end;if I<0 then N=N-1;I=I+o end
  217. local S={q,s,j,x,z,_,E,T,A,O,I,N}return S end
  218. local function c(g,k)local q=g[1]-k[1]local s=g[2]-k[2]local j=g[3]-k[3]
  219. local x=g[4]-k[4]local z=g[5]-k[5]local _=g[6]-k[6]local E=g[7]-k[7]
  220. local T=g[8]-k[8]local A=g[9]-k[9]local O=g[10]-k[10]local I=g[11]-k[11]
  221. local N=g[12]-k[12]if q<0 then s=s-1;q=q+o end;if s<0 then j=j-1;s=s+o end
  222. if j<0 then x=x-1;j=j+o end;if x<0 then z=z-1;x=x+o end;if z<0 then _=_-1;z=z+o end
  223. if _<0 then E=E-1;_=_+o end;if E<0 then T=T-1;E=E+o end;if T<0 then A=A-1;T=T+o end
  224. if A<0 then O=O-1;A=A+o end;if O<0 then I=I-1;O=O+o end;if I<0 then N=N-1;I=I+o end
  225. local S={q,s,j,x,z,_,E,T,A,O,I,N}if N<0 then S=d(S,i)end;return S end
  226. local function m(g,k)local q=g[1]+k[1]local s=g[2]+k[2]local j=g[3]+k[3]
  227. local x=g[4]+k[4]local z=g[5]+k[5]local _=g[6]+k[6]local E=g[7]+k[7]
  228. local T=g[8]+k[8]local A=g[9]+k[9]local O=g[10]+k[10]local I=g[11]+k[11]
  229. local N=g[12]+k[12]local S=g[13]+k[13]local H=g[14]+k[14]local R=g[15]+k[15]local D=g[16]+
  230. k[16]local L=g[17]+k[17]local U=g[18]+k[18]
  231. local C=g[19]+k[19]local M=g[20]+k[20]local F=g[21]+k[21]local W=g[22]+k[22]local Y=g[23]+
  232. k[23]local P=g[24]+k[24]if q>a then s=s+1;q=q-o end;if s>a then j=j+1;s=s-
  233. o end;if j>a then x=x+1;j=j-o end;if x>a then z=z+1;x=x-o end;if
  234. z>a then _=_+1;z=z-o end;if _>a then E=E+1;_=_-o end
  235. if E>a then T=T+1;E=E-o end;if T>a then A=A+1;T=T-o end;if A>a then O=O+1;A=A-o end
  236. if O>a then I=I+1;O=O-o end;if I>a then N=N+1;I=I-o end;if N>a then S=S+1;N=N-o end
  237. if S>a then H=H+1;S=S-o end;if H>a then R=R+1;H=H-o end;if R>a then D=D+1;R=R-o end
  238. if D>a then L=L+1;D=D-o end;if L>a then U=U+1;L=L-o end;if U>a then C=C+1;U=U-o end
  239. if C>a then M=M+1;C=C-o end;if M>a then F=F+1;M=M-o end;if F>a then W=W+1;F=F-o end
  240. if W>a then Y=Y+1;W=W-o end;if Y>a then P=P+1;Y=Y-o end
  241. local V={q,s,j,x,z,_,E,T,A,O,I,N,S,H,R,D,L,U,C,M,F,W,Y,P}return V end
  242. local function f(g,k)local q,j,x,z,_,E,T,A,O,I,N,S=unpack(g)local H,R,D,L,U,C,M,F,W,Y,P,V=unpack(k)local B=q*H;local s=q*R
  243. s=s+j*H;local G=q*D;G=G+j*R;G=G+x*H;local K=q*L;K=K+j*D;K=K+x*R;K=K+z*H;local Q=q*U
  244. Q=Q+j*L;Q=Q+x*D;Q=Q+z*R;Q=Q+_*H;local J=q*C;J=J+j*U;J=J+x*L;J=J+z*D;J=J+_*R;J=
  245. J+E*H;local X=q*M;X=X+j*C;X=X+x*U;X=X+z*L;X=X+_*D;X=X+E*R;X=X+T*H;local Z=q*
  246. F;Z=Z+j*M;Z=Z+x*C;Z=Z+z*U;Z=Z+_*L;Z=Z+E*D;Z=Z+T*R;Z=Z+A*H;local ee=q*
  247. W;ee=ee+j*F;ee=ee+x*M;ee=ee+z*C;ee=ee+_*U;ee=ee+E*L
  248. ee=ee+T*D;ee=ee+A*R;ee=ee+O*H;local et=q*Y;et=et+j*W;et=et+x*F;et=et+z*M
  249. et=et+_*C;et=et+E*U;et=et+T*L;et=et+A*D;et=et+O*R;et=et+I*H;local ea=q*P
  250. ea=ea+j*Y;ea=ea+x*W;ea=ea+z*F;ea=ea+_*M;ea=ea+E*C;ea=ea+T*U;ea=ea+A*L;ea=ea+
  251. O*D;ea=ea+I*R;ea=ea+N*H;local eo=q*V;eo=eo+j*P;eo=eo+x*Y
  252. eo=eo+z*W;eo=eo+_*F;eo=eo+E*M;eo=eo+T*C;eo=eo+A*U;eo=eo+O*L;eo=eo+I*D;eo=eo+
  253. N*R;eo=eo+S*H;local ei=j*V;ei=ei+x*P;ei=ei+z*Y;ei=ei+_*W
  254. ei=ei+E*F;ei=ei+T*M;ei=ei+A*C;ei=ei+O*U;ei=ei+I*L;ei=ei+N*D;ei=ei+S*R
  255. local en=x*V;en=en+z*P;en=en+_*Y;en=en+E*W;en=en+T*F;en=en+A*M;en=en+O*C;en=en+
  256. I*U;en=en+N*L;en=en+S*D;local es=z*V;es=es+_*P;es=es+E*Y
  257. es=es+T*W;es=es+A*F;es=es+O*M;es=es+I*C;es=es+N*U;es=es+S*L;local eh=_*V
  258. eh=eh+E*P;eh=eh+T*Y;eh=eh+A*W;eh=eh+O*F;eh=eh+I*M;eh=eh+N*C;eh=eh+S*U
  259. local er=E*V;er=er+T*P;er=er+A*Y;er=er+O*W;er=er+I*F;er=er+N*M;er=er+S*C
  260. local ed=T*V;ed=ed+A*P;ed=ed+O*Y;ed=ed+I*W;ed=ed+N*F;ed=ed+S*M;local el=A*V
  261. el=el+O*P;el=el+I*Y;el=el+N*W;el=el+S*F;local eu=O*V;eu=eu+I*P;eu=eu+N*Y
  262. eu=eu+S*W;local ec=I*V;ec=ec+N*P;ec=ec+S*Y;local em=N*V;em=em+S*P;local ef=S*V;local ew=0
  263. s=s+ (B/o)s=s-s%1;B=B%o;G=G+ (s/o)G=G-G%1;s=s%o;K=K+ (G/o)K=K-K%1;G=G%o;Q=
  264. Q+ (K/o)Q=Q-Q%1;K=K%o;J=J+ (Q/o)J=J-J%1;Q=Q%o;X=X+ (J/o)X=
  265. X-X%1;J=J%o;Z=Z+ (X/o)Z=Z-Z%1;X=X%o;ee=ee+ (Z/o)
  266. ee=ee-ee%1;Z=Z%o;et=et+ (ee/o)et=et-et%1;ee=ee%o;ea=ea+ (et/o)
  267. ea=ea-ea%1;et=et%o;eo=eo+ (ea/o)eo=eo-eo%1;ea=ea%o;ei=ei+ (eo/o)ei=ei-
  268. ei%1;eo=eo%o;en=en+ (ei/o)en=en-en%1;ei=ei%o
  269. es=es+ (en/o)es=es-es%1;en=en%o;eh=eh+ (es/o)eh=eh-eh%1;es=es%o
  270. er=er+ (eh/o)er=er-er%1;eh=eh%o;ed=ed+ (er/o)ed=ed-ed%1;er=er%o
  271. el=el+ (ed/o)el=el-el%1;ed=ed%o;eu=eu+ (el/o)eu=eu-eu%1;el=el%o
  272. ec=ec+ (eu/o)ec=ec-ec%1;eu=eu%o;em=em+ (ec/o)em=em-em%1;ec=ec%o
  273. ef=ef+ (em/o)ef=ef-ef%1;em=em%o;ew=ew+ (ef/o)ew=ew-ew%1;ef=ef%o
  274. local ey={B,s,G,K,Q,J,X,Z,ee,et,ea,eo,ei,en,es,eh,er,ed,el,eu,ec,em,ef,ew}return ey end
  275. local function w(g)
  276. local o={unpack(f({unpack(g,1,12)},n),1,12)}local k={unpack(m(g,f(o,i)),13,24)}return r(k)end;local function y(g,k)return w(f(g,k))end
  277. local function p(g)local k,q,j,x,z,_,E,T,A,O,I,N=unpack(g)local S=k*k;local s=
  278. k*q*2;local H=k*j*2;H=H+q*q;local R=k*x*2;R=R+q*j*2;local D=k*z*2;D=D+
  279. q*x*2;D=D+j*j;local L=k*_*2;L=L+q*z*2;L=L+j*x*2;local U=k*E*2;U=U+q*_*
  280. 2;U=U+j*z*2;U=U+x*x;local C=k*T*2;C=C+q*E*2
  281. C=C+j*_*2;C=C+x*z*2;local M=k*A*2;M=M+q*T*2;M=M+j*E*2;M=M+x*_*2
  282. M=M+z*z;local F=k*O*2;F=F+q*A*2;F=F+j*T*2;F=F+x*E*2;F=F+z*_*2
  283. local W=k*I*2;W=W+q*O*2;W=W+j*A*2;W=W+x*T*2;W=W+z*E*2;W=W+_*_
  284. local Y=k*N*2;Y=Y+q*I*2;Y=Y+j*O*2;Y=Y+x*A*2;Y=Y+z*T*2;Y=Y+_*E*2;local P=q*N*
  285. 2;P=P+j*I*2;P=P+x*O*2;P=P+z*A*2;P=P+_*T*2
  286. P=P+E*E;local V=j*N*2;V=V+x*I*2;V=V+z*O*2;V=V+_*A*2;V=V+E*T*2
  287. local B=x*N*2;B=B+z*I*2;B=B+_*O*2;B=B+E*A*2;B=B+T*T;local G=z*N*2
  288. G=G+_*I*2;G=G+E*O*2;G=G+T*A*2;local K=_*N*2;K=K+E*I*2;K=K+T*O*2
  289. K=K+A*A;local Q=E*N*2;Q=Q+T*I*2;Q=Q+A*O*2;local J=T*N*2;J=J+A*I*2
  290. J=J+O*O;local X=A*N*2;X=X+O*I*2;local Z=O*N*2;Z=Z+I*I;local ee=I*N*2;local et=N*N;local ea=0;s=
  291. s+ (S/o)s=s-s%1;S=S%o;H=H+ (s/o)H=H-H%1;s=s%o;R=R+ (H/o)R=
  292. R-R%1;H=H%o;D=D+ (R/o)D=D-D%1;R=R%o;L=L+ (D/o)L=L-L%1;D=D%o;U=
  293. U+ (L/o)U=U-U%1;L=L%o;C=C+ (U/o)C=C-C%1;U=U%o;M=M+ (C/o)M=
  294. M-M%1;C=C%o;F=F+ (M/o)F=F-F%1;M=M%o;W=W+ (F/o)W=W-W%1;F=F%o;Y=
  295. Y+ (W/o)Y=Y-Y%1;W=W%o;P=P+ (Y/o)P=P-P%1;Y=Y%o;V=V+ (P/o)V=
  296. V-V%1;P=P%o;B=B+ (V/o)B=B-B%1;V=V%o;G=G+ (B/o)G=G-G%1;B=B%o;K=
  297. K+ (G/o)K=K-K%1;G=G%o;Q=Q+ (K/o)Q=Q-Q%1;K=K%o;J=J+ (Q/o)J=
  298. J-J%1;Q=Q%o;X=X+ (J/o)X=X-X%1;J=J%o;Z=Z+ (X/o)Z=Z-Z%1;X=X%o;ee=
  299. ee+ (Z/o)ee=ee-ee%1;Z=Z%o;et=et+ (ee/o)et=et-et%1
  300. ee=ee%o;ea=ea+ (et/o)ea=ea-ea%1;et=et%o
  301. local eo={S,s,H,R,D,L,U,C,M,F,W,Y,P,V,B,G,K,Q,J,X,Z,ee,et,ea}return w(eo)end;local function v(g)return y(g,s)end;local function b(g)local g={unpack(g)}for k=13,24 do g[k]=0 end;return
  302. w(g)end;return
  303. {eq=h,mul=y,sqr=p,add=d,sub=c,shr=l,mont=v,invMont=b,sub192=u}end;e["src.empty"]=function(...)end
  304. e["src.elliptic"]=function(...)fp=t("fp")local a=fp.eq
  305. local o=fp.mul;local i=fp.sqr;local n=fp.add;local s=fp.sub;local h=fp.shr;local r=fp.mont;local l=fp.invMont
  306. local u=fp.sub192;local c=192
  307. local m={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}
  308. local f={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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 w={0,0,0,0,0,0,0,0,0,0,0,0}
  309. local y=r({1,0,0,0,0,0,0,0,0,0,0,0})local v=r({3,0,0,0,0,0,0,0,0,0,0,65533})
  310. local b={r({30457,58187,5603,63215,8936,58151,26571,7272,26680,23486,32353,59456}),r({3,0,0,0,0,0,0,0,0,0,0,0}),r({1,0,0,0,0,0,0,0,0,0,0,0})}local g={b}local k=r({108,0,0,0,0,0,0,0,0,0,0,0})
  311. local q={__tostring=function(d)return
  312. string.char(unpack(d))end,__index={toHex=function(d,p)return
  313. ("%02x"):rep(#d):format(unpack(d))end,isEqual=function(d,p)
  314. if type(p)~="table"then return false end;if#d~=#p then return false end;local L=0;for U=1,#d do
  315. L=bit32.bor(L,bxor(d[U],p[U]))end;return L==0 end}}
  316. local function j(d,p)local d={unpack(d)}local L={unpack(y)}for U=1,c do
  317. if p[U]==1 then L=o(L,d)end;d=o(d,d)end;return L end
  318. local function x(d)local p,L,U=unpack(d)local M=n(p,L)local F=i(M)local W=i(p)local Y=i(L)local P=n(W,Y)
  319. local V=i(U)local B=s(P,n(V,V))local G=o(s(F,P),B)local K=o(P,s(W,Y))local Q=o(P,B)
  320. local J={G,K,Q}return J end
  321. local function z(d,p)local L,U,M=unpack(d)local W,Y,P=unpack(p)local V=o(M,P)local G=i(V)local K=o(L,W)
  322. local Q=o(U,Y)local J=o(k,o(K,Q))local X=s(G,J)local b=n(G,J)
  323. local Z=o(V,o(X,s(o(n(L,U),n(W,Y)),n(K,Q))))local ee=o(V,o(b,s(Q,K)))local et=o(X,b)local ea={Z,ee,et}return ea end
  324. local function _(d)local p,L,U=unpack(d)local C=s(v,p)local M={unpack(L)}
  325. local F={unpack(U)}local W={C,M,F}return W end;local function E(d,p)return z(d,_(p))end
  326. local function T(d)local p,L,U=unpack(d)local C=j(U,m)
  327. local M=o(p,C)local F=o(L,C)local W={unpack(y)}local Y={M,F,W}return Y end
  328. local function A(d,p)local L,U,C=unpack(d)local M,F,W=unpack(p)local Y=o(L,W)local P=o(U,W)local V=o(M,C)
  329. local B=o(F,C)return a(Y,V)and a(P,B)end
  330. local function O(d)local p,L,U=unpack(d)local C=i(p)local M=i(L)local F=i(U)local W=i(F)local Y=n(C,M)Y=o(Y,F)
  331. local P=o(k,o(C,M))P=n(W,P)return a(Y,P)end
  332. local function I(k)local d=k[1]%32;if d>=16 then d=d-32 end;return d end
  333. local function N(k)local d={}local k={unpack(k)}while k[12]>=0 and not a(k,w)do
  334. if k[1]%2 ==1 then
  335. d[#d+1]=I(k)k=u(k,{d[#d],0,0,0,0,0,0,0,0,0,0,0})else d[#d+1]=0 end;k=h(k)end;return d end
  336. local function S(d,p)local L=N(d)local U={p}local C=x(p)for F=3,31,2 do U[F]=z(U[F-2],C)end
  337. local M={{unpack(w)},{unpack(y)},{unpack(y)}}for F=#L,1,-1 do M=x(M)
  338. if L[F]>0 then M=z(M,U[L[F]])elseif L[F]<0 then M=E(M,U[-L[F]])end end;return M end;for d=2,196 do g[d]=x(g[d-1])end
  339. local function H(d)
  340. local p={{unpack(w)},{unpack(y)},{unpack(y)}}local L=1;for U=1,12 do local C=d[U]
  341. for M=1,16 do if C%2 ==1 then p=z(p,g[L])end;L=L+1;C=C/2;C=C-C%1 end end;return p end
  342. local function R(d)d=T(d)local p={}local L,U=unpack(d)p[1]=L[1]%2;for C=1,12 do local M=U[C]%256;p[2*C]=M;p[
  343. 2*C+1]=(U[C]-M)/256 end;return
  344. setmetatable(p,q)end
  345. local function D(d)local p={}
  346. for G=1,12 do p[G]=d[2*G]p[G]=p[G]+d[2*G+1]*256 end;local L=i(p)local U=s(L,y)local C=s(o(k,L),y)local M=i(U)local F=o(U,M)local W=o(F,M)
  347. local Y=o(C,i(C))local P=o(W,Y)local V=o(F,o(C,j(P,f)))
  348. if V[1]%2 ~=d[1]then V=s(v,V)end;local B={V,p,{unpack(y)}}return B end
  349. return{G=b,pointAdd=z,pointNeg=_,pointSub=E,pointEq=A,pointIsOnCurve=O,scalarMul=S,scalarMulG=H,pointEncode=R,pointDecode=D}end
  350. e["src.ecc"]=function(...)local a=t("fq")local o=t("elliptic")local i=t("sha256")
  351. t("urandom")
  352. local n={1372,62520,47765,8105,45059,9616,65535,65535,65535,65535,65535,65532}local s=24;local h=24
  353. local function r(f)local w=i.hmac({0x00},f)local y;repeat w=i.digest(w)
  354. y=a.fromBytes(w)until a.cmp(y,n)<=0;return y end
  355. local function d(f)local w=r(f)local y=o.scalarMulG(w)local p=o.pointEncode(y)return p end;local function l()local f=os.urandom()local w=d(f)return w,f end
  356. local function u(f,w)
  357. local y=o.pointDecode(w)local p=r(f)local v=o.scalarMul(p,y)v=o.pointScale(v)
  358. local b=a.bytes(v[2])local b=i.digest(b)return b end
  359. local function c(f,w)
  360. w=type(w)=="table"and string.char(unpack(w))or w
  361. f=type(f)=="table"and string.char(unpack(f))or f;local y=tostring(os.epoch("utc"))local p=r(f)
  362. local v=r(w..y..f)local b=o.scalarMulG(v)
  363. b=string.char(unpack(o.pointEncode(b)))local g=r(b..w)local k=a.sub(v,a.mul(p,g))g=a.bytes(g)
  364. k=a.bytes(k)local q=g;for j=1,#k do q[#q+1]=k[j]end;return q end
  365. local function m(f,w,y)local p=o.pointDecode(f)local v={unpack(y,1,h)}
  366. local b={unpack(y,h+1,h+s)}v=a.fromBytes(v)b=a.fromBytes(b)
  367. local g=o.pointAdd(o.scalarMulG(b),o.scalarMul(v,p))
  368. g=string.char(unpack(o.pointEncode(g)))local k=r(g..w)return a.eq(k,v)end;return{publicKey=d,exchange=u,sign=c,verify=m,keypair=l}end;return t
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top