Merge remote-tracking branch 'origin/next' into philip/aquarium

This commit is contained in:
Philip Monk 2019-03-20 17:46:30 -07:00
commit b5414a49af
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC
10 changed files with 493 additions and 83130 deletions

View File

@ -15,7 +15,7 @@
;div#root
;+ inner
==
;script@"/~~/landscape/js/index.js";
;script@"/~~/landscape/js/index-min.js";
==
::
==

View File

@ -3750,65 +3750,185 @@
::
++ ob
|%
++ feen :: conceal structure v2
:: +fein: conceal structure, v3.
::
:: +fein conceals planet-sized atoms. The idea is that it should not be
:: trivial to tell which planet a star has spawned under.
::
++ fein
|= pyn/@ ^- @
?: &((gte pyn 0x1.0000) (lte pyn 0xffff.ffff))
(add 0x1.0000 (fice (sub pyn 0x1.0000)))
(add 0x1.0000 (feis (sub pyn 0x1.0000)))
?: &((gte pyn 0x1.0000.0000) (lte pyn 0xffff.ffff.ffff.ffff))
=+ lo=(dis pyn 0xffff.ffff)
=+ hi=(dis pyn 0xffff.ffff.0000.0000)
=/ lo (dis pyn 0xffff.ffff)
=/ hi (dis pyn 0xffff.ffff.0000.0000)
%+ con hi
$(pyn lo)
pyn
::
++ fend :: restore structure v2
:: +fynd: restore structure, v3.
::
:: Restores obfuscated values that have been enciphered with +fein.
::
++ fynd
|= cry/@ ^- @
?: &((gte cry 0x1.0000) (lte cry 0xffff.ffff))
(add 0x1.0000 (teil (sub cry 0x1.0000)))
(add 0x1.0000 (tail (sub cry 0x1.0000)))
?: &((gte cry 0x1.0000.0000) (lte cry 0xffff.ffff.ffff.ffff))
=+ lo=(dis cry 0xffff.ffff)
=+ hi=(dis cry 0xffff.ffff.0000.0000)
=/ lo (dis cry 0xffff.ffff)
=/ hi (dis cry 0xffff.ffff.0000.0000)
%+ con hi
$(cry lo)
cry
::
++ fice :: adapted from
|= nor/@ :: black and rogaway
^- @ :: "ciphers with
=+ ^= sel :: arbitrary finite
%+ rynd 3 :: domains", 2002
%+ rynd 2
%+ rynd 1
%+ rynd 0
[(mod nor 65.535) (div nor 65.535)]
(add (mul 65.535 -.sel) +.sel)
:: +feis: a four-round generalised Feistel cipher over the domain
:: [0, 2^32 - 2^16 - 1].
::
++ teil :: reverse ++fice
|= vip/@
:: See: Black & Rogaway (2002), Ciphers for arbitrary finite domains.
::
++ feis
|= m=@
^- @
=+ ^= sel
%+ rund 0
%+ rund 1
%+ rund 2
%+ rund 3
[(mod vip 65.535) (div vip 65.535)]
(add (mul 65.535 -.sel) +.sel)
(fee 4 0xffff 0x1.0000 (mul 0xffff 0x1.0000) eff m)
::
++ rynd :: feistel round
|= {n/@ l/@ r/@}
^- {@ @}
:- r
?~ (mod n 2)
(~(sum fo 65.535) l (muk (snag n raku) 2 r))
(~(sum fo 65.536) l (muk (snag n raku) 2 r))
:: +tail: reverse +feis.
::
++ rund :: reverse round
|= {n/@ l/@ r/@}
^- {@ @}
:- r
?~ (mod n 2)
(~(dif fo 65.535) l (muk (snag n raku) 2 r))
(~(dif fo 65.536) l (muk (snag n raku) 2 r))
++ tail
|= m=@
^- @
(feen 4 0xffff 0x1.0000 (mul 0xffff 0x1.0000) eff m)
::
:: +fee: "Fe" in B&R (2002).
::
:: A Feistel cipher given the following parameters:
::
:: r: number of Feistel rounds
:: a, b: parameters such that ab >= k
:: k: value such that the domain of the cipher is [0, k - 1]
:: prf: a gate denoting a family of pseudorandom functions indexed by
:: its first argument and taking its second argument as input
:: m: an input value in the domain [0, k - 1]
::
++ fee
|= [r=@ a=@ b=@ k=@ prf=$-([j=@ r=@] @) m=@]
^- @
=/ c (fe r a b prf m)
?: (lth c k)
c
(fe r a b prf c)
::
:: +feen: "Fe^-1" in B&R (2002).
::
:: Reverses a Feistel cipher constructed with parameters as described in
:: +fee.
::
++ feen
|= [r=@ a=@ b=@ k=@ prf=$-([j=@ r=@] @) m=@]
^- @
=/ c (fen r a b prf m)
?: (lth c k)
c
(fen r a b prf c)
::
:: +fe: "fe" in B&R (2002).
::
:: An internal function to +fee.
::
:: Note that this implementation differs slightly from the reference paper
:: to support some legacy behaviour. See urbit/arvo#1105.
::
++ fe
|= [r=@ a=@ b=@ prf=$-([j=@ r=@] @) m=@]
=/ j 1
=/ ell (mod m a)
=/ arr (div m a)
|- ^- @
::
?: (gth j r)
?. =((mod r 2) 0)
(add (mul arr a) ell)
::
:: Note that +fe differs from B&R (2002)'s "fe" below, as a previous
:: implementation of this cipher contained a bug such that certain inputs
:: could encipher to the same output.
::
:: To correct these problem cases while also preserving the cipher's
:: legacy behaviour on most inputs, we check for a problem case (which
:: occurs when 'arr' is equal to 'a') and, if detected, use an alternate
:: permutation instead.
::
?: =(arr a)
(add (mul arr a) ell)
(add (mul ell a) arr)
::
=/ f (prf (sub j 1) arr)
::
=/ tmp
?. =((mod j 2) 0)
(mod (add f ell) a)
(mod (add f ell) b)
::
$(j +(j), ell arr, arr tmp)
::
:: +fen: "fe^-1" in B&R (2002).
::
:: Note that this implementation differs slightly from the reference paper
:: to support some legacy behaviour. See urbit/arvo#1105.
::
++ fen
|= [r=@ a=@ b=@ prf=$-([j=@ r=@] @) m=@]
=/ j r
::
=/ ahh
?. =((mod r 2) 0)
(div m a)
(mod m a)
::
=/ ale
?. =((mod r 2) 0)
(mod m a)
(div m a)
::
:: Similar to the comment in +fe, +fen differs from B&R (2002)'s "fe^-1"
:: here in order to preserve the legacy cipher's behaviour on most inputs.
::
:: Here problem cases can be identified by 'ahh' equating with 'a'; we
:: correct those cases by swapping the values of 'ahh' and 'ale'.
::
=/ ell
?: =(ale a)
ahh
ale
::
=/ arr
?: =(ale a)
ale
ahh
::
|- ^- @
?: (lth j 1)
(add (mul arr a) ell)
=/ f (prf (sub j 1) ell)
::
:: Note that there is a slight deviation here to avoid dealing with
:: negative values. We add 'a' or 'b' to arr as appropriate and reduce
:: 'f' modulo the same number before performing subtraction.
::
=/ tmp
?. =((mod j 2) 0)
(mod (sub (add arr a) (mod f a)) a)
(mod (sub (add arr b) (mod f b)) b)
::
$(j (sub j 1), ell tmp, arr ell)
::
:: +eff: a murmur3-based pseudorandom function. 'F' in B&R (2002).
::
++ eff
|= [j=@ r=@]
^- @
(muk (snag j raku) 2 r)
::
:: +raku: seeds for eff.
::
++ raku
^- (list @ux)
@ -3817,6 +3937,7 @@
0x85bc.ae01
0x4b38.7af7
==
::
--
::
:::: 3g: molds and mold builders
@ -5617,7 +5738,7 @@
++ dim (ape dip)
++ dip (bass 10 ;~(plug sed:ab (star sid:ab)))
++ dum (bass 10 (plus sid:ab))
++ fed %+ cook fend:ob
++ fed %+ cook fynd:ob
;~ pose
%+ bass 0x1.0000.0000.0000.0000 :: oversized
;~ plug
@ -5729,7 +5850,7 @@
==
::
$p
=+ sxz=(feen:ob q.p.lot)
=+ sxz=(fein:ob q.p.lot)
=+ dyx=(met 3 sxz)
:- '~'
?: (lte dyx 1)

