mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-17 20:01:32 +03:00
commit
e166d7dcba
@ -4984,7 +4984,8 @@
|
||||
++ scr :: scrypt
|
||||
~% %scr + ~
|
||||
|%
|
||||
++ sal |= [x=@ r=@] :: salsa20 hash
|
||||
++ sal
|
||||
|= [x=@ r=@] :: salsa20 hash
|
||||
?> =((mod r 2) 0) :: with r rounds
|
||||
=+ few==>(fe .(a 5))
|
||||
=+ ^= rot
|
||||
@ -4993,7 +4994,8 @@
|
||||
=+ ^= lea
|
||||
|= [a=@ b=@]
|
||||
(net:few (sum:few (net:few a) (net:few b)))
|
||||
=> |% ++ qr :: quarterround
|
||||
=> |%
|
||||
++ qr :: quarterround
|
||||
|= y=[@ @ @ @ ~]
|
||||
=+ zb=(mix &2.y (rot 7 (sum:few &1.y &4.y)))
|
||||
=+ zc=(mix &3.y (rot 9 (sum:few zb &1.y)))
|
||||
@ -5010,22 +5012,18 @@
|
||||
&1.za &2.za &3.za &4.za
|
||||
&4.zb &1.zb &2.zb &3.zb
|
||||
&3.zc &4.zc &1.zc &2.zc
|
||||
&2.zd &3.zd &4.zd &1.zd
|
||||
==
|
||||
&2.zd &3.zd &4.zd &1.zd ==
|
||||
++ cr :: columnround
|
||||
|= [x=(list ,@)]
|
||||
=+ ^= y %- rr ^- (list ,@) :~
|
||||
&1.x &5.x &9.x &13.x
|
||||
&2.x &6.x &10.x &14.x
|
||||
&3.x &7.x &11.x &15.x
|
||||
&4.x &8.x &12.x &16.x
|
||||
==
|
||||
=+ ya=(qr ~[&1.x &5.x &9.x &13.x])
|
||||
=+ yb=(qr ~[&6.x &10.x &14.x &2.x])
|
||||
=+ yc=(qr ~[&11.x &15.x &3.x &7.x])
|
||||
=+ yd=(qr ~[&16.x &4.x &8.x &12.x])
|
||||
^- (list ,@) :~
|
||||
&1.y &5.y &9.y &13.y
|
||||
&2.y &6.y &10.y &14.y
|
||||
&3.y &7.y &11.y &15.y
|
||||
&4.y &8.y &12.y &16.y
|
||||
==
|
||||
&1.ya &4.yb &3.yc &2.yd
|
||||
&2.ya &1.yb &4.yc &3.yd
|
||||
&3.ya &2.yb &1.yc &4.yd
|
||||
&4.ya &3.yb &2.yc &1.yd ==
|
||||
++ dr :: doubleround
|
||||
|= [x=(list ,@)]
|
||||
(rr (cr x))
|
||||
@ -5041,7 +5039,8 @@
|
||||
$(xw (dr xw), r (sub r 2))
|
||||
(rep 5 (al xw ow))
|
||||
::
|
||||
++ rpp |= [a=bloq b=@ c=@] :: rip w/filler blocks
|
||||
++ rpp
|
||||
|= [a=bloq b=@ c=@] :: rip w/filler blocks
|
||||
=+ q=(rip a c)
|
||||
=+ w=(lent q)
|
||||
?. =(w b)
|
||||
@ -5049,28 +5048,21 @@
|
||||
^+ q (weld q (reap (sub b (lent q)) 0))
|
||||
q
|
||||
::
|
||||
++ xrl |= [a=(list ,@) b=(list ,@)] :: xor lists
|
||||
|- ^- (list ,@)
|
||||
?~ a b ?~ b a
|
||||
[i=(mix -.a -.b) t=$(a +.a, b +.b)]
|
||||
::
|
||||
++ xrm |= [a=(list (list ,@)) b=(list (list ,@))]
|
||||
|- ^- (list (list ,@))
|
||||
?~ a b ?~ b a
|
||||
[i=(xrl -.a -.b) t=$(a +.a, b +.b)]
|
||||
::
|
||||
++ bls |= [a=@ b=(list ,@)] :: split to sublists
|
||||
++ bls
|
||||
|= [a=@ b=(list ,@)] :: split to sublists
|
||||
?> =((mod (lent b) a) 0)
|
||||
|- ^- (list (list ,@))
|
||||
?~ b ~
|
||||
[i=(scag a `(list ,@)`b) t=$(b (slag a `(list ,@)`b))]
|
||||
::
|
||||
++ slb |= [a=(list (list ,@))]
|
||||
++ slb
|
||||
|= [a=(list (list ,@))]
|
||||
|- ^- (list ,@)
|
||||
?~ a ~
|
||||
(weld `(list ,@)`-.a $(a +.a))
|
||||
::
|
||||
++ sbm |= [r=@ b=(list ,@)] :: scryptBlockMix
|
||||
++ sbm
|
||||
|= [r=@ b=(list ,@)] :: scryptBlockMix
|
||||
?> =((lent b) (mul 2 r))
|
||||
=+ [x=(snag (dec (mul 2 r)) b) c=0]
|
||||
=| [ya=(list ,@) yb=(list ,@)]
|
||||
@ -5081,14 +5073,13 @@
|
||||
$(c +(c), b +.b, ya [i=x t=ya])
|
||||
$(c +(c), b +.b, yb [i=x t=yb])
|
||||
::
|
||||
++ srm |= [r=@ b=(list ,@) n=@] :: scryptROMix
|
||||
?> ?&
|
||||
=((lent b) (mul 2 r))
|
||||
++ srm
|
||||
|= [r=@ b=(list ,@) n=@] :: scryptROMix
|
||||
?> ?& =((lent b) (mul 2 r))
|
||||
=(n (bex (dec (xeb n))))
|
||||
(lth n (bex (mul r 16)))
|
||||
==
|
||||
=| v=(list (list ,@))
|
||||
=+ c=0
|
||||
=+ [v=*(list (list ,@)) c=0]
|
||||
=. v
|
||||
|- ^- (list (list ,@))
|
||||
=+ w=(sbm r b)
|
||||
@ -5098,13 +5089,19 @@
|
||||
|- ^- (list ,@)
|
||||
?: =(c n) x
|
||||
=+ q=(snag (dec (mul r 2)) x)
|
||||
$(x (sbm r (xrl x (snag (mod q n) v))), c +(c))
|
||||
=+ z=`(list ,@)`(snag (mod q n) v)
|
||||
=+ ^= w |- ^- (list ,@)
|
||||
?~ x ~ ?~ z ~
|
||||
[i=(mix -.x -.z) t=$(x +.x, z +.z)]
|
||||
$(x (sbm r w), c +(c))
|
||||
::
|
||||
++ hmc |= [k=@ t=@] :: HMAC-SHA-256
|
||||
++ hmc
|
||||
|= [k=@ t=@] :: HMAC-SHA-256
|
||||
(hml k (met 3 k) t (met 3 t))
|
||||
::
|
||||
++ hml |= [k=@ kl=@ t=@ tl=@] :: w/length
|
||||
=. k (end 3 kl k) =. t (end 3 tl t)
|
||||
++ hml
|
||||
|= [k=@ kl=@ t=@ tl=@] :: w/length
|
||||
=> .(k (end 3 kl k), t (end 3 tl t))
|
||||
=+ b=64
|
||||
=. k ?. (gth kl b) k (shay kl k)
|
||||
=+ ^= q %+ shay (add b tl)
|
||||
@ -5118,7 +5115,7 @@
|
||||
::
|
||||
++ pbl ~/ %pbl :: w/length
|
||||
|= [p=@ pl=@ s=@ sl=@ c=@ d=@]
|
||||
=. p (end 3 pl p) =. s (end 3 sl s)
|
||||
=> .(p (end 3 pl p), s (end 3 sl s))
|
||||
=+ h=32
|
||||
?> ?& (lte d (bex 30)) :: max key length 1GB
|
||||
(lte c (bex 28)) :: max iterations 2^28
|
||||
@ -5146,7 +5143,7 @@
|
||||
++ hsl ~/ %hsl :: w/length
|
||||
|= [p=@ pl=@ s=@ sl=@ n=@ r=@ z=@ d=@]
|
||||
=| v=(list (list ,@))
|
||||
=. p (end 3 pl p) =. s (end 3 sl s)
|
||||
=> .(p (end 3 pl p), s (end 3 sl s))
|
||||
=+ u=(mul (mul 128 r) z)
|
||||
?> ?& =(n (bex (dec (xeb n)))) :: n is power of 2
|
||||
!=(r 0) !=(z 0)
|
||||
@ -5156,8 +5153,7 @@
|
||||
(lth pl (bex 31))
|
||||
(lth sl (bex 31))
|
||||
==
|
||||
=+ ^= b =+ %^ rpp 3 u
|
||||
(pbl p pl s sl 1 u)
|
||||
=+ ^= b =+ (rpp 3 u (pbl p pl s sl 1 u))
|
||||
%+ turn (bls (mul 128 r) -)
|
||||
|=(a=(list ,@) (rpp 9 (mul 2 r) (rep 3 a)))
|
||||
?> =((lent b) z)
|
||||
|
Loading…
Reference in New Issue
Block a user