Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 52 additions & 53 deletions desk/app/vitriol.hoon
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,35 @@
?: &((gte c 'A') (lte c 'F')) (add 10 (sub c 'A'))
!!
$(chars t.chars, i +(i), val (add val (lsh [2 i] nib)))
::
++ deed-safe
|= [=bowl:gall who=@p]
^- (unit [life=@ud pass=@])
=/ result=(each (unit point:jael) tang)
%- mule |.
.^ (unit point:jael)
%j
/(scot %p our.bowl)/pynt/(scot %da now.bowl)/(scot %p who)
==
?. ?=(%& -.result) ~
?~ p.result ~
=/ pnt u.p.result
?: =(0 life.pnt) ~
=/ ky (~(get by keys.pnt) life.pnt)
?~ ky ~
`[life.pnt pass.u.ky]
::
++ ring-safe
|= [=bowl:gall lyf=@ud]
^- (unit @)
=/ result=(each * tang)
%- mule |.
.^ *
%j
/(scot %p our.bowl)/vein/(scot %da now.bowl)/(scot %ud lyf)
==
?. ?=(%& -.result) ~
`;;(@ p.result)
--
^- agent:gall
=| state-1
Expand Down Expand Up @@ -97,19 +126,14 @@
:: GET /vitriol/pubkey — return this ship's on-chain networking key
::
[%vitriol %pubkey ~]
=/ deed-result
%- mule |.
.^ [life=@ud pass=@ sec=(unit @)]
%j
/(scot %p our.bowl)/deed/(scot %da now.bowl)/(scot %p our.bowl)/1
==
=/ deed (deed-safe bowl our.bowl)
=/ result=json
?: ?=(%| -.deed-result)
?~ deed
(pairs:enjs:format ~[['configured' b+%.n] ['error' s+'no keys in Jael']])
%- pairs:enjs:format
:~ ['configured' b+%.y]
['pass' s+(to-hex 130 pass.p.deed-result)]
['life' (numb:enjs:format life.p.deed-result)]
['pass' s+(to-hex 130 pass.u.deed)]
['life' (numb:enjs:format life.u.deed)]
['ship' s+(scot %p our.bowl)]
==
:_ this
Expand All @@ -123,29 +147,19 @@
:_ this
(give-simple-payload:app:server eyre-id (json-response:gen:server err))
:: get our deed and ring from Jael
=/ deed-result
%- mule |.
.^ [life=@ud pass=@ sec=(unit @)]
%j
/(scot %p our.bowl)/deed/(scot %da now.bowl)/(scot %p our.bowl)/1
==
?: ?=(%| -.deed-result)
=/ deed (deed-safe bowl our.bowl)
?~ deed
=/ err=json (pairs:enjs:format ['error' s+'no keys in Jael']~)
:_ this
(give-simple-payload:app:server eyre-id (json-response:gen:server err))
=/ ring-result
%- mule |.
.^ @
%j
/(scot %p our.bowl)/vein/(scot %da now.bowl)/(scot %ud life.p.deed-result)
==
?: ?=(%| -.ring-result)
=/ ring (ring-safe bowl life.u.deed)
?~ ring
=/ err=json (pairs:enjs:format ['error' s+'cannot read private key from Jael']~)
:_ this
(give-simple-payload:app:server eyre-id (json-response:gen:server err))
:: extract Ed25519 signing seed from ring
:: ring format (suite B): 1 byte 'B' + 32 bytes sgn-seed + 32 bytes cry-seed
=/ sgn-seed (end 8 (rsh 3 p.ring-result))
=/ sgn-seed (end 8 (rsh 3 u.ring))
=/ jon (need (de:json:html q:(need body.request.req)))
=/ content (so:dejs:format (~(got by ((om:dejs:format same) jon)) 'content'))
=/ msg=octs [(met 3 content) content]
Expand All @@ -154,7 +168,7 @@
%- pairs:enjs:format
:~ ['signature' s+(to-hex 128 sig)]
['signer_id' s+(scot %p our.bowl)]
['pass' s+(to-hex 130 pass.p.deed-result)]
['pass' s+(to-hex 130 pass.u.deed)]
==
:_ this
(give-simple-payload:app:server eyre-id (json-response:gen:server result))
Expand All @@ -175,13 +189,8 @@
:: resolve signer
=/ who (slav %p signer-cord)
:: scry Jael for signer's on-chain deed
=/ deed-result
%- mule |.
.^ [life=@ud pass=@ sec=(unit @)]
%j
/(scot %p our.bowl)/deed/(scot %da now.bowl)/(scot %p who)/1
==
?: ?=(%| -.deed-result)
=/ deed (deed-safe bowl who)
?~ deed
=/ result=json
%- pairs:enjs:format
:~ ['verified' b+%.n]
Expand All @@ -190,7 +199,7 @@
==
:_ this
(give-simple-payload:app:server eyre-id (json-response:gen:server result))
?: =(0 life.p.deed-result)
?: =(0 life.u.deed)
=/ result=json
%- pairs:enjs:format
:~ ['verified' b+%.n]
Expand All @@ -201,7 +210,7 @@
(give-simple-payload:app:server eyre-id (json-response:gen:server result))
:: extract Ed25519 signing pubkey from on-chain pass
:: pass format (suite b): 1 byte 'b' + 32 bytes sgn-pub + 32 bytes cry-pub
=/ sgn-pub (end 8 (rsh 3 pass.p.deed-result))
=/ sgn-pub (end 8 (rsh 3 pass.u.deed))
=/ sig=@ (from-hex sig-hex)
=/ msg=octs [(met 3 payload) payload]
=/ valid=? (veri-octs:ed:crypto sig msg sgn-pub)
Expand All @@ -210,7 +219,7 @@
%- pairs:enjs:format
:~ ['verified' b+%.y]
['signer' s+signer-cord]
['life' (numb:enjs:format life.p.deed-result)]
['life' (numb:enjs:format life.u.deed)]
==
%- pairs:enjs:format
:~ ['verified' b+%.n]
Expand All @@ -228,20 +237,15 @@
(give-simple-payload:app:server eyre-id not-found:gen:server)
=/ who-knot=@t i.t.t.site.rl
=/ who (slav %p who-knot)
=/ deed
%- mule |.
.^ [life=@ud pass=@ sec=(unit @)]
%j
/(scot %p our.bowl)/deed/(scot %da now.bowl)/(scot %p who)/1
==
=/ deed (deed-safe bowl who)
=/ result=json
?: ?=(%| -.deed)
?~ deed
%- pairs:enjs:format
:~ ['attested' b+%.n]
['ship' s+who-knot]
['error' s+'ship not found in Jael']
==
?: =(0 life.p.deed)
?: =(0 life.u.deed)
%- pairs:enjs:format
:~ ['attested' b+%.n]
['ship' s+who-knot]
Expand All @@ -250,7 +254,7 @@
%- pairs:enjs:format
:~ ['attested' b+%.y]
['ship' s+who-knot]
['life' (numb:enjs:format life.p.deed)]
['life' (numb:enjs:format life.u.deed)]
==
:_ this
(give-simple-payload:app:server eyre-id (json-response:gen:server result))
Expand All @@ -269,20 +273,15 @@
^- (unit (unit cage))
?+ pole ~
[%x %pubkey %json ~]
=/ deed-result
%- mule |.
.^ [life=@ud pass=@ sec=(unit @)]
%j
/(scot %p our.bowl)/deed/(scot %da now.bowl)/(scot %p our.bowl)/1
==
=/ deed (deed-safe bowl our.bowl)
:- ~ :- ~ :- %json
!> ^- json
?: ?=(%| -.deed-result)
?~ deed
(pairs:enjs:format ['configured' b+%.n]~)
%- pairs:enjs:format
:~ ['configured' b+%.y]
['pass' s+(to-hex 130 pass.p.deed-result)]
['life' (numb:enjs:format life.p.deed-result)]
['pass' s+(to-hex 130 pass.u.deed)]
['life' (numb:enjs:format life.u.deed)]
==
==
::
Expand Down
2 changes: 1 addition & 1 deletion desk/sys.kelvin
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[%zuse 409]
[%zuse 408]
Loading