View File

@ -518,28 +518,52 @@
==
::
++ login-page
%+ titl 'Sign in - Urbit'
;= ;div.container.top
%+ titl 'Login - Landscape'
;=
;div.header-container.container
;div.row
;div.flex-col-x.header-breadcrumbs;
==
;div.row.align-center.header-mainrow
;div.flex-col-2.justify-end;
;h1.flex-col-x.header-title: Login
==
==
;div.container
;div.row
;div.flex-col-2;
;div.flex-col-x
;div.row.mt-10
;h3.col-md-12: Ship
==
;div.row
;div.col-md-4
;h1.sign: Sign in
==
;div.col-md-8
;p.ship
;label.sig: ~
;input#ship.mono(contenteditable "", placeholder "your-urbit");
==
;input#pass.mono(type "password", placeholder "passcode");
;h2.advice: Type +{;code:("+code")} in your dojo for your passcode.
;pre:code#err;
;input#ship.col-md-10.h3.text-500.collection-title(placeholder "your-ship", contenteditable "");
==
;div.row.mt-5
;h3.col-md-12
; Type
;span.text-mono.mr-1: +code
; in your terminal and press enter
==
==
;div.row
;input#pass.col-md-10.h3.mono.text-500.collection-title(type "password", placeholder "passcode");
==
;div.row.mt-5
;button#login.btn-primary.btn(disabled "true"): Login
==
;div.row.mt-5
;pre#err;
==
==
==
==
;script@"/~/at/~/auth.js";
;script:'''
$(function() {
$ship = $('#ship')
$pass = $('#pass')
$login = $('#login')
$ship.on('keydown', function(e) {
if(e.keyCode === 13 || e.keyCode === 9) {
if(!urb.is_me($ship.val().toLowerCase()))
@ -549,14 +573,23 @@
e.preventDefault()
}
})
$ship.on('focus', function(e) {
$pass.hide()
})
$pass.on('keydown', function(e) {
if(e.keyCode === 13) {
urb.submit($ship.val().toLowerCase(),$pass.val())
$pass.on('keypress', function(e) {
if($pass.val().length > -1) {
$login.prop('disabled', false)
} else {
$login.prop('disabled', true)
}
})
$pass.on('paste', function(e) {
if($pass.val().length > -1) {
$login.prop('disabled', false)
} else {
$login.prop('disabled', true)
}
})
$login.on('click', function(e) {
urb.submit($ship.val().toLowerCase(),$pass.val())
})
if(window.ship) {
$ship.val(urb.ship)
$pass.focus()
@ -605,8 +638,7 @@
;title:"{(trip a)}"
;script(type "text/javascript", src "//cdnjs.cloudflare.com/ajax/".
"libs/jquery/2.1.1/jquery.min.js");
;link(rel "stylesheet", href "/===/web/lib/css/fonts.css");
;link(rel "stylesheet", href "/===/web/lib/css/bootstrap.css");
;link(rel "stylesheet", href "/===/web/landscape/css/index.css");
==
;body:"*{b}"
==

View File

@ -7716,6 +7716,7 @@
:: enc(X) is the sequence of bytes in X padded with zero-bytes to a
:: length of 32.
:: Note that for any X, len(enc(X)) is a multiple of 32.
~| [%bytes-n-too-long max=32 actual=p.p.dat]
?> (lte p.p.dat 32)
(pad-to-multiple (render-hex-bytes p.dat) 64 %right)
::
@ -7725,7 +7726,7 @@
:: by the minimum number of zero-bytes such that len(enc(X)) is a
:: multiple of 32.
%+ weld $(dat [%uint p.p.dat])
$(dat [%bytes-n p.dat])
(pad-to-multiple (render-hex-bytes p.dat) 64 %right)
::
%string
:: enc(X) = enc(enc_utf8(X)), i.e. X is utf-8 encoded and this value is
@ -7757,24 +7758,19 @@
::
:: decoding
::
++ decode-topics
:: tox: list of hex words
|* [tox=(lest @ux) tys=(list etyp)]
=- (decode-arguments (crip -) tys)
%+ render-hex-bytes (mul 32 (lent tox))
%+ roll `(list @ux)`tox
|= [top=@ux tos=@]
(cat 8 top tos)
++ decode-topics decode-arguments
::
++ decode-results
:: rex: string of hex bytes with leading 0x.
|* [rex=@t tys=(list etyp)]
(decode-arguments (rsh 3 2 rex) tys)
=- (decode-arguments - tys)
%+ turn (rip 9 (rsh 3 2 rex))
(curr rash hex)
::
++ decode-arguments
|* [res=@t tys=(list etyp)]
|* [wos=(list @) tys=(list etyp)]
=/ wos=(list @) wos :: get rid of tmi
=| win=@ud
=/ wos=(list @t) (rip 9 res)
=< (decode-from 0 tys)
|%
++ decode-from
@ -7799,22 +7795,21 @@
?(%address %bool %uint) :: %int %real %ureal
:- +(win)
?- typ
%address `@ux`(rash wor hex)
%uint `@ud`(rash wor hex)
%bool =(1 (rash wor hex))
%address `@ux`wor
%uint `@ud`wor
%bool =(1 wor)
==
::
%string
=+ $(tys ~[%bytes])
~! -
[nin (trip (swp 3 q.dat))]
::
%bytes
:- +(win)
:: find the word index of the actual data.
=/ lic=@ud (div (rash wor hex) 32)
=/ lic=@ud (div wor 32)
:: learn the bytelength of the data.
=/ len=@ud (rash (snag lic wos) hex)
=/ len=@ud (snag lic wos)
(decode-bytes-n +(lic) len)
::
[%bytes-n *]
@ -7824,11 +7819,11 @@
[%array *]
:- +(win)
:: find the word index of the actual data.
=. win (div (rash wor hex) 32)
=. win (div wor 32)
:: read the elements from their location.
%- tail
%^ decode-array-n ~[t.typ] +(win)
(rash (snag win wos) hex)
(snag win wos)
::
[%array-n *]
(decode-array-n ~[t.typ] win n.typ)
@ -7838,18 +7833,20 @@
|= [fro=@ud bys=@ud]
^- octs
:: parse {bys} bytes from {fro}.
=- [bys (rash - hex)]
%^ end 3 (mul 2 bys)
%+ can 9
%+ turn
(swag [fro +((div (dec bys) 32))] wos)
|=(a=@t [1 a])
:- bys
%^ rsh 3
=+ (mod bys 32)
?:(=(0 -) - (sub 32 -))
%+ rep 8
%- flop
=- (swag [fro -] wos)
+((div (dec bys) 32))
::
++ decode-array-n
::NOTE we take (list etyp) even though we only operate on
:: a single etyp as a workaround for urbit/arvo#673
::NOTE careful! produces lists without type info
=| res=(list)
~& %watch-out--arrays-without-typeinfo
|* [tys=(list etyp) fro=@ud len=@ud]
^- [@ud (list)]
?~ tys !!
@ -8224,8 +8221,10 @@
|= [wat=tape mof=@ud wer=?(%left %right)]
^- tape
=+ len=(lent wat)
?: =(len mof) wat
=+ tad=(reap (sub mof (mod len mof)) '0')
?: =(0 len) (reap mof '0')
=+ mad=(mod len mof)
?: =(0 mad) wat
=+ tad=(reap (sub mof mad) '0')
%- weld
?:(?=(%left wer) [tad wat] [wat tad])
::

View File

@ -1,5 +1,109 @@
/+ *test
|%
++ test-parse-p
;: weld
%+ expect-eq
!> ~zod
!> `@p`0
::
%+ expect-eq
!> ~lex
!> `@p`200
::
%+ expect-eq
!> ~binzod
!> `@p`512
::
%+ expect-eq
!> ~samzod
!> `@p`1.024
::
%+ expect-eq
!> ~poldec-tonteg
!> `@p`9.896.704
::
%+ expect-eq
!> ~nidsut-tomdun
!> `@p`15.663.360
::
%+ expect-eq
!> ~morlyd-mogmev
!> `@p`3.108.299.008
::
%+ expect-eq
!> ~fipfes-morlyd
!> `@p`479.733.505
::
%+ expect-eq
!> ~dilwes-fadnel
!> `@p`23.554.048
::
%+ expect-eq
!> ~fipfes-dilwes
!> `@p`529.511.092
::
%+ expect-eq
!> ~hossev-roppec
!> `@p`1.859.915.444
::
%+ expect-eq
!> ~fipfes-hossev
!> `@p`145.391.618
::
==
::
++ test-render-p
;: weld
%+ expect-eq
!> '~zod'
!> (scot %p 0)
::
%+ expect-eq
!> '~lex'
!> (scot %p 200)
::
%+ expect-eq
!> '~binzod'
!> (scot %p 512)
::
%+ expect-eq
!> '~samzod'
!> (scot %p 1.024)
::
%+ expect-eq
!> '~poldec-tonteg'
!> (scot %p 9.896.704)
::
%+ expect-eq
!> '~nidsut-tomdun'
!> (scot %p 15.663.360)
::
%+ expect-eq
!> '~morlyd-mogmev'
!> (scot %p 3.108.299.008)
::
%+ expect-eq
!> '~fipfes-morlyd'
!> (scot %p 479.733.505)
::
%+ expect-eq
!> '~dilwes-fadnel'
!> (scot %p 23.554.048)
::
%+ expect-eq
!> '~fipfes-dilwes'
!> (scot %p 529.511.092)
::
%+ expect-eq
!> '~hossev-roppec'
!> (scot %p 1.859.915.444)
::
%+ expect-eq
!> '~fipfes-hossev'
!> (scot %p 145.391.618)
::
==
::
++ test-parse-q
;: weld
%+ expect-eq

140
tests/sys/hoon/ob.hoon Normal file
View File

@ -0,0 +1,140 @@
/+ *test
|%
++ test-fein-fynd-inverses
;: weld
%+ expect-eq
!> 0
!> (fynd:ob (fein:ob 0))
::
%+ expect-eq
!> 15.663.360
!> (fynd:ob (fein:ob 15.663.360))
::
%+ expect-eq
!> 1.208.402.137
!> (fynd:ob (fein:ob 1.208.402.137))
::
%+ expect-eq
!> 123.456.789.012.345
!> (fynd:ob (fein:ob 123.456.789.012.345))
::
%+ expect-eq
!> 4.267.685.634
!> (fynd:ob (fein:ob 4.267.685.634))
::
%+ expect-eq
!> 1.625.882.369
!> (fynd:ob (fein:ob 1.625.882.369))
::
==
::
++ test-fein-fynd-match-reference-vals
;: weld
%+ expect-eq
!> 1.897.766.331
!> (fein:ob 123.456.789)
::
%+ expect-eq
!> 1.208.402.137
!> (fein:ob 15.663.360)
::
%+ expect-eq
!> 15.663.360
!> (fynd:ob 1.208.402.137)
::
%+ expect-eq
!> 123.456.789
!> (fynd:ob 1.897.766.331)
::
==
::
++ test-feis-tail-inverses
;: weld
%+ expect-eq
!> 15.663.360
!> (tail:ob (feis:ob 15.663.360))
::
%+ expect-eq
!> 1.208.402.137
!> (tail:ob (feis:ob 1.208.402.137))
::
%+ expect-eq
!> 4.267.685.634
!> (tail:ob (feis:ob 4.267.685.634))
::
%+ expect-eq
!> 1.625.882.369
!> (tail:ob (feis:ob 1.625.882.369))
::
==
::
++ test-feis-tail-match-reference-vals
;: weld
%+ expect-eq
!> 2.060.458.291
!> (feis:ob 123.456.789)
::
%+ expect-eq
!> 1.195.593.620
!> (feis:ob 15.663.360)
::
%+ expect-eq
!> 1.107.963.580
!> (tail:ob 123.456.789)
::
%+ expect-eq
!> 15.663.360
!> (tail:ob 1.195.593.620)
::
==
::
++ test-exhaustive-small
=/ a=(list @) ~[5 9 2 6 4 0 8 7 1 10 3 11]
=/ b=(list @) ~[2 1 0 3 10 4 9 5 7 11 6 8]
=/ c=(list @) ~[10 6 7 1 0 11 3 9 5 2 8 4]
=/ d=(list @) ~[11 0 3 5 9 8 6 10 4 1 2 7]
::
=/ prf
|= [j=@ r=@]
^- @
?: =(j 0)
(snag r a)
?: =(j 1)
(snag r b)
?: =(j 2)
(snag r c)
(snag r d)
::
::
=/ feis
|= arg=@
^- @
(fee:ob 4 3 4 12 prf arg)
::
=/ tail
|= arg=@
^- @
(feen:ob 4 3 4 12 prf arg)
::
=/ emm=(list @) ~[0 1 2 3 4 5 6 7 8 9 10 11]
=/ semm=(set @) (sy emm)
::
=/ perm=(list @) (turn emm feis)
=/ inv=(list @) (turn perm tail)
=/ distincts=(set @) (sy perm)
::
;: weld
%+ expect-eq
!> (lent perm)
!> (lent ~(tap in distincts))
::
%+ expect-eq
!> &
!> (roll perm |=([x=@ acc=?] &((~(has in semm) x) acc)))
::
%+ expect-eq
!> emm
!> inv
::
==
--

View File

@ -11,7 +11,7 @@
^- manx
;div
;div
=urb-component "TopicCreatePage"
=urb-component "TopicCreatePage"
=urb-ship "{(scow %p p.bem.gas)}"
=urb-claypath "{<pax>}"
=urb-content "{(trip body)}"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -14,7 +14,7 @@
;div.flex-col-2;
;div.flex-col-x
;div.profile-avatar
;div(urb-component "Sigil", urb-size "310", urb-ship "{(scow %p p.bem.gas)}", urb-suffix "false");
;div(urb-component "Sigil", urb-size "320", urb-ship "{(scow %p p.bem.gas)}", urb-suffix "false");
;div(urb-component "ProfileMsgBtn", urb-ship "{(scow %p p.bem.gas)}");
==
==