-- Dakarun sealed loader (Lua/Luau). Paste into your executor and run. -- Signature is verified before anything executes. local _dkr_selfck = "2596533728" local _dkr_bridge = { http_get = httpget, hookfunction = hookfunction, request = request, game = game, workspace = workspace, fireproximityprompt = fireproximityprompt, getfpscap = getfpscap, setscriptable = setscriptable, getrenv = getrenv, loadstring = loadstring, toclipboard = toclipboard, shared = shared, gethui = gethui, getgenv = getgenv, iscclosure = iscclosure, islclosure = islclosure, getobjects = getobjects, fireclickdetector = fireclickdetector, httpget = httpget, setclipboard = setclipboard, getnilinstances = getnilinstances, setfpscap = setfpscap, getloadedmodules = getloadedmodules, newcclosure = newcclosure, getrunningscripts = getrunningscripts, isscriptable = isscriptable, identifyexecutor = identifyexecutor, getinstances = getinstances, } local _dkr_hostg = _G local _dkr_z0 = 506617437 local _dkr_z1 = 73337268 local _dkr_schar, _dkr_ssub, _dkr_tconcat = string.char, string.sub, table.concat local _dkr_print = print if not (_dkr_schar and _dkr_ssub and _dkr_tconcat and string.byte) then error("Dakarun: runtime unavailable") end local _dkr_gi = debug and debug.getinfo if _dkr_gi then local _dkr_hookok = true local function _dkr_isc(f) local _dkr_i = _dkr_gi(f, "S") return _dkr_i and _dkr_i.what == "C" end if not (_dkr_isc(_dkr_tconcat) and _dkr_isc(_dkr_schar) and _dkr_isc(_dkr_ssub) and _dkr_isc(string.byte)) then _dkr_hookok = false end _dkr_isc = nil if not _dkr_hookok then error("Dakarun: environment mismatch") end end _dkr_gi = nil local _dkr_vm = (function() local hl=-1 local hm=0 local hn=1 local ho=2 local hp=3 local hq=4 local hr=5 local hu=6 local hv=7 local hw=8 local hx=9 local hy=10 local hz=11 local ia=12 local ib=13 local ic=14 local id=15 local ie=16 local ig=17 local ih=18 local ii=19 local ij=20 local ik=21 local il=22 local im=23 local io=24 local ip=25 local iq=26 local ir=27 local is=28 local it=29 local iu=30 local iv=31 local iw=32 local ix=33 local iy=34 local iz=35 local ja=36 local jb=37 local jc=38 local jd=39 local je=40 local jf=41 local jg=42 local jh=43 local ji=jh+1 local jj={kind='__mark'}local jk=64 local jl=jk*12 local jm=jl/64 local jn=16 local function jo(jp,jq)local jr=jp[jq]+jp[jq+1]*256+jp[jq+2]*65536+jp[jq+3]*16777216 if jr>=2147483648 then jr=jr-4294967296 end return jr end local function js(jt)if jt==nil then return'nil'end local ju=type(jt)if ju=='number'then return'number'elseif ju=='string'then return'string'elseif ju=='boolean'then return'boolean'elseif ju=='userdata'then return'userdata'end if ju=='table'then local jv=jt.kind if jv=='table'then return'table'elseif jv=='__mark'then return'mark'end return'table'end return'function'end local function jw(jx)return jx==nil or jx==false end local function jy(jz)if jz==math.huge then return'inf'elseif jz==-math.huge then return'-inf'elseif jz~=jz then return'-nan'end return tostring(jz)end local function ka(kb)if kb==nil then return'nil'end local kc=type(kb)if kc=='number'then return jy(kb)elseif kc=='string'then return kb elseif kc=='boolean'then return kb and'true'or'false'elseif kc=='userdata'then return tostring(kb)elseif kc=='table'then local kd=kb.kind if kd=='table'then return'table'elseif kd=='__mark'then return'mark'end return tostring(kb)end return'function'end local function ke(kg)if type(kg)=='number'then return kg end if type(kg)=='string'then if kg:match('^%s*$')then return nil end return tonumber(kg)end return nil end local function ki(kj,kk)if js(kj)~=js(kk)then return false end return kj==kk end local function kl(km)local kn=type(km)if kn=='string'then return's:'..km elseif kn=='number'then return'n:'..jy(km)elseif kn=='boolean'then return'b:'..(km and'true'or'false')end error('table index is '..js(km),0)end local function ko(kp)local kq=kp:sub(1,2)local kr=kp:sub(3)if kq=='n:'then return tonumber(kr)elseif kq=='b:'then return kr=='true'end return kr end local function ks(kt)return type(kt)=='table'and kt.kind=='table'end local function ku(kv,kw)local kx=kv.n+1 kv.n=kx kv[kx]=kw return kv end local function ky(kz,la)local lb={n=0}for lc=la,kz.n do ku(lb,kz[lc])end return lb end local ld={}ld.__index=ld local le function ld.new(lf,lg,lh,li,lj)local lk=lf.m if#lk~=ji then error('bad opcode map',0)end local ll={}for lm=0,ji-1 do ll[lk[lm+1]+1]=lm end local self=setmetatable({},ld)self.inv=ll self.protos=lf.p self.stack={}self.sp=0 self.frames={}self.output={}self.globals={}local ln={}for lo,lp in ipairs(lf.p)do if lp.code~=nil then ln[lp]={plain=lp.code}else local lq=lo-1 local lr={}for ls=1,jn do lr[#lr+1]={idx=-1,dec={},last=0}end ln[lp]={cb=lp.cb,cbn=lp.cbn,n=lp.ncode,nonce={lq%256,math.floor(lq/256)%256,math.floor(lq/65536)%256,math.floor(lq/16777216)%256,0,0,0,0,0,0,0,0,},key=li,tick=0,loads=0,slots=lr,xor=lj,}end end self.readers=ln installBuiltins(self)if lg~=nil then le(self,lg,lh)end return self end function ld:fetch(lt,lu)if lt.plain then local lv=lt.plain[lu+1]if not lv then return nil end return lv[1],lv[2],lv[3]end if lu<0 or lu>=lt.n then return nil end local lw=math.floor(lu/jk)local lx=lt.slots local ly,lz=nil,lx[1]for ma=1,#lx do local mb=lx[ma]if mb.idx==lw then ly=mb break end if mb.lastlt.cbn then mf=lt.cbn-me end local mg=lt.cb local mh={}for mi=1,mf do mh[mi]=mg[me+mi]end local mj=lt.xor(lt.key,lt.nonce,mh,mf,lw*jm)for mk=1,mf do mh[mk]=0 end local ml=0 for mm=0,mf-12,12 do mc[ml+1]=jo(mj,mm+1)mc[ml+2]=jo(mj,mm+5)mc[ml+3]=jo(mj,mm+9)ml=ml+3 end for mn=1,mf do mj[mn]=0 end ly.idx=lw lt.loads=lt.loads+1 end lt.tick=lt.tick+1 ly.last=lt.tick local mo=(lu%jk)*3 local mp=ly.dec return mp[mo+1],mp[mo+2],mp[mo+3]end function ld:push(mq)local mr=self.sp+1 self.sp=mr self.stack[mr]=mq end function ld:pop()local ms=self.sp if ms==0 then self:fail('stack underflow')end local mt=self.stack[ms]self.stack[ms]=nil self.sp=ms-1 return mt end function ld:boxOf(mu,mv)local mw=mu.boxes[mv+1]if mw==nil then mw={v=nil}mu.boxes[mv+1]=mw end return mw end function ld:currentLine()local mx=self.frames[#self.frames]if not mx then return nil end return mx.proto.lines[mx.pc+1]end function ld:fail(my)local mz=self:currentLine()if mz~=nil then error('line '..mz..': '..my,0)else error(my,0)end end function ld:popToMark()local na={n=0}while true do local nb=self:pop()if nb==jj then break end na.n=na.n+1 na[na.n]=nb end local nc=na.n for nd=1,math.floor(nc/2)do local ne=nc-nd+1 na[nd],na[ne]=na[ne],na[nd]end return na end function ld:pushFrame(nf,ng,nh)local ni=nf.proto local nj={}for nk=1,ni.nparams do local nl=nil if nk<=ng.n then nl=ng[nk]end nj[nk]={v=nl}end local nm={n=0}if ni.vararg then for no=ni.nparams+1,ng.n do ku(nm,ng[no])end end self.frames[#self.frames+1]={closure=nf,proto=ni,reader=self.readers[ni],pc=0,base=self.sp,boxes=nj,varargs=nm,nwant=nh,}end function ld:callValue(np,nq,nr)local ns=type(np)=='table'and np.kind or nil if ns=='closure'then self:pushFrame(np,nq,nr)return end if ns=='builtin'then local nt=np.fn(self,nq)local nu=nt.n or#nt if nr==hl then for nv=1,nu do self:push(nt[nv])end else for nw=1,nr do if nw<=nu then self:push(nt[nw])else self:push(nil)end end end return end if type(np)=='function'then self:callHost(np,nq,nr)return end self:fail('attempt to call a '..js(np)..' value')end function ld:doReturn(nz)local oa=self.frames[#self.frames]self.frames[#self.frames]=nil if#self.frames==0 then return end for ob=self.sp,oa.base+1,-1 do self.stack[ob]=nil end self.sp=oa.base local oc=nz.n or#nz if oa.nwant==hl then for od=1,oc do self:push(nz[od])end else for oe=1,oa.nwant do if oe<=oc then self:push(nz[oe])else self:push(nil)end end end end function ld:run(of)while#self.frames>of do self:step()end end function ld:protectedCall(og,oh)local oi=type(og)=='table'and og.kind or nil if oi~='closure'and oi~='builtin'then return{ok=false,vals={n=1,'attempt to call a '..js(og)..' value'}}end local oj=#self.frames local ol=self.sp local om,on=pcall(function()self:callValue(og,oh,hl)self:run(oj)end)if not om then for oo=#self.frames,oj+1,-1 do self.frames[oo]=nil end for oq=self.sp,ol+1,-1 do self.stack[oq]=nil end self.sp=ol local os=type(on)=='string'and on or('error: '..tostring(on))return{ok=false,vals={n=1,os}}end local ot={n=0}for ou=ol+1,self.sp do ku(ot,self.stack[ou])end for ov=self.sp,ol+1,-1 do self.stack[ov]=nil end self.sp=ol return{ok=true,vals=ot}end function ld:getIndex(ow,ox)if ks(ow)then if type(ox)=='number'and ox==math.floor(ox)and ox>=1 then return ow.arr[ox]end return ow.map[kl(ox)]end if type(ow)=='table'or type(ow)=='userdata'then return ow[ox]end if type(ow)=='string'then local oy=self.globals.string if type(oy)=='table'then local oz=oy[ox]if oz~=nil then return oz end end self:fail('attempt to index a string value')end self:fail('attempt to index a '..js(ow)..' value')end function ld:setIndex(pa,pb,pd)if ks(pa)then if type(pb)=='number'and pb==math.floor(pb)and pb>=1 then pa.arr[pb]=pd if pb>pa.len then pa.len=pb end return end local pe=kl(pb)if pd==nil then pa.map[pe]=nil else pa.map[pe]=pd end return end if type(pa)=='table'or type(pa)=='userdata'then pa[pb]=self:toHost(pd)return end self:fail('attempt to index a '..js(pa)..' value')end function ld:step()local pf=self.frames[#self.frames]local pg,ph,pj=self:fetch(pf.reader,pf.pc)pf.pc=pf.pc+1 if pg==nil then self:fail('program counter out of range')end local pk=self.inv[pg+1]local pl=self.stack if pk==hm then self:push(pf.proto.consts[ph+1])elseif pk==hn then self:push(self:boxOf(pf,ph).v)elseif pk==ho then self:boxOf(pf,ph).v=self:pop()elseif pk==hp then local pm=pf.closure.upvals[ph+1]if not pm then self:fail('bad upvalue '..ph)end self:push(pm.v)elseif pk==hq then local pn=pf.closure.upvals[ph+1]if not pn then self:fail('bad upvalue '..ph)end pn.v=self:pop()elseif pk==hr then self:push(self.globals[pf.proto.consts[ph+1]])elseif pk==hu then self.globals[pf.proto.consts[ph+1]]=self:pop()elseif pk==je then self:boxOf(pf,pj).v=pf.proto.consts[ph+1]elseif pk==hv or pk==hw or pk==hx or pk==hy or pk==hz or pk==ia then local po=self:pop()local pp=self:pop()if type(pp)=='number'and type(po)=='number'then if pk==hv then self:push(pp+po)elseif pk==hw then self:push(pp-po)elseif pk==hx then self:push(pp*po)elseif pk==hy then self:push(pp/po)elseif pk==hz then self:push(pp-math.floor(pp/po)*po)else self:push(pp^po)end else local pq=ke(pp)local pr=ke(po)if pq==nil then self:fail('attempt to perform arithmetic on a '..js(pp)..' value')end if pr==nil then self:fail('attempt to perform arithmetic on a '..js(po)..' value')end if pk==hv then self:push(pq+pr)elseif pk==hw then self:push(pq-pr)elseif pk==hx then self:push(pq*pr)elseif pk==hy then self:push(pq/pr)elseif pk==hz then self:push(pq-math.floor(pq/pr)*pr)else self:push(pq^pr)end end elseif pk==jf or pk==jg or pk==jh then local ps=self:boxOf(pf,ph).v local pu=self:boxOf(pf,pj).v if type(ps)=='number'and type(pu)=='number'then if pk==jf then self:push(ps+pu)elseif pk==jg then self:push(ps-pu)else self:push(ps*pu)end else local pv=ke(ps)local pw=ke(pu)if pv==nil then self:fail('attempt to perform arithmetic on a '..js(ps)..' value')end if pw==nil then self:fail('attempt to perform arithmetic on a '..js(pu)..' value')end if pk==jf then self:push(pv+pw)elseif pk==jg then self:push(pv-pw)else self:push(pv*pw)end end elseif pk==ib then local px=self:pop()if type(px)=='number'then self:push(-px)else local py=ke(px)if py==nil then self:fail('attempt to perform arithmetic on a '..js(px)..' value')end self:push(-py)end elseif pk==ic then local pz=self:pop()local qa=self:pop()local qb,qc=type(qa),type(pz)if(qb~='string'and qb~='number')or(qc~='string'and qc~='number')then local qd=(qb~='string'and qb~='number')and js(qa)or js(pz)self:fail('attempt to concatenate a '..qd..' value')end self:push(ka(qa)..ka(pz))elseif pk==id then local qe=self:pop()if type(qe)=='string'then self:push(#qe)elseif ks(qe)then self:push(qe.len)elseif type(qe)=='table'then self:push(#qe)else self:fail('attempt to get length of a '..js(qe)..' value')end elseif pk==ie then self:push(jw(self:pop()))elseif pk==ig then local qf=self:pop()local qg=self:pop()self:push(ki(qg,qf))elseif pk==ih or pk==ii then local qh=self:pop()local qi=self:pop()local qj,qk=type(qi),type(qh)if qj=='number'and qk=='number'then self:push((pk==ih and qi1 then local sf=ke(sd[2])if type(se)=='string'and sf~=nil then local sg=se:match('^%s*(.-)%s*$')local sh=tonumber(sg,sf)return rp(sh)end return rp(nil)end local si=ke(se)return rp(si)end)rt.pairs=rm('pairs',function(sj,sl)local sm=sl[1]local sn={n=0}local so if ks(sm)then for sq=1,sm.len do if sm.arr[sq]~=nil then ku(sn,sq)end end for sr in pairs(sm.map)do ku(sn,ko(sr))end so=function(ss)local su=nil if type(ss)=='number'then su=sm.arr[ss]end if su==nil then su=sm.map[kl(ss)]end return su end elseif type(sm)=='table'then for sw in pairs(sm)do ku(sn,sw)end so=function(sx)return sm[sx]end else sj:fail("bad argument #1 to 'pairs' (table expected, got "..js(sm)..")")end local sy={i=0}return rp(rm('pairsnext',function()sy.i=sy.i+1 if sy.i>sn.n then return rr()end local sz=sn[sy.i]return{n=2,sz,so(sz)}end))end)rt.ipairs=rm('ipairs',function(ta,tb)local tc=tb[1]local td if ks(tc)then td=function(te)return tc.arr[te]end elseif type(tc)=='table'then td=function(tf)return tc[tf]end else ta:fail("bad argument #1 to 'ipairs' (table expected, got "..js(tc)..")")end local tg={i=1}return rp(rm('ipairsnext',function()local th=td(tg.i)if th==nil then return rr()end local ti=tg.i tg.i=tg.i+1 return{n=2,ti,th}end))end)rt.error=rm('error',function(tj,tk)local tl=tk[1]error(tl==nil and'error'or ka(tl),0)end)rt.assert=rm('assert',function(tm,tn)local to=tn[1]if jw(to)then error(tn.n>1 and ka(tn[2])or'assertion failed!',0)end return rp(to)end)rt.select=rm('select',function(tp,tq)local tr=tq[1]local ts=tq.n-1 if tr=='#'then return rp(ts)end local tt=ke(tr)if tt==nil or tt~=math.floor(tt)then tp:fail("bad argument #1 to 'select' (number expected, got "..js(tr)..")")end if tt<1 or tt>ts+1 then tp:fail("bad argument #1 to 'select' (index out of range)")end local tu={n=0}for tv=tt,ts do ku(tu,tq[tv+1])end return tu end)rt.unpack=rm('unpack',function(tw,tz)local ua=tz[1]if not ks(ua)then tw:fail("bad argument #1 to 'unpack' (table expected, got "..js(ua)..")")end local ub=(tz.n>1)and ke(tz[2])or 1 local uc=(tz.n>2)and ke(tz[3])or ua.len ub=(ub==nil)and 1 or math.floor(ub)uc=(uc==nil)and ua.len or math.floor(uc)local ud={n=0}for ue=ub,uc do ku(ud,ua.arr[ue])end return ud end)rt.pcall=rm('pcall',function(uf,ug)local uh=uf:protectedCall(ug[1],ky(ug,2))local ui={n=0}ku(ui,uh.ok)for uj=1,uh.vals.n do ku(ui,uh.vals[uj])end return ui end)rt.xpcall=rm('xpcall',function(uk,ul)local um=ul[1]local un=ul[2]local uo=type(um)=='table'and um.kind or nil local up=type(un)=='table'and un.kind or nil if uo~='closure'and uo~='builtin'then uk:fail("bad argument #1 to 'xpcall' ("..js(um).." expected function)")end if up~='closure'and up~='builtin'then uk:fail("bad argument #2 to 'xpcall' ("..js(un).." expected function)")end local uq=uk:protectedCall(um,ky(ul,3))if uq.ok then local ur={n=0}ku(ur,true)for us=1,uq.vals.n do ku(ur,uq.vals[us])end return ur end local ut=uq.vals[1]local uu=#uk.frames local uv=uk.sp local uw,ux=pcall(function()uk:callValue(un,{n=1,ut},hl)uk:run(uu)end)if not uw then for uy=#uk.frames,uu+1,-1 do uk.frames[uy]=nil end for uz=uk.sp,uv+1,-1 do uk.stack[uz]=nil end uk.sp=uv error(type(ux)=='string'and ux or tostring(ux),0)end local va={n=0}for vb=uv+1,uk.sp do ku(va,uk.stack[vb])end for vc=uk.sp,uv+1,-1 do uk.stack[vc]=nil end uk.sp=uv return{n=2,false,va[1]}end)do local vd=string local ve=table local function vf(vg,vh,vi)if type(vg)~='string'then vg=tostring(vg)end vh=tonumber(vh)if vh==nil then error("bad argument #2 to 'rep' (number expected)",2)end vh=math.floor(vh)if vh<1 then return''end if vi==nil or vi==''then return vd.rep(vg,vh)end if type(vi)~='string'then vi=tostring(vi)end local vj={}for vk=1,vh do vj[vk]=vg end return ve.concat(vj,vi)end rt.string={byte=vd.byte,char=vd.char,find=vd.find,format=vd.format,gmatch=vd.gmatch,gsub=vd.gsub,len=vd.len,lower=vd.lower,match=vd.match,rep=vf,reverse=vd.reverse,sub=vd.sub,upper=vd.upper,}end end le=function(vl,vn,vo)local vp=vl.globals vp.getgenv=rm('getgenv',function(vq,vr)return rp(vq.globals)end)vp.getrenv=rm('getrenv',function(vs,vt)return rp(vo)end)for vu,vv in pairs(vn)do if vu~='getgenv'and vu~='getrenv'and vp[vu]==nil and vv~=nil then vp[vu]=vv end end end local function vw(...)return{n=select('#',...),...}end function ld:toHost(vx,vy)if type(vx)~='table'then return vx end local vz=vx.kind if vz=='table'then vy=vy or{}if vy[vx]then return vy[vx]end local wa={}vy[vx]=wa for wb=1,vx.len do if vx.arr[wb]~=nil then wa[wb]=self:toHost(vx.arr[wb],vy)end end for wc,wd in pairs(vx.map)do wa[self:toHost(ko(wc),vy)]=self:toHost(wd,vy)end return wa elseif vz=='closure'or vz=='builtin'then local we=self local wf=vx return function(...)local wg=select('#',...)local wh={n=wg}for wi=1,wg do wh[wi]=we:toVM(select(wi,...))end local wj=we:protectedCall(wf,wh)if not wj.ok then error(wj.vals[1],0)end local wk=table.unpack or unpack return wk(wj.vals,1,wj.vals.n)end end return vx end function ld:toVM(wl)return wl end function ld:callHost(wm,wn,wo)local wp={}for wq=1,wn.n do wp[wq]=self:toHost(wn[wq])end local wr=table.unpack or unpack local ws,wt=pcall(function()return vw(wm(wr(wp,1,wn.n)))end)if not ws then self:fail(wt)end local wu=wt.n if wo==hl then for wv=1,wu do self:push(wt[wv])end else for ww=1,wo do if ww<=wu then self:push(wt[ww])else self:push(nil)end end end end local function wx(wy,wz,xa,xb,xc)local xd=ld.new(wy,wz,xa,xb,xc)local xe={kind='closure',proto=wy.p[1],upvals={}}xd:pushFrame(xe,{n=0},0)local xf,xg=pcall(xd.run,xd,0)local xh=xd.output for xi,xj in pairs(xd.readers)do if xj.slots then for xk,xl in ipairs(xj.slots)do for xm=1,#xl.dec do xl.dec[xm]=0 end xl.idx=-1 end end end if not xf then error(xg,0)end return xh end return{VM=ld,execute=wx,MULTRET=hl,OP_COUNT=ji,typeOf=js,} end)() local _dkr_ed = (function() local cte=4294967296 local ctf,ctg,cth,cti,ctj,ctk if type(bit32)=='table'then ctf=bit32.bxor ctg=bit32.band cth=bit32.bor cti=bit32.bnot ctj=bit32.rshift ctk=bit32.lshift else local function ctl(ctm)return function(ctn,cto)local ctp,ctq=0,1 for ctr=1,32 do local cts,ctt=ctn%2,cto%2 if ctm(cts,ctt)then ctp=ctp+ctq end ctn=(ctn-cts)/2 cto=(cto-ctt)/2 ctq=ctq*2 end return ctp end end ctf=ctl(function(ctu,ctv)return ctu~=ctv end)ctg=ctl(function(ctw,ctx)return ctw==1 and ctx==1 end)cth=ctl(function(cty,ctz)return cty==1 or ctz==1 end)cti=function(cua)return 4294967295-cua end ctj=function(cub,cuc)return math.floor(cub/(2^cuc))end ctk=function(cud,cue)if cue==0 then return cud end return(cud%(2^(32-cue)))*(2^cue)end end local function cuf(cug,cuh)return{h=cug%cte,l=cuh%cte}end local function cui(cuj,cuk)local cul=cuj.l+cuk.l local cum=0 if cul>=cte then cul=cul-cte;cum=1 end local cun=cuj.h+cuk.h+cum if cun>=cte then cun=cun-cte end return{h=cun,l=cul}end local function cuo(cup,cuq)return{h=ctf(cup.h,cuq.h),l=ctf(cup.l,cuq.l)}end local function cur(cus,cut)return{h=ctg(cus.h,cut.h),l=ctg(cus.l,cut.l)}end local function cuu(cuv)return{h=cti(cuv.h),l=cti(cuv.l)}end local function cuw(cux,cuy)cuy=cuy%64 if cuy==0 then return{h=cux.h,l=cux.l}end if cuy==32 then return{h=cux.l,l=cux.h}end if cuy<32 then return{h=cth(ctj(cux.h,cuy),ctk(cux.l,32-cuy)),l=cth(ctj(cux.l,cuy),ctk(cux.h,32-cuy)),}end local cuz=cuy-32 return{h=cth(ctj(cux.l,cuz),ctk(cux.h,32-cuz)),l=cth(ctj(cux.h,cuz),ctk(cux.l,32-cuz)),}end local function cva(cvb,cvc)return{h=ctj(cvb.h,cvc),l=cth(ctj(cvb.l,cvc),ctk(cvb.h,32-cvc)),}end local function cvd(cve,cvf,cvg)return cuo(cur(cve,cvf),cur(cuu(cve),cvg))end local function cvh(cvi,cvj,cvk)return cuo(cuo(cur(cvi,cvj),cur(cvi,cvk)),cur(cvj,cvk))end local function cvl(cvm)return cuo(cuo(cuw(cvm,28),cuw(cvm,34)),cuw(cvm,39))end local function cvn(cvo)return cuo(cuo(cuw(cvo,14),cuw(cvo,18)),cuw(cvo,41))end local function cvp(cvq)return cuo(cuo(cuw(cvq,1),cuw(cvq,8)),cva(cvq,7))end local function cvr(cvs)return cuo(cuo(cuw(cvs,19),cuw(cvs,61)),cva(cvs,6))end local cvt={'428a2f98d728ae22','7137449123ef65cd','b5c0fbcfec4d3b2f','e9b5dba58189dbbc','3956c25bf348b538','59f111f1b605d019','923f82a4af194f9b','ab1c5ed5da6d8118','d807aa98a3030242','12835b0145706fbe','243185be4ee4b28c','550c7dc3d5ffb4e2','72be5d74f27b896f','80deb1fe3b1696b1','9bdc06a725c71235','c19bf174cf692694','e49b69c19ef14ad2','efbe4786384f25e3','0fc19dc68b8cd5b5','240ca1cc77ac9c65','2de92c6f592b0275','4a7484aa6ea6e483','5cb0a9dcbd41fbd4','76f988da831153b5','983e5152ee66dfab','a831c66d2db43210','b00327c898fb213f','bf597fc7beef0ee4','c6e00bf33da88fc2','d5a79147930aa725','06ca6351e003826f','142929670a0e6e70','27b70a8546d22ffc','2e1b21385c26c926','4d2c6dfc5ac42aed','53380d139d95b3df','650a73548baf63de','766a0abb3c77b2a8','81c2c92e47edaee6','92722c851482353b','a2bfe8a14cf10364','a81a664bbc423001','c24b8b70d0f89791','c76c51a30654be30','d192e819d6ef5218','d69906245565a910','f40e35855771202a','106aa07032bbd1b8','19a4c116b8d2d0c8','1e376c085141ab53','2748774cdf8eeb99','34b0bcb5e19b48a8','391c0cb3c5c95a63','4ed8aa4ae3418acb','5b9cca4f7763e373','682e6ff3d6b2b8a3','748f82ee5defb2fc','78a5636f43172f60','84c87814a1f0ab72','8cc702081a6439ec','90befffa23631e28','a4506cebde82bde9','bef9a3f7b2c67915','c67178f2e372532b','ca273eceea26619c','d186b8c721c0c207','eada7dd6cde0eb1e','f57d4f7fee6ed178','06f067aa72176fba','0a637dc5a2c898a6','113f9804bef90dae','1b710b35131c471b','28db77f523047d84','32caab7b40c72493','3c9ebe0a15c9bebc','431d67c49c100d4c','4cc5d4becb3e42b6','597f299cfc657e2a','5fcb6fab3ad6faec','6c44198c4a475817',}local cvu={}for cvv=1,80 do local cvw=cvt[cvv]cvu[cvv]=cuf(tonumber(cvw:sub(1,8),16),tonumber(cvw:sub(9,16),16))end local cvx={'6a09e667f3bcc908','bb67ae8584caa73b','3c6ef372fe94f82b','a54ff53a5f1d36f1','510e527fade682d1','9b05688c2b3e6c1f','1f83d9abfb41bd6b','5be0cd19137e2179',}local function cvy(cvz)local cwa=#cvz local cwb=(cwa*8)%cte local cwc=math.floor(cwa/536870912)local cwd=128-((cwa+1+16)%128)if cwd==128 then cwd=0 end local cwe=cwa+1+cwd+16 local cwf={}for cwg=1,cwa do cwf[cwg]=cvz:byte(cwg)end cwf[cwa+1]=128 for cwh=cwa+2,cwa+1+cwd do cwf[cwh]=0 end for cwi=1,8 do cwf[cwa+1+cwd+cwi]=0 end cwf[cwe-7]=math.floor(cwc/16777216)%256 cwf[cwe-6]=math.floor(cwc/65536)%256 cwf[cwe-5]=math.floor(cwc/256)%256 cwf[cwe-4]=cwc%256 cwf[cwe-3]=math.floor(cwb/16777216)%256 cwf[cwe-2]=math.floor(cwb/65536)%256 cwf[cwe-1]=math.floor(cwb/256)%256 cwf[cwe]=cwb%256 local cwj={}for cwk=1,8 do local cwl=cvx[cwk]cwj[cwk]=cuf(tonumber(cwl:sub(1,8),16),tonumber(cwl:sub(9,16),16))end local cwm={}for cwn=0,cwe/128-1 do local cwo=cwn*128 for cwp=1,16 do local cwq=cwo+(cwp-1)*8 local cwr=cwf[cwq+1]*16777216+cwf[cwq+2]*65536+cwf[cwq+3]*256+cwf[cwq+4]local cws=cwf[cwq+5]*16777216+cwf[cwq+6]*65536+cwf[cwq+7]*256+cwf[cwq+8]cwm[cwp]=cuf(cwr,cws)end for cwt=17,80 do cwm[cwt]=cui(cui(cvr(cwm[cwt-2]),cwm[cwt-7]),cui(cvp(cwm[cwt-15]),cwm[cwt-16]))end local cwu,cwv,cww,cwx,cwy,cwz,cxa,cxb=cwj[1],cwj[2],cwj[3],cwj[4],cwj[5],cwj[6],cwj[7],cwj[8]for cxc=1,80 do local cxd=cui(cui(cui(cui(cxb,cvn(cwy)),cvd(cwy,cwz,cxa)),cvu[cxc]),cwm[cxc])local cxe=cui(cvl(cwu),cvh(cwu,cwv,cww))cxb=cxa;cxa=cwz;cwz=cwy;cwy=cui(cwx,cxd)cwx=cww;cww=cwv;cwv=cwu;cwu=cui(cxd,cxe)end cwj[1]=cui(cwj[1],cwu)cwj[2]=cui(cwj[2],cwv)cwj[3]=cui(cwj[3],cww)cwj[4]=cui(cwj[4],cwx)cwj[5]=cui(cwj[5],cwy)cwj[6]=cui(cwj[6],cwz)cwj[7]=cui(cwj[7],cxa)cwj[8]=cui(cwj[8],cxb)end local cxf={}for cxg=1,8 do local cxh=cwj[cxg]cxf[#cxf+1]=string.char(math.floor(cxh.h/16777216)%256,math.floor(cxh.h/65536)%256,math.floor(cxh.h/256)%256,cxh.h%256,math.floor(cxh.l/16777216)%256,math.floor(cxh.l/65536)%256,math.floor(cxh.l/256)%256,cxh.l%256)end return table.concat(cxf)end local function cxi()return{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}end local function cxj(cxk)local cxl=cxi()for cxm=1,16 do cxl[cxm]=cxk[cxm]end return cxl end local cxn={65517,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,65535,32767}local function cxo(cxp)for cxq=1,4 do for cxr=1,16 do local cxs=cxp[cxr]if cxs>=65536 or cxs<0 then local cxt=math.floor(cxs/65536)cxp[cxr]=cxs-cxt*65536 if cxr==16 then cxp[1]=cxp[1]+cxt*38 else cxp[cxr+1]=cxp[cxr+1]+cxt end end end end local cxu=math.floor(cxp[16]/32768)cxp[16]=cxp[16]-cxu*32768 cxp[1]=cxp[1]+cxu*19 for cxv=1,3 do local cxw=cxp[cxv]if cxw>=65536 then local cxx=math.floor(cxw/65536)cxp[cxv]=cxw-cxx*65536 cxp[cxv+1]=cxp[cxv+1]+cxx end end local cxy={}for cxz=1,4 do local cya=0 for cyb=1,16 do local cyc=cxp[cyb]-cxn[cyb]-cya if cyc<0 then cyc=cyc+65536;cya=1 else cya=0 end cxy[cyb]=cyc end if cya==0 then for cyd=1,16 do cxp[cyd]=cxy[cyd]end else break end end return cxp end local function cye(cyf,cyg)local cyh=cxi()for cyi=1,16 do cyh[cyi]=cyf[cyi]+cyg[cyi]end return cxo(cyh)end local function cyj(cyk,cyl)local cym=cxi()for cyn=1,16 do cym[cyn]=cyk[cyn]-cyl[cyn]end return cxo(cym)end local function cyo(cyp,cyq)local cyr={}for cys=1,32 do cyr[cys]=0 end for cyt=1,16 do local cyu=cyp[cyt]if cyu~=0 then for cyv=1,16 do cyr[cyt+cyv-1]=cyr[cyt+cyv-1]+cyu*cyq[cyv]end end end for cyw=32,17,-1 do local cyx=cyr[cyw]if cyx~=0 then cyr[cyw-16]=cyr[cyw-16]+cyx*38 cyr[cyw]=0 end end local cyy=cxi()for cyz=1,16 do cyy[cyz]=cyr[cyz]end return cxo(cyy)end local function cza(czb)return cyo(czb,czb)end local function czc(czd)local cze=cxj(czd)cxo(cze)for czf=1,16 do if cze[czf]~=0 then return false end end return true end local function czg(czh,czi)local czj=cxj(czh)local czk=cxj(czi)cxo(czj)cxo(czk)for czl=1,16 do if czj[czl]~=czk[czl]then return false end end return true end local function czm(czn,czo)local czp=cxi()czp[1]=1 for czq=1,#czo do czp=cza(czp)if czo[czq]==1 then czp=cyo(czp,czn)end end return czp end local czr={}for czs=254,0,-1 do if czs>=5 then czr[#czr+1]=1 elseif czs==3 or czs==1 or czs==0 then czr[#czr+1]=1 else czr[#czr+1]=0 end end local czt={}for czu=251,0,-1 do czt[#czt+1]=(czu==0)and 0 or 1 end local czv={}for czw=252,0,-1 do if czw>=3 then czv[#czv+1]=1 elseif czw==3 or czw==1 or czw==0 then czv[#czv+1]=1 else czv[#czv+1]=0 end end local function czx(czy)return czm(czy,czr)end local function czz(daa)if#daa~=32 then return nil end local dab={daa:byte(1,32)}if dab[32]>=128 then return nil end if dab[32]==127 then local dac=true for dad=2,31 do if dab[dad]~=255 then dac=false;break end end if dac and dab[1]>=236 then return nil end end local dae=cxi()for daf=1,16 do dae[daf]=dab[2*daf-1]+dab[2*daf]*256 end return dae end local function dag(dah)local dai=cxj(dah)cxo(dai)local daj={}for dak=1,16 do daj[#daj+1]=string.char(dai[dak]%256,math.floor(dai[dak]/256)%256)end return table.concat(daj)end local function dal(dam)local dan=cxi()dan[1]=dam%65536 dan[2]=math.floor(dam/65536)%65536 return dan end local dao=cyj(cxi(),cyo(dal(121665),czx(dal(121666))))local dap=cye(dao,dao)local daq=czm(dal(2),czv)local function dar(das,dat,dau,dav)return{X=das,Y=dat,Z=dau,T=dav}end local function daw()local dax=cxi()local day=cxi()day[1]=1 return dar(dax,cxj(day),cxj(day),cxi())end local function daz(dba,dbb)local dbc=cyo(cyj(dba.Y,dba.X),cyj(dbb.Y,dbb.X))local dbd=cyo(cye(dba.Y,dba.X),cye(dbb.Y,dbb.X))local dbe=cyo(cyo(dba.T,dap),dbb.T)local dbf=cye(cyo(dba.Z,dbb.Z),cyo(dba.Z,dbb.Z))local dbg=cyj(dbd,dbc)local dbh=cyj(dbf,dbe)local dbi=cye(dbf,dbe)local dbj=cye(dbd,dbc)return dar(cyo(dbg,dbh),cyo(dbi,dbj),cyo(dbh,dbi),cyo(dbg,dbj))end local function dbk(dbl,dbm)return czg(cyo(dbl.X,dbm.Z),cyo(dbm.X,dbl.Z))and czg(cyo(dbl.Y,dbm.Z),cyo(dbm.Y,dbl.Z))end local function dbn(dbo,dbp)local dbq=daw()for dbr=32,1,-1 do local dbs=dbo:byte(dbr)for dbt=7,0,-1 do dbq=daz(dbq,dbq)if math.floor(dbs/(2^dbt))%2==1 then dbq=daz(dbq,dbp)end end end return dbq end local function dbu(dbv)local dbw=czx(dbv.Z)local dbx=cyo(dbv.X,dbw)local dby=cyo(dbv.Y,dbw)local dbz=dag(dby)local dca=dag(dbx)local dcb=dca:byte(1)%2 local dcc=dbz:byte(32)dbz=dbz:sub(1,31)..string.char(dcc+(dcb==1 and 128 or 0))return dbz end local function dcd()local dce=cxi()for dcf=1,15 do dce[dcf]=65535 end dce[1]=65517 dce[16]=32767 return dce end local function dcg(dch)if#dch~=32 then return nil end local dci=(dch:byte(32)>=128)and 1 or 0 local dcj=dch:sub(1,31)..string.char(dch:byte(32)%128)local dck=czz(dcj)if not dck then return nil end local dcl=cza(dck)local dcm=cyo(cyj(dcl,dal(1)),czx(cye(cyo(dao,dcl),dal(1))))local dcn if czc(dcm)then if dci==1 then return nil end dcn=cxi()else dcn=czm(dcm,czt)if not czg(cza(dcn),dcm)then dcn=cyo(dcn,daq)if not czg(cza(dcn),dcm)then return nil end end local dco=dag(dcn)if(dco:byte(1)%2)~=dci then dcn=cyj(dcd(),dcn)end end return dar(dcn,dck,dal(1),cyo(dcn,dck))end local dcp='5866666666666666666666666666666666666666666666666666666666666666'local function dcq(dcr)local dcs={}for dct=1,#dcr,2 do dcs[#dcs+1]=string.char(tonumber(dcr:sub(dct,dct+1),16))end return table.concat(dcs)end local function dcu(dcv)local dcw={}for dcx=1,#dcv do dcw[#dcw+1]=string.format('%02x',dcv:byte(dcx))end return table.concat(dcw)end local dcy=dcg(dcq(dcp))if not dcy then error('bad base point',0)end local dcz='edd3f55c1a631258d69cf7a2def9de1400000000000000000000000000000010'local dda=dcq(dcz)local function ddb(ddc,ddd)for dde=#ddc,1,-1 do local ddf,ddg=ddc:byte(dde),ddd:byte(dde)if ddf~=ddg then return ddf>ddg end end return true end local function ddh(ddi)local ddj={}for ddk=1,16 do ddj[ddk]=dda:byte(2*ddk-1)+dda:byte(2*ddk)*256 end local ddl=cxi()for ddm=64,1,-1 do local ddn=ddi:byte(ddm)for ddo=7,0,-1 do local ddp=math.floor(ddn/(2^ddo))%2 for ddq=1,16 do local ddr=ddl[ddq]*2+ddp ddl[ddq]=ddr%65536 ddp=math.floor(ddr/65536)end local dds=true for ddt=16,1,-1 do if ddl[ddt]~=ddj[ddt]then dds=ddl[ddt]>ddj[ddt];break end end if dds then local ddu=0 for ddv=1,16 do local ddw=ddl[ddv]-ddj[ddv]-ddu if ddw<0 then ddw=ddw+65536;ddu=1 else ddu=0 end ddl[ddv]=ddw end end end end return ddl end local function ddx(ddy)return dag(ddy)end local function ddz(dea,deb,dec)if#dec~=64 or#dea~=32 then return false end local ded=dec:sub(1,32)local dee=dec:sub(33,64)if ddb(dee,dda)then return false end local def=dcg(ded)if not def then return false end local deg=dcg(dea)if not deg then return false end local deh=cvy(ded..dea..deb)local dei=ddh(deh)local dej=dbn(dee,dcy)local dek=dbn(ddx(dei),deg)return dbk(dej,daz(def,dek))end return{sha512=cvy,verify=ddz,hex_to_bytes=dcq,bytes_to_hex=dcu,} end)() local function _dkr_json(bti)local btj=1 local function btk()while btj<=#bti and bti:sub(btj,btj):match("%s")do btj=btj+1 end end local btl local function btm()btj=btj+1 local btn={}while true do local bto=bti:sub(btj,btj)if bto=='"'then btj=btj+1 break end if bto=="\\"then local btp=bti:sub(btj+1,btj+1)if btp=="n"then btn[#btn+1]="\n"elseif btp=="t"then btn[#btn+1]="\t"elseif btp=="r"then btn[#btn+1]="\r"elseif btp=='"'then btn[#btn+1]='"'elseif btp=="\\"then btn[#btn+1]="\\"elseif btp=="u"then local btq=tonumber(bti:sub(btj+2,btj+5),16)or 63 if btq<128 then btn[#btn+1]=string.char(btq)else btn[#btn+1]="?"end btj=btj+4 end btj=btj+2 else btn[#btn+1]=bto btj=btj+1 end end return table.concat(btn)end local function btr()local bts=bti:match("^-?%d+%.?%d*[eE]?[+-]?%d*",btj)btj=btj+#bts return tonumber(bts)end local function btt()btj=btj+1 local btu={}local btv=0 btk()if bti:sub(btj,btj)=="]"then btj=btj+1 return btu end while true do btv=btv+1 btu[btv]=btl()btk()local btw=bti:sub(btj,btj)if btw=="]"then btj=btj+1 break end btj=btj+1 end return btu end local function btx()btj=btj+1 local bty={}btk()if bti:sub(btj,btj)=="}"then btj=btj+1 return bty end while true do btk()local btz=btm()btk()btj=btj+1 bty[btz]=btl()btk()local bua=bti:sub(btj,btj)if bua=="}"then btj=btj+1 break end btj=btj+1 end return bty end btl=function()btk()local bub=bti:sub(btj,btj)if bub=='"'then return btm()end if bub=="{"then return btx()end if bub=="["then return btt()end if bti:sub(btj,btj+3)=="true"then btj=btj+4 return true end if bti:sub(btj,btj+4)=="false"then btj=btj+5 return false end if bti:sub(btj,btj+3)=="null"then btj=btj+4 return nil end return btr()end local buc=btl()return buc end local function _dkr_bxor(a, b) local r, bit = 0, 1 for _ = 1, 8 do local abit, bbit = a % 2, b % 2 if abit ~= bbit then r = r + bit end a = (a - abit) / 2 b = (b - bbit) / 2 bit = bit * 2 end return r end local _dkr_M32 = 4294967296 local function _dkr_mul32(a, b) a = a % _dkr_M32 b = b % _dkr_M32 local a0 = a % 65536 local a1 = (a - a0) / 65536 local b0 = b % 65536 local b1 = (b - b0) / 65536 local p0 = a0 * b0 local p1 = a1 * b0 + a0 * b1 return (p0 + (p1 % 65536) * 65536) % _dkr_M32 end local function _dkr_xor32(a, b) a = a % _dkr_M32 b = b % _dkr_M32 local r, bit = 0, 1 for _ = 1, 32 do local abit = a % 2 local bbit = b % 2 if abit ~= bbit then r = r + bit end a = (a - abit) / 2 b = (b - bbit) / 2 bit = bit * 2 end return r end local function _dkr_fnv(bytes, n) local h = 2166136261 for i = 1, n do h = _dkr_xor32(h, bytes[i]) h = _dkr_mul32(h, 16777619) end return h end local function _dkr_rng(seed) local s = seed % _dkr_M32 if s == 0 then s = 2654435769 end return function() s = _dkr_xor32(s, _dkr_mul32(s, 8192)) s = _dkr_xor32(s, math.floor(s / 131072)) s = _dkr_xor32(s, _dkr_mul32(s, 32)) return s end end local _dkr_b64chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" local _dkr_b64map = {} for i = 1, #_dkr_b64chars do _dkr_b64map[_dkr_b64chars:sub(i, i)] = i - 1 end local function _dkr_b64d(s) local out = {} local n = 0 local i = 1 while i <= #s do local c1 = _dkr_b64map[s:sub(i, i)] or 0 local c2 = _dkr_b64map[s:sub(i + 1, i + 1)] or 0 local c3 = _dkr_b64map[s:sub(i + 2, i + 2)] or 0 local c4 = _dkr_b64map[s:sub(i + 3, i + 3)] or 0 local w = c1 * 262144 + c2 * 4096 + c3 * 64 + c4 n = n + 1 out[n] = math.floor(w / 65536) % 256 if s:sub(i + 2, i + 2) ~= "=" then n = n + 1 out[n] = math.floor(w / 256) % 256 end if s:sub(i + 3, i + 3) ~= "=" then n = n + 1 out[n] = w % 256 end i = i + 4 end return out, n end local function _dkr_ckey(keystr) local pre = {} local n = 0 for i = 1, #keystr do n = n + 1 pre[n] = string.byte(keystr, i) end local label = "dkr-const-v1" for i = 1, #label do n = n + 1 pre[n] = string.byte(label, i) end local rng = _dkr_rng(_dkr_fnv(pre, n)) local ck = {} for i = 1, 32 do ck[i] = rng() % 256 end for i = 1, n do pre[i] = 0 end return ck end -- Code-key derivation for incremental instruction decoding. Mirrors -- src/codecrypt.ts deriveCodeKey exactly: FNV-1a(master || "dkr-code-v1") -- seeding xorshift32, low byte per word. Validated standalone under lua5.1 -- alongside _dkr_ckey; any change must re-pass that check. local function _dkr_codekey(keystr) local pre = {} local n = 0 for i = 1, #keystr do n = n + 1 pre[n] = string.byte(keystr, i) end local label = "dkr-code-v1" for i = 1, #label do n = n + 1 pre[n] = string.byte(label, i) end local rng = _dkr_rng(_dkr_fnv(pre, n)) local ck = {} for i = 1, 32 do ck[i] = rng() % 256 end for i = 1, n do pre[i] = 0 end return ck end -- Stone 7: outer-key derivation executed at stub runtime. Deliberately NOT -- the low-byte-only pattern of _dkr_ckey/_dkr_codekey: each key byte is -- lowByte(xorshift()) XOR highByte(next xorshift()), so an attacker reusing -- their existing inner-KDF reimplementation derives the wrong key here. -- Bit-identical mirror of deriveOuterKey in src/constcrypt.ts. local function _dkr_outerkey(seedstr) local pre = {} local n = 0 for i = 1, #seedstr do n = n + 1 pre[n] = string.byte(seedstr, i) end local label = "dkr-outer-v1" for i = 1, #label do n = n + 1 pre[n] = string.byte(label, i) end local rng = _dkr_rng(_dkr_fnv(pre, n)) local ok = {} for i = 1, 32 do local a = rng() local b = rng() ok[i] = _dkr_xor32(a % 256, math.floor(b / 16777216) % 256) end for i = 1, n do pre[i] = 0 end return ok end local function _dkr_stream(ck, pi0, ci0, n) local pre = {} local m = 0 for i = 1, 32 do m = m + 1 pre[m] = ck[i] end local v = pi0 for _ = 1, 4 do m = m + 1 pre[m] = v % 256 v = math.floor(v / 256) end v = ci0 for _ = 1, 4 do m = m + 1 pre[m] = v % 256 v = math.floor(v / 256) end local rng = _dkr_rng(_dkr_fnv(pre, m)) local ks = {} for i = 1, n do ks[i] = rng() % 256 end for i = 1, m do pre[i] = 0 end return ks end local function _dkr_constdec(chunk, ck) for pi = 1, #chunk.p do local cs = chunk.p[pi].consts for ci = 1, #cs do local c = cs[ci] if type(c) == "table" and type(c.e) == "string" then local eb, en = _dkr_b64d(c.e) if en > 0 then local ks = _dkr_stream(ck, pi - 1, ci - 1, en) local db = {} for i = 1, en do db[i] = _dkr_schar(_dkr_bxor(eb[i], ks[i])) end cs[ci] = table.concat(db) for i = 1, en do eb[i] = 0 ks[i] = 0 db[i] = 0 end else cs[ci] = "" end end end end end -- Dakarun ChaCha20 (RFC 8439) — pure Lua 5.1, NO bitwise operators. -- -- All arithmetic uses doubles as exact integers (< 2^53): -- add mod 2^32 : (a + b) % 2^32 (a,b < 2^32, sum < 2^33 — exact) -- xor32 : byte-wise via a 65536-entry lookup table built once -- rotl : (a * 2^n) % 2^32 + floor(a / 2^(32-n)) (a*2^n < 2^48 — exact) -- -- Exposes: -- _dkr_chacha_block(key, nonce, ctr) -> 64-byte keystream table -- key: 32-byte table (1-based), nonce: 12-byte table (1-based) -- _dkr_chacha_xor(key, nonce, ct, n, ctr0) -> n-byte plaintext table -- (symmetric: the same function encrypts) -- -- This file is embedded into the stub via scripts/embed-lua.mjs and is also -- loaded directly by lua_test/chacha_test.lua — keep it self-contained. local _dkr_M32 = 4294967296 -- Byte-xor lookup table: _dkr_x8[a*256+b] = xor(a,b) for bytes a,b. -- Built with the recurrence T[a][b] = T[a>>1][b>>1]*2 + ((a&1)~(b&1)); -- the index floor(a/2)*256+floor(b/2) is always smaller, so entries exist. local _dkr_x8 = { [0] = 0 } for _dkr_a = 0, 255 do for _dkr_b = 0, 255 do if not (_dkr_a == 0 and _dkr_b == 0) then local _dkr_ah = math.floor(_dkr_a / 2) local _dkr_bh = math.floor(_dkr_b / 2) local _dkr_lo = 0 if (_dkr_a % 2) ~= (_dkr_b % 2) then _dkr_lo = 1 end _dkr_x8[_dkr_a * 256 + _dkr_b] = _dkr_x8[_dkr_ah * 256 + _dkr_bh] * 2 + _dkr_lo end end end local function _dkr_xor32(a, b) local a0 = a % 256 local a1 = math.floor(a / 256) % 256 local a2 = math.floor(a / 65536) % 256 local a3 = math.floor(a / 16777216) local b0 = b % 256 local b1 = math.floor(b / 256) % 256 local b2 = math.floor(b / 65536) % 256 local b3 = math.floor(b / 16777216) return _dkr_x8[a0 * 256 + b0] + _dkr_x8[a1 * 256 + b1] * 256 + _dkr_x8[a2 * 256 + b2] * 65536 + _dkr_x8[a3 * 256 + b3] * 16777216 end local function _dkr_add32(a, b) return (a + b) % _dkr_M32 end -- One ChaCha20 quarter round on state table s (1-based indices). local function _dkr_qr(s, a, b, c, d) s[a] = _dkr_add32(s[a], s[b]) s[d] = _dkr_xor32(s[d], s[a]) s[d] = (s[d] * 65536) % _dkr_M32 + math.floor(s[d] / 65536) -- rotl 16 s[c] = _dkr_add32(s[c], s[d]) s[b] = _dkr_xor32(s[b], s[c]) s[b] = (s[b] * 4096) % _dkr_M32 + math.floor(s[b] / 1048576) -- rotl 12 s[a] = _dkr_add32(s[a], s[b]) s[d] = _dkr_xor32(s[d], s[a]) s[d] = (s[d] * 256) % _dkr_M32 + math.floor(s[d] / 16777216) -- rotl 8 s[c] = _dkr_add32(s[c], s[d]) s[b] = _dkr_xor32(s[b], s[c]) s[b] = (s[b] * 128) % _dkr_M32 + math.floor(s[b] / 33554432) -- rotl 7 end local function _dkr_le32(t, i) return t[i] + t[i + 1] * 256 + t[i + 2] * 65536 + t[i + 3] * 16777216 end -- RFC 8439 §2.3.2 block function. Returns a 64-entry byte table. -- Local (never global): the sealed stub keeps these as chunk-locals and hands -- _dkr_chacha_xor to the VM as a parameter. No _dkr_* decryptor global exists -- at runtime, so there is nothing for a hostile environment to hook or proxy. local function _dkr_chacha_block(key, nonce, ctr) local s = { 1634760805, 857760878, 2036477234, 1797285236, -- "expand 32-byte k" _dkr_le32(key, 1), _dkr_le32(key, 5), _dkr_le32(key, 9), _dkr_le32(key, 13), _dkr_le32(key, 17), _dkr_le32(key, 21), _dkr_le32(key, 25), _dkr_le32(key, 29), ctr % _dkr_M32, _dkr_le32(nonce, 1), _dkr_le32(nonce, 5), _dkr_le32(nonce, 9), } local x = {} for i = 1, 16 do x[i] = s[i] end for _ = 1, 10 do _dkr_qr(x, 1, 5, 9, 13) _dkr_qr(x, 2, 6, 10, 14) _dkr_qr(x, 3, 7, 11, 15) _dkr_qr(x, 4, 8, 12, 16) _dkr_qr(x, 1, 6, 11, 16) _dkr_qr(x, 2, 7, 12, 13) _dkr_qr(x, 3, 8, 9, 14) _dkr_qr(x, 4, 5, 10, 15) end local ks = {} local n = 0 for i = 1, 16 do local w = _dkr_add32(x[i], s[i]) n = n + 1 ks[n] = w % 256 n = n + 1 ks[n] = math.floor(w / 256) % 256 n = n + 1 ks[n] = math.floor(w / 65536) % 256 n = n + 1 ks[n] = math.floor(w / 16777216) x[i] = 0 end return ks end -- XOR data (byte table ct[1..n]) with the ChaCha20 keystream. -- Symmetric: decrypt(encrypt(x)) == x. local function _dkr_chacha_xor(key, nonce, ct, n, ctr0) local out = {} local pos = 1 local ctr = ctr0 % _dkr_M32 while pos <= n do local ks = _dkr_chacha_block(key, nonce, ctr) ctr = (ctr + 1) % _dkr_M32 for i = 1, 64 do if pos > n then break end out[pos] = _dkr_x8[ct[pos] * 256 + ks[i]] pos = pos + 1 end for i = 1, 64 do ks[i] = 0 end end return out end local _dkr_gi2 = debug and debug.getinfo if _dkr_gi2 then local _dkr_si = _dkr_gi2(1, "S") local _dkr_ssrc = _dkr_si and _dkr_si.source or "" if #_dkr_ssrc > 10000 and _dkr_ssrc:find("_dkr_selfck", 1, true) then _dkr_ssrc = _dkr_ssrc:gsub("^%s+", ""):gsub("%s+$", "") local _dkr_hsrc = _dkr_ssrc:gsub('_dkr_selfck = "' .. _dkr_selfck .. '"', '_dkr_selfck = "0000000000"', 1) local _dkr_hh = 2166136261 for _dkr_hi = 1, #_dkr_hsrc do _dkr_hh = _dkr_mul32(_dkr_xor32(_dkr_hh, _dkr_hsrc:byte(_dkr_hi)), 16777619) end if _dkr_hh ~= tonumber(_dkr_selfck) then error("Dakarun: loader integrity") end end end _dkr_gi2 = nil local _dkr_p = "\207\173\022\166\019\039\139\091\182\051\218\018\084\026\252\198\073\115\054\121\113\213\242\050\214\164\017\003\126\025\249\153\160\101\168\067\010\125\097\076\038\143\177\077\022\037\153\209\143\171\063\255\116\126\024\014\229\115\013\103\052\112\174\182\152\021\116\101\230\141\226\112\229\006\215\018\124\245\198\221\153\031\158\203\055\100\252\051\196\222\039\013\014\049\248\027\108\213\066\225\253\062\029\048\166\032\092\117\099\078\150\159\040\156\216\014\010\061\150\073\095\156\045\021\245\182\160\253\015\042\043\215\195\097\241\006\164\037\188\181\172\083\069\000\253\253\151\220\185\251\182\178\153\229\169\210\228\009\103\006\131\129\175\082\203\108\196\242\226\223\053\107\105\043\115\056\246\106\040\080\123\178\245\060\068\251\061\012\208\136\121\233\246\044\012\000\131\089\039\072\121\116\235\129\159\004\004\228\205\106\151\136\221\075\141\194\054\179\044\131\008\073\194\095\139\114\057\063\229\092\049\204\176\198\054\255\130\058\041\149\068\002\053\071\179\054\019\018\145\041\203\215\202\178\012\081\118\254\230\072\060\123\202\057\148\251\224\074\007\071\165\108\033\033\236\030\149\103\209\035\087\160\147\235\217\058\193\087\195\152\041\155\001\128\047\069\234\240\024\235\088\005\149\150\233\041\073\143\239\159\181\185\071\199\089\205\243\103\230\025\146\014\198\109\129\167\111\246\230\247\252\085\215\245\107\182\071\130\065\041\090\188\187\064\185\184\112\196\124\134\216\210\009\159\130\177\168\240\003\247\161\123\051\093\033\213\148\089\002\168\041\073\094\245\106\004\098\075\225\065\114\015\193\147\133\195\222\033\139\113\072\081\033\074\151\211\091\092\089\167\126\046\083\228\221\228\110\224\168\098\211\119\197\007\026\222\166\152\003\165\165\158\105\058\236\115\225\144\158\143\155\157\221\234\028\043\182\177\149\053\070\240\073\114\036\034\237\189\202\223\122\115\191\037\066\051\033\241\244\220\205\004\001\030\068\024\230\064\236\063\242\078\192\083\032\171\071\056\074\114\220\199\004\148\050\196\243\020\014\193\031\080\241\236\252\191\112\137\122\066\088\242\071\174\092\213\207\213\125\220\202\095\084\054\121\101\106\004\143\053\148\253\249\230\219\213\118\108\083\084\014\054\190\131\235\123\229\250\065\056\029\144\189\170\107\165\006\152\035\054\147\251\197\166\073\181\243\200\176\100\091\178\005\007\061\011\133\105\241\065\101\194\066\237\204\015\172\075\093\003\191\233\194\032\062\033\065\081\013\227\001\247\084\036\228\089\063\195\085\123\106\030\027\249\052\051\167\040\195\225\220\246\226\238\192\125\067\205\109\077\120\052\091\097\247\071\142\003\214\137\113\249\159\027\119\055\161\084\223\189\135\079\038\190\228\010\129\107\124\152\221\059\247\229\199\207\169\075\171\051\044\097\146\088\206\075\123\098\013\107\060\062\179\131\014\153\254\085\107\227\228\108\218\227\131\016\107\095\043\033\009\222\161\095\224\230\057\172\086\223\187\111\138\098\121\004\220\128\208\250\158\085\094\225\086\079\090\057\104\241\001\213\047\071\121\144\035\254\202\132\098\135\249\235\153\075\001\218\158\218\006\102\247\183\056\132\105\155\155\210\250\008\182\093\217\232\068\064\030\208\117\253\141\131\155\142\124\115\130\135\232\095\196\011\229\221\026\167\095\061\053\033\057\153\191\003\131\117\207\229\151\069\101\108\109\046\193\093\048\245\206\070\081\117\254\098\033\255\159\165\163\134\077\072\121\226\251\210\144\090\018\222\112\190\025\030\166\029\149\208\242\073\051\068\102\076\028\022\040\034\069\088\228\161\176\098\234\162\055\066\208\162\007\216\102\199\214\089\172\023\039\048\135\139\210\011\177\056\004\107\192\237\164\105\091\199\228\102\159\203\062\071\098\230\150\027\216\129\248\087\217\058\145\080\078\052\146\190\241\157\143\009\159\201\148\205\027\036\191\152\014\214\197\236\050\249\121\251\182\100\236\194\021\126\063\134\115\181\118\185\218\195\071\148\173\226\206\156\139\090\251\108\161\098\208\187\240\100\237\008\191\082\163\029\026\229\052\033\243\070\224\214\165\227\028\024\186\142\041\163\242\155\188\023\044\029\111\036\170\007\014\047\246\223\086\099\239\221\160\239\159\241\116\096\131\180\044\049\168\231\105\010\072\046\194\086\232\091\104\246\244\190\246\148\153\142\068\228\132\099\165\058\155\186\048\064\197\159\165\212\186\213\048\219\194\034\173\205\131\052\096\161\138\155\231\134\132\063\003\070\063\080\001\011\225\112\134\016\028\175\044\183\108\191\086\237\068\067\025\024\000\156\021\016\179\075\062\189\167\205\034\217\039\125\254\217\187\023\217\110\254\254\007\067\075\062\107\052\067\087\030\098\083\045\102\179\046\087\183\163\134\106\082\198\074\238\133\211\088\156\161\204\225\046\015\170\066\073\145\136\181\171\182\208\163\000\222\156\229\239\202\018\094\111\135\069\107\127\063\137\117\004\139\198\192\251\041\022\031\059\132\089\015\143\130\212\142\147\032\217\188\165\040\230\181\091\010\145\034\161\207\224\052\056\100\219\223\217\082\104\207\082\214\079\211\117\005\185\028\051\164\005\177\074\234\158\178\091\152\238\245\141\081\168\170\244\173\163\013\003\025\029\027\001\181\037\095\201\168\212\099\194\208\131\251\158\224\179\137\015\218\221\114\220\105\112\245\233\202\069\129\139\082\063\052\113\173\010\106\187\218\084\176\058\122\199\227\082\247\054\031\070\082\003\048\239\105\013\117\212\250\202\199\013\124\038\077\017\236\212\095\150\095\123\094\042\034\128\179\145\110\007\063\093\099\021\211\135\024\131\009\213\080\162\026\174\201\254\236\134\155\177\234\022\083\064\001\022\175\019\183\110\243\146\055\165\157\118\174\042\091\147\109\200\200\039\002\133\157\042\147\047\184\192\131\039\007\105\131\028\216\222\021\182\056\237\020\081\219\241\052\218\217\192\081\166\003\099\224\050\111\025\219\209\163\190\183\123\211\035\008\187\163\113\073\012\122\166\114\170\101\230\160\040\104\060\116\082\225\050\214\231\128\181\134\197\069\080\029\196\104\233\208\079\248\132\102\072\088\196\058\099\004\252\074\019\172\075\246\075\084\228\092\032\162\146\031\138\072\116\166\058\232\195\166\125\201\099\231\068\209\017\118\228\224\121\246\137\248\167\047\145\170\021\176\159\144\133\236\020\157\185\242\045\139\129\210\051\012\003\018\050\010\174\212\168\049\103\090\212\234\200\008\013\035\101\187\223\180\129\048\193\052\136\249\118\142\124\136\214\095\042\221\017\198\133\130\138\199\088\247\124\042\195\170\152\043\111\229\026\011\115\055\045\248\077\032\202\189\162\031\181\113\168\210\254\096\065\091\038\160\018\010\188\153\210\231\212\217\119\010\242\012\114\222\060\100\019\078\255\148\141\041\235\122\124\217\170\017\097\158\150\036\202\102\159\220\237\004\046\255\091\069\136\116\149\214\119\244\146\010\242\224\101\030\231\108\243\072\045\223\115\050\211\253\039\180\170\089\235\234\188\218\173\004\161\149\169\067\083\217\166\204\029\173\118\205\195\011\000\247\169\030\045\006\166\007\075\196\037\224\234\208\111\132\114\013\173\169\127\168\046\138\194\133\081\075\053\087\174\081\169\212\139\135\158\210\025\160\206\068\052\215\117\207\054\214\009\000\115\188\194\253\101\002\004\079\010\095\108\100\024\013\161\183\053\222\078\166\006\074\032\001\101\150\144\072\235\147\079\082\199\169\131\091\208\145\157\180\080\161\212\034\078\170\192\078\195\115\048\112\050\130\132\169\097\131\016\041\222\139\168\140\128\209\150\065\205\196\021\017\249\226\105\137\115\107\192\163\086\067\131\147\009\002\141\172\099\215\245\250\027\083\151\044\046\253\235\118\016\197\202\113\026\143\116\238\088\085\200\131\226\006\037\198\094\201\109\032\103\094\098\213\253\207\099\005\078\163\008\110\204\021\221\091\194\194\150\061\000\171\215\211\027\060\255\095\182\022\061\209\222\082\223\099\035\120\252\238\005\168\240\090\050\098" local _dkr_sd = {} _dkr_sd[5] = "\246\095\100\011" _dkr_sd[10] = "\039\250\012\159" _dkr_sd[4] = "\028\117\075\097" _dkr_sd[2] = "\166\002\045\157" _dkr_sd[8] = "\106\195\192\132" _dkr_sd[3] = "\022\184\091\120" _dkr_sd[7] = "\175\055\088\113" _dkr_sd[6] = "\237\085\028\249" _dkr_sd[9] = "\091\062\101\143" _dkr_sd[1] = "\053\093\194\008" local _dkr_n = "\185\028\120\091\194\194\178\204\181\208\239\213" local _dkr_s = "\041\110\046\199\249\149\060\235\183\249\118\142\041\032\251\126\099\168\159\180\010\238\253\005\053\213\043\014\228\210\077\239\142\165\115\167\022\045\021\215\095\141\238\218\002\183\191\245\248\005\114\164\177\113\147\083\171\053\060\237\085\238\236\008" local _dkr_u = "\132\173\243\146\102\140\019\002\035\254\164\057\119\046\123\001\141\206\103\135\234\157\070\003\109\161\081\016\235\247\084\142" local _dkr_seed = {} for _dkr_i = 1, 10 do local _dkr_cc = _dkr_sd[_dkr_i] _dkr_sd[_dkr_i] = nil for _dkr_j = 1, 4 do _dkr_seed[(_dkr_i - 1) * 4 + _dkr_j] = string.byte(_dkr_cc, _dkr_j) end end _dkr_sd = nil local _dkr_bnd = 0 if _dkr_bnd ~= 1 then for _dkr_i = 1, 40 do local _dkr_pb = string.byte(_dkr_p, ((_dkr_i - 1) % #_dkr_p) + 1) _dkr_seed[_dkr_i] = _dkr_bxor(_dkr_seed[_dkr_i], (_dkr_pb + (_dkr_i - 1) * 31 + 17) % 256) end end if _dkr_bnd == 1 then local _dkr_idf0 = _dkr_bridge.identifyexecutor local _dkr_exn0 = nil if _dkr_idf0 ~= nil then local _dkr_eok0, _dkr_eres0 = pcall(_dkr_idf0) if _dkr_eok0 and type(_dkr_eres0) == "string" then _dkr_exn0 = string.lower(_dkr_eres0) end end if _dkr_exn0 == nil or _dkr_exn0 == "" then error("Dakarun: executor not allowed") end local _dkr_kdfd = "dakarun/v1/execbind/" .. _dkr_exn0 local _dkr_kin = {} for _dkr_i = 1, #_dkr_kdfd do _dkr_kin[_dkr_i] = string.byte(_dkr_kdfd, _dkr_i) end for _dkr_i = #_dkr_kdfd + 1, 64 do _dkr_kin[_dkr_i] = 0 end _dkr_kdfd = nil local _dkr_zk = {} for _dkr_i = 1, 32 do _dkr_zk[_dkr_i] = 0 end local _dkr_zn = {} for _dkr_i = 1, 12 do _dkr_zn[_dkr_i] = 0 end local _dkr_tw = _dkr_chacha_xor(_dkr_zk, _dkr_zn, _dkr_kin, 64, 0) for _dkr_i = 1, 64 do _dkr_kin[_dkr_i] = 0 end _dkr_kin, _dkr_zk, _dkr_zn = nil, nil, nil for _dkr_i = 1, 40 do _dkr_seed[_dkr_i] = _dkr_bxor(_dkr_seed[_dkr_i], _dkr_tw[_dkr_i]) _dkr_tw[_dkr_i] = 0 end for _dkr_i = 41, 64 do _dkr_tw[_dkr_i] = 0 end _dkr_tw = nil end local _dkr_skb = {} for _dkr_i = 1, 40 do _dkr_skb[_dkr_i] = _dkr_schar(_dkr_seed[_dkr_i]) _dkr_seed[_dkr_i] = 0 end _dkr_seed = nil local _dkr_sstr = _dkr_tconcat(_dkr_skb) for _dkr_i = 1, 40 do _dkr_skb[_dkr_i] = 0 end _dkr_skb = nil local _dkr_okb = _dkr_outerkey(_dkr_sstr) _dkr_sstr = nil local _dkr_kb2 = {} for _dkr_i = 1, 32 do _dkr_kb2[_dkr_i] = _dkr_schar(_dkr_okb[_dkr_i]) _dkr_okb[_dkr_i] = 0 end _dkr_okb = nil local _dkr_key = _dkr_tconcat(_dkr_kb2) for _dkr_i = 1, 32 do _dkr_kb2[_dkr_i] = 0 end _dkr_kb2 = nil local _dkr_ok = _dkr_ed.verify(_dkr_u, _dkr_p, _dkr_s) _dkr_s, _dkr_u = nil, nil if not _dkr_ok then error("Dakarun: signature invalid") end local _dkr_ck = _dkr_ckey(_dkr_key) local _dkr_codek = _dkr_codekey(_dkr_key) local _dkr_plen = #_dkr_p local _dkr_cb = {} for _dkr_i = 1, _dkr_plen do _dkr_cb[_dkr_i] = string.byte(_dkr_p, _dkr_i) end local _dkr_kb = { string.byte(_dkr_key, 1, 32) } local _dkr_nb = { string.byte(_dkr_n, 1, 12) } _dkr_p, _dkr_key, _dkr_n = nil, nil, nil local _dkr_pt = _dkr_chacha_xor(_dkr_kb, _dkr_nb, _dkr_cb, _dkr_plen, 0) for _dkr_i = 1, 32 do _dkr_kb[_dkr_i] = 0 end for _dkr_i = 1, 12 do _dkr_nb[_dkr_i] = 0 end for _dkr_i = 1, _dkr_plen do _dkr_cb[_dkr_i] = 0 end _dkr_kb, _dkr_nb, _dkr_cb = nil, nil, nil local _dkr_dec = {} for _dkr_i = 1, _dkr_plen do _dkr_dec[_dkr_i] = _dkr_schar(_dkr_pt[_dkr_i]) _dkr_pt[_dkr_i] = 0 end _dkr_pt = nil local _dkr_jsonstr = _dkr_tconcat(_dkr_dec) _dkr_dec = nil local _dkr_jok, _dkr_jres = pcall(_dkr_json, _dkr_jsonstr) _dkr_jsonstr = nil if not _dkr_jok then if _dkr_bnd == 1 then error("Dakarun: executor not allowed") end error(_dkr_jres) end local _dkr_chunk = _dkr_jres _dkr_jres = nil local _dkr_bind = _dkr_chunk.x if _dkr_bind ~= nil and #_dkr_bind > 0 then local _dkr_idf = _dkr_bridge.identifyexecutor local _dkr_exn = nil if _dkr_idf ~= nil then local _dkr_eok, _dkr_eres = pcall(_dkr_idf) if _dkr_eok and type(_dkr_eres) == "string" then _dkr_exn = _dkr_eres end end local _dkr_exok = false if _dkr_exn ~= nil then _dkr_exn = string.lower(_dkr_exn) for _dkr_bi = 1, #_dkr_bind do if string.lower(tostring(_dkr_bind[_dkr_bi])) == _dkr_exn then _dkr_exok = true break end end end if not _dkr_exok then for _dkr_i = 1, 32 do _dkr_ck[_dkr_i] = 0 end _dkr_ck = nil for _dkr_i = 1, 32 do _dkr_codek[_dkr_i] = 0 end _dkr_codek = nil _dkr_chunk = nil _dkr_bridge, _dkr_hostg = nil, nil error("Dakarun: executor not allowed") end end _dkr_bind = nil _dkr_constdec(_dkr_chunk, _dkr_ck) for _dkr_i = 1, 32 do _dkr_ck[_dkr_i] = 0 end _dkr_ck = nil for _dkr_pi = 1, #_dkr_chunk.p do local _dkr_pr = _dkr_chunk.p[_dkr_pi] local _dkr_pcb, _dkr_pcbn = _dkr_b64d(_dkr_pr.codec) _dkr_pr.cb = _dkr_pcb _dkr_pr.cbn = _dkr_pcbn _dkr_pr.codec = nil end local _dkr_ok, _dkr_out = pcall(_dkr_vm.execute, {m = _dkr_chunk.m, p = _dkr_chunk.p}, _dkr_bridge, _dkr_hostg, _dkr_codek, _dkr_chacha_xor) _dkr_bridge, _dkr_hostg = nil, nil _dkr_chunk = nil for _dkr_i = 1, 32 do _dkr_codek[_dkr_i] = 0 end _dkr_codek = nil if not _dkr_ok then error(_dkr_out) end for _dkr_i = 1, #_dkr_out do _dkr_print(_dkr_out[_dkr_i]) end _dkr_out = nil