urbit/pkg/arvo/sys/vane/kale.hoon

1017 lines
30 KiB
Plaintext
Raw Normal View History

2019-06-25 21:54:42 +03:00
!: :: /vane/kale
:: :: %reference/0
!? 150
::
::
:: %kale: secrets and promises.
::
:: todo:
::
:: - communication with other vanes:
:: - actually use %behn for expiring secrets
:: - report %ames propagation errors to user
::
:: - nice features:
:: - scry namespace
:: - task for converting invites to tickets
::
|= pit/vase
=, pki:kale
=, able:kale
=, crypto
=, kale
=, ethereum
=, rpc
=, azimuth
2019-06-26 21:31:37 +03:00
=, point=point:able:kale
2019-06-25 21:54:42 +03:00
:: ::::
:::: # models :: data structures
:: ::::
:: the %kale state comes in two parts: absolute
:: and relative.
::
:: ++state-relative is subjective, denormalized and
:: derived. it consists of all the state we need to
:: manage subscriptions efficiently.
::
=> |%
2019-06-26 21:31:37 +03:00
+$ state :: all vane state
2019-06-25 21:54:42 +03:00
$: ver=$0 :: vane version
2019-06-26 21:31:37 +03:00
pki=state-pki ::
2019-06-25 21:54:42 +03:00
etn=state-eth-node :: eth connection state
sap=state-snapshots :: state snapshots
== ::
2019-06-26 21:31:37 +03:00
+$ state-pki :: urbit metadata
2019-06-25 21:54:42 +03:00
$: $= own :: vault (vein)
$: yen=(set duct) :: trackers
sig=(unit oath) :: for a moon
tuf=(list turf) :: domains
boq=@ud :: boot block
nod=(unit purl:eyre) :: eth gateway
fak=_| :: fake keys
lyf=life :: version
jaw=(map life ring) :: private keys
== ::
2019-07-19 01:26:15 +03:00
$= zim :: public
2019-06-26 21:31:37 +03:00
$: yen=(jug duct ship) :: trackers
ney=(jug ship duct) :: reverse trackers
2019-06-25 21:54:42 +03:00
dns=dnses :: on-chain dns state
pos=(map ship point) :: on-chain ship state
== ::
== ::
2019-06-26 21:31:37 +03:00
+$ state-snapshots :: rewind points
2019-06-25 21:54:42 +03:00
$: interval=_100 :: block interval
max-count=_10 :: max snaps
count=@ud :: length of snaps
last-block=@ud :: number of last snap
snaps=(qeu [block-number=@ud snap=snapshot]) :: old states
== ::
2019-06-26 21:31:37 +03:00
+$ message :: message to her kale
2019-06-26 23:14:45 +03:00
$% [%nuke whos=(set ship)] :: cancel trackers
[%public-keys whos=(set ship)] :: view ethereum events
2019-07-19 01:26:15 +03:00
[%public-keys-result =public-keys-result] :: tmp workaround
2019-06-25 21:54:42 +03:00
== ::
2019-06-26 21:31:37 +03:00
+$ card :: i/o action
2019-06-25 21:54:42 +03:00
(wind note gift) ::
:: ::
+$ move :: output
[p=duct q=card] ::
:: ::
+$ note :: out request $->
2019-06-26 22:53:41 +03:00
$~ [%a %want *ship *path **] ::
2019-06-26 21:31:37 +03:00
$% $: %a :: to %ames
2019-06-25 21:54:42 +03:00
$>(%want task:able:ames) :: send message
== ::
2019-06-26 21:31:37 +03:00
$: %k :: to self
2019-06-25 21:54:42 +03:00
$>(%look task) :: set ethereum source
== ::
$: @tas ::
$% $>(%init vane-task) :: report install
== == == ::
:: ::
+$ sign :: in result $<-
2019-06-26 21:31:37 +03:00
$~ [%a %woot *ship ~] ::
2019-06-26 22:53:41 +03:00
$% [%a $>(%woot gift:able:ames)] :: message result
2019-06-25 21:54:42 +03:00
== ::
-- ::
:: ::::
:::: # light :: light cores
:: ::::
=> |%
:: :: ++ez
:::: ## ethereum^light :: wallet algebra
:: ::::
++ ez
:: simple ethereum-related utility arms.
::
|%
::
:: +order-events: sort changes by block and log numbers
::
++ order-events
|= loz=(list (pair event-id diff-azimuth))
^+ loz
%+ sort loz
:: sort by block number, then by event log number,
::TODO then by diff priority.
|= [[[b1=@ud l1=@ud] *] [[b2=@ud l2=@ud] *]]
?. =(b1 b2) (lth b1 b2)
?. =(l1 l2) (lth l1 l2)
&
--
--
:: ::::
:::: # heavy :: heavy engines
:: ::::
=> |%
:: :: ++of
:::: ## main^heavy :: main engine
:: ::::
++ of
:: this core handles all top-level %kale semantics,
:: changing state and recording moves.
::
:: logically we could nest the ++su core within it, but
:: we keep them separated for clarity. the ++curd and
:: ++cure arms complete relative and absolute effects,
:: respectively, at the top level.
::
:: XX doc
::
:: a general pattern here is that we use the ++et core
:: to generate absolute effects (++change), then invoke
:: ++su to calculate the derived effect of these changes.
::
:: for ethereum-related events, this is preceded by
:: invocation of ++et, which produces ethereum-level
:: changes (++chain). these get turned into absolute
:: effects by ++cute.
::
:: arvo issues: should be merged with the top-level
:: vane interface when that gets cleaned up a bit.
::
=| moz/(list move)
=| $: $: :: our: identity
:: now: current time
:: eny: unique entropy
::
our=ship
now=@da
eny=@uvJ
==
:: all vane state
::
state
==
:: lex: all durable state
:: moz: pending actions
::
=* lex ->
|%
:: :: ++abet:of
++ abet :: resolve
[(flop moz) lex]
:: :: ++sein:of
++ sein :: sponsor
|= who=ship
^- ship
:: XX save %dawn sponsor in .own.sub, check there
::
2019-06-26 21:31:37 +03:00
=/ pot (~(get by pos.zim.pki) who)
2019-06-25 21:54:42 +03:00
?: ?& ?=(^ pot)
2019-06-26 21:31:37 +03:00
?=(^ sponsor.u.pot)
2019-06-25 21:54:42 +03:00
==
2019-06-26 21:31:37 +03:00
u.sponsor.u.pot
2019-06-25 21:54:42 +03:00
(^sein:title who)
:: :: ++saxo:of
++ saxo :: sponsorship chain
|= who/ship
^- (list ship)
=/ dad (sein who)
[who ?:(=(who dad) ~ $(who dad))]
:: :: ++call:of
++ call :: invoke
|= $: :: hen: event cause
:: tac: event data
::
hen/duct
tac/task
==
^+ +>
?- -.tac
::
:: boot from keys
:: $: $dawn
:: =seed
:: spon=ship
:: czar=(map ship [=life =pass])
:: turf=(list turf)}
:: bloq=@ud
:: node=purl
:: ==
::
%dawn
:: single-homed
::
?> =(our who.seed.tac)
:: save our boot block
::
2019-06-26 21:31:37 +03:00
=. boq.own.pki bloq.tac
2019-06-25 21:54:42 +03:00
:: save our ethereum gateway (required for galaxies)
::
2019-06-26 21:31:37 +03:00
=. nod.own.pki node.tac
2019-06-25 21:54:42 +03:00
:: save our parent signature (only for moons)
::
2019-06-26 21:31:37 +03:00
=. sig.own.pki sig.seed.tac
2019-06-25 21:54:42 +03:00
:: if we're given a snapshot, restore it
::
=. +>.$
?~ snap.tac +>.$
(restore-snap hen u.snap.tac |)
:: load our initial public key, overriding snapshot
::
2019-06-26 21:31:37 +03:00
=. pos.zim.pki
2019-06-25 21:54:42 +03:00
=/ cub (nol:nu:crub:crypto key.seed.tac)
2019-06-26 21:31:37 +03:00
%+ ~(put by pos.zim.pki)
2019-06-25 21:54:42 +03:00
our
2019-06-26 21:31:37 +03:00
[1 lyf.seed.tac (my [lyf.seed.tac [1 pub:ex:cub]] ~) `spon.tac]
2019-06-25 21:54:42 +03:00
:: our initial private key
::
2019-06-26 21:31:37 +03:00
=. lyf.own.pki lyf.seed.tac
=. jaw.own.pki (my [lyf.seed.tac key.seed.tac] ~)
:: XX save sponsor in .own.pki
2019-06-25 21:54:42 +03:00
:: XX reconcile with .dns.eth
:: set initial domains
::
2019-06-26 21:31:37 +03:00
=. tuf.own.pki turf.tac
2019-06-26 22:53:41 +03:00
:: our initial galaxy table as a +map from +life to +public
::
2019-07-19 01:26:15 +03:00
=/ diffs=(list [=ship =diff:point])
2019-06-26 22:53:41 +03:00
%~ tap by
%- ~(run by czar.tac)
2019-07-19 01:26:15 +03:00
|= [=a=life =a=pass]
^- diff:point
[%keys [*life 0 *pass] [a-life 1 a-pass]]
2019-06-26 22:53:41 +03:00
=. +>.$
|- ^+ +>.^$
2019-07-19 01:26:15 +03:00
?~ diffs
2019-06-26 22:53:41 +03:00
+>.^$
=. +>.^$
%- curd =< abet
%- public-keys:~(feel su hen our pki etn sap)
2019-07-19 01:26:15 +03:00
[%diff ship diff]:i.diffs
$(diffs t.diffs)
2019-06-25 21:54:42 +03:00
::
=. moz
%+ weld moz
:: order is crucial!
::
:: %dill must init after %gall
:: the %give init (for unix) must be after %dill init
:: %kale init must be deferred (makes http requests)
::
^- (list move)
2019-06-26 21:31:37 +03:00
:~ [hen %give %init our]
2019-07-04 02:01:45 +03:00
[hen %slip %e %init our]
2019-06-25 21:54:42 +03:00
[hen %slip %d %init our]
[hen %slip %g %init our]
[hen %slip %c %init our]
[hen %slip %a %init our]
==
+>.$
::
:: boot fake
:: [%fake =ship]
::
%fake
:: single-homed
::
?> =(our ship.tac)
:: fake keys are deterministically derived from the ship
::
=/ cub (pit:nu:crub:crypto 512 our)
:: save our parent signature (only for moons)
::
:: XX move logic to zuse
::
2019-06-26 21:31:37 +03:00
=. sig.own.pki
2019-06-25 21:54:42 +03:00
?. ?=(%earl (clan:title our))
~
=/ yig (pit:nu:crub:crypto 512 (^sein:title our))
[~ (sign:as:yig (shaf %earl (sham our 1 pub:ex:cub)))]
:: our initial public key
::
2019-06-26 21:31:37 +03:00
=. pos.zim.pki
%+ ~(put by pos.zim.pki)
our
[rift=1 life=1 (my [`@ud`1 [`life`1 pub:ex:cub]] ~) `(^sein:title our)]
2019-06-25 21:54:42 +03:00
:: our private key
::
:: Private key updates are disallowed for fake ships,
:: so we do this first.
::
2019-06-26 21:31:37 +03:00
=. lyf.own.pki 1
=. jaw.own.pki (my [1 sec:ex:cub] ~)
2019-06-25 21:54:42 +03:00
:: set the fake bit
::
2019-06-26 21:31:37 +03:00
=. fak.own.pki &
2019-06-25 21:54:42 +03:00
:: initialize other vanes per the usual procedure
::
:: Except for ourselves!
::
=. moz
%+ weld moz
^- (list move)
:~ [hen %give %init our]
2019-07-04 02:01:45 +03:00
[hen %slip %e %init our]
2019-06-25 21:54:42 +03:00
[hen %slip %d %init our]
[hen %slip %g %init our]
[hen %slip %c %init our]
[hen %slip %a %init our]
==
+>.$
::
:: set ethereum source
:: [%look p=(each ship purl)]
::
%look
2019-06-26 21:31:37 +03:00
%- curd =< abet
(sources:~(feel su hen our pki etn sap) [whos source]:tac)
2019-06-25 21:54:42 +03:00
::
:: cancel all trackers from duct
2019-06-26 23:14:45 +03:00
:: {$nuke whos=(set ship)}
2019-06-25 21:54:42 +03:00
::
$nuke
2019-06-26 23:14:45 +03:00
=/ ships=(list ship)
%~ tap in
%- ~(int in whos.tac)
(~(get ju yen.zim.pki) hen)
2019-06-26 21:31:37 +03:00
=. ney.zim.pki
|- ^- (jug ship duct)
?~ ships
ney.zim.pki
(~(del ju $(ships t.ships)) i.ships hen)
2019-06-26 23:14:45 +03:00
=. yen.zim.pki
|- ^- (jug duct ship)
?~ ships
yen.zim.pki
(~(del ju $(ships t.ships)) hen i.ships)
?^ whos.tac
+>.$
%_ +>.$
2019-06-26 21:31:37 +03:00
yen.own.pki (~(del in yen.own.pki) hen)
yen.etn (~(del in yen.etn) hen)
2019-06-25 21:54:42 +03:00
==
::
:: watch public keys
2019-06-26 21:31:37 +03:00
:: [%public-keys ships=(set ship)]
2019-06-25 21:54:42 +03:00
::
2019-06-26 21:31:37 +03:00
%public-keys
2019-06-25 21:54:42 +03:00
%- curd =< abet
2019-06-26 21:31:37 +03:00
(~(public-keys ~(feed su hen our pki etn sap) hen) ships.tac)
2019-06-25 21:54:42 +03:00
::
:: seen after breach
:: [%meet our=ship who=ship]
::
%meet
2019-06-26 21:31:37 +03:00
:: XX what do
~& %meet-kale
+>.$
2019-06-25 21:54:42 +03:00
::
:: restore snapshot
:: [%snap snap=snapshot kick=?]
%snap
(restore-snap hen snap.tac kick.tac)
::
2019-06-26 21:31:37 +03:00
:: sources subscription
:: [%sources ~]
::
%sources
(curd abet:~(sources ~(feed su hen our pki etn sap) hen))
::
2019-06-25 21:54:42 +03:00
:: XX should be a subscription
:: XX reconcile with .dns.eth
:: request domains
:: [%turf ~]
::
%turf
:: ships with real keys must have domains,
:: those with fake keys must not
::
2019-06-26 21:31:37 +03:00
?< =(fak.own.pki ?=(^ tuf.own.pki))
+>.$(moz [[hen %give %turf tuf.own.pki] moz])
::
:: Update from app
2019-07-19 01:26:15 +03:00
:: [%new-event =ship =udiff:point]
2019-06-26 21:31:37 +03:00
::
2019-07-19 01:26:15 +03:00
%new-event
2019-06-26 21:31:37 +03:00
%- curd =< abet
2019-07-19 01:26:15 +03:00
(~(new-event su hen our pki etn sap) ship.tac udiff.tac)
2019-06-25 21:54:42 +03:00
::
:: learn of kernel upgrade
:: [%vega ~]
::
%vega
+>.$
::
:: watch private keys
2019-06-26 21:31:37 +03:00
:: {$private-keys $~}
2019-06-25 21:54:42 +03:00
::
2019-06-26 21:31:37 +03:00
%private-keys
(curd abet:~(private-keys ~(feed su hen our pki etn sap) hen))
2019-06-25 21:54:42 +03:00
::
%wegh
%_ +>
moz
:_ moz
^- move
:^ hen %give %mass
^- mass
:+ %kale %|
2019-06-26 21:31:37 +03:00
:~ pki+&+pki
2019-06-25 21:54:42 +03:00
etn+&+etn
sap+&+sap
dot+&+lex
==
==
::
:: authenticated remote request
:: {$west p/ship q/path r/*}
::
$west
=* her p.tac
=/ mes (message r.tac)
?- -.mes
::
:: cancel trackers
2019-06-26 23:14:45 +03:00
:: [%nuke whos=(set ship)]
2019-06-25 21:54:42 +03:00
::
%nuke
2019-06-26 22:53:41 +03:00
=. moz [[hen %give %mack ~] moz]
2019-06-25 21:54:42 +03:00
$(tac mes)
::
:: view ethereum events
2019-06-26 22:53:41 +03:00
:: [%public-keys whos=(set ship)]
2019-06-25 21:54:42 +03:00
::
2019-06-26 21:31:37 +03:00
%public-keys
=. moz [[hen %give %mack ~] moz]
2019-06-26 23:14:45 +03:00
$(tac mes)
2019-06-25 21:54:42 +03:00
::
2019-06-26 21:31:37 +03:00
:: receive keys result
2019-07-19 01:26:15 +03:00
:: [%public-keys-result =public-keys-result]
2019-06-25 21:54:42 +03:00
::
2019-06-26 21:31:37 +03:00
%public-keys-result
2019-06-26 22:53:41 +03:00
=. moz [[hen %give %mack ~] moz]
2019-07-19 01:26:15 +03:00
%- curd =< abet
(public-keys:~(feel su hen our pki etn sap) public-keys-result.mes)
2019-06-25 21:54:42 +03:00
==
::
:: rewind to snapshot
:: {$wind p/@ud}
::
%wind
(wind hen p.tac)
==
::
++ take
|= [tea=wire hen=duct hin=sign]
^+ +>
?> ?=([@ *] tea)
=* wir t.tea
?- hin
[%a %woot *]
?~ q.hin +>.$
?~ u.q.hin ~&(%ares-fine +>.$)
~& [%woot-bad p.u.u.q.hin]
~_ q.u.u.q.hin
::TODO fail:et
+>.$
==
:: :: ++curd:of
++ curd :: relative moves
|= $: moz/(list move)
2019-06-26 21:31:37 +03:00
pki/state-pki
2019-06-25 21:54:42 +03:00
etn/state-eth-node
sap/state-snapshots
==
2019-06-26 21:31:37 +03:00
+>(pki pki, etn etn, sap sap, moz (weld (flop moz) ^moz))
2019-06-25 21:54:42 +03:00
:: :: ++wind:of
++ wind :: rewind to snap
|= [hen=duct block=@ud]
^+ +>
2019-06-26 21:31:37 +03:00
:: XX what do
!!
2019-06-25 21:54:42 +03:00
:: :: ++restore-block:of
++ restore-block :: rewind before block
|= [hen=duct block=@ud]
!!
:: %+ cute hen =< abet
:: XX
:: (~(restore-block et hen our now sub.lex etn.lex sap.lex) block)
:: :: ++restore-snap:of
++ restore-snap :: restore snapshot
|= [hen=duct snap=snapshot look=?]
!!
:: %+ cute hen =< abet
:: XX
:: %- ~(restore-snap et hen our now sub.lex etn.lex sap.lex)
:: [snap look]
--
:: :: ++su
:::: ## relative^heavy :: subjective engine
:: ::::
++ su
:: the ++su core handles all derived state,
:: subscriptions, and actions.
::
:: ++feed:su registers subscriptions.
::
:: ++feel:su checks if a ++change should notify
:: any subscribers.
::
=| moz=(list move)
2019-07-19 01:26:15 +03:00
=| $: hen=duct
our=ship
2019-06-26 21:31:37 +03:00
state-pki
2019-06-25 21:54:42 +03:00
state-eth-node
state-snapshots
==
:: moz: moves in reverse order
2019-06-26 21:31:37 +03:00
:: pki: relative urbit state
2019-06-25 21:54:42 +03:00
::
2019-06-26 21:31:37 +03:00
=* pki ->+<
2019-06-25 21:54:42 +03:00
=* etn ->+>-
=* sap ->+>+
|%
2019-06-26 21:31:37 +03:00
++ this-su .
2019-06-25 21:54:42 +03:00
:: :: ++abet:su
++ abet :: resolve
2019-06-26 21:31:37 +03:00
[(flop moz) pki etn sap]
2019-06-25 21:54:42 +03:00
:: :: ++exec:su
2019-06-26 22:53:41 +03:00
++ emit
|= =move
+>.$(moz [move moz])
::
2019-06-25 21:54:42 +03:00
++ exec :: mass gift
|= {yen/(set duct) cad/card}
=/ noy ~(tap in yen)
2019-06-26 22:53:41 +03:00
|- ^+ this-su
?~ noy this-su
2019-06-25 21:54:42 +03:00
$(noy t.noy, moz [[i.noy cad] moz])
::
2019-07-19 01:26:15 +03:00
++ public-keys-give
|= [yen=(set duct) =public-keys-result]
2019-06-25 21:54:42 +03:00
=+ yez=~(tap in yen)
2019-06-26 22:53:41 +03:00
|- ^+ this-su
?~ yez this-su
2019-06-25 21:54:42 +03:00
=* d i.yez
2019-06-26 22:53:41 +03:00
=. this-su
2019-07-12 00:45:40 +03:00
?. ?=([[%a @ @ *] *] d)
%- emit
2019-07-19 01:26:15 +03:00
[d %give %public-keys public-keys-result]
2019-07-12 00:45:40 +03:00
=/ our (slav %p i.t.i.d)
=/ who (slav %p i.t.t.i.d)
2019-07-19 01:26:15 +03:00
=/ =message [%public-keys-result public-keys-result]
2019-06-26 22:53:41 +03:00
%- emit
:^ d
%pass
/public-keys-result
^- note
[%a %want who /k/public-keys-result message]
$(yez t.yez)
2019-06-25 21:54:42 +03:00
::
2019-06-26 21:31:37 +03:00
++ get-source
|= who=@p
^- source
=/ ship-source (~(get by ship-sources.etn) who)
?^ ship-source
(~(got by sources) u.ship-source)
?: =((clan:title who) %earl)
[%& (^sein:title who)]
(~(got by sources) default-source.etn)
::
++ get-source-id
|= =source
^- [source-id _this-su]
=/ source-reverse (~(get by sources-reverse) source)
?^ source-reverse
[u.source-reverse this-su]
:- top-source-id.etn
%_ this-su
top-source-id.etn +(top-source-id.etn)
sources.etn (~(put by sources) top-source-id.etn source)
sources-reverse.etn (~(put by sources-reverse) source top-source-id.etn)
==
::
2019-07-19 01:26:15 +03:00
++ new-event
|= [=a=ship =a=udiff:point]
^+ this-su
=/ a-point=point (~(gut by pos.zim.pki) a-ship *point)
=/ a-diff=diff:point (udiff-to-diff:point a-udiff a-point)
(public-keys:feel %diff a-ship a-diff)
::
++ extract-snap :: extract rewind point
2019-06-25 21:54:42 +03:00
^- snapshot
2019-06-26 21:31:37 +03:00
~
2019-06-25 21:54:42 +03:00
:: :: ++feed:su
++ feed :: subscribe to view
|_ :: hen: subscription source
::
hen/duct
::
2019-06-26 21:31:37 +03:00
++ public-keys
|= whos=(set ship)
?: fak.own.pki
(public-keys:fake whos)
=. ney.zim
=/ whol=(list ship) ~(tap in whos)
|- ^- (jug ship duct)
?~ whol
ney.zim
(~(put ju $(whol t.whol)) i.whol hen)
2019-07-19 01:26:15 +03:00
=/ =public-keys-result
2019-06-26 21:31:37 +03:00
:- %full
?: =(~ whos)
pos.zim
%- my ^- (list (pair ship point))
%+ murn
~(tap in whos)
|= who=ship
^- (unit (pair ship point))
=/ pub (~(get by pos.zim) who)
?~ pub ~
?: =(0 life.u.pub) ~
`[who u.pub]
2019-06-26 22:53:41 +03:00
=. yen.zim
%- ~(gas ju yen.zim)
%+ turn ~(tap in whos)
|= who=ship
[hen who]
2019-07-19 01:26:15 +03:00
=. ..feed (public-keys-give (sy hen ~) public-keys-result)
2019-06-26 22:53:41 +03:00
..feed
2019-06-26 21:31:37 +03:00
::
++ private-keys :: private keys
2019-06-25 21:54:42 +03:00
%_ ..feed
2019-06-26 21:31:37 +03:00
moz [[hen %give %private-keys [lyf jaw]:own] moz]
2019-06-25 21:54:42 +03:00
yen.own (~(put in yen.own) hen)
==
::
2019-06-26 21:31:37 +03:00
++ sources
%_ ..feed
yen.etn (~(put in yen.etn) hen)
moz
%- welp :_ moz
%+ turn
~(tap by ship-sources-reverse.etn)
|= [=source-id whos=(set ship)]
[hen %give %source whos (~(got by sources.etn) source-id)]
2019-06-25 21:54:42 +03:00
==
:: :: ++fake:feed:su
++ fake :: fake subs and state
2019-06-26 21:31:37 +03:00
?> fak.own.pki
2019-06-25 21:54:42 +03:00
|%
2019-06-26 21:31:37 +03:00
++ public-keys
|= whos=(set ship)
=/ whol=(list ship) ~(tap in whos)
=/ passes
|- ^- (list [who=ship =pass])
?~ whol
~
=/ cub (pit:nu:crub:crypto 512 i.whol)
:- [i.whol pub:ex:cub]
$(whol t.whol)
=/ points=(list (pair ship point))
%+ turn passes
|= [who=ship =pass]
^- [who=ship =point]
[who [rift=1 life=1 (my [1 1 pass] ~) `(^sein:title who)]]
=. moz [[hen %give %public-keys %full (my points)] moz]
2019-07-19 01:26:15 +03:00
..feel
2019-06-25 21:54:42 +03:00
--
--
:: :: ++feel:su
++ feel :: update tracker
|%
:: :: ++pubs:feel:su
2019-06-26 21:31:37 +03:00
++ public-keys
2019-07-19 01:26:15 +03:00
|= =public-keys-result
2019-06-26 21:31:37 +03:00
^+ ..feel
2019-07-19 01:26:15 +03:00
?: ?=(%full -.public-keys-result)
=. pos.zim (~(uni by pos.zim) points.public-keys-result)
2019-06-26 22:53:41 +03:00
=/ pointl=(list [who=ship =point])
2019-07-19 01:26:15 +03:00
~(tap by points.public-keys-result)
2019-06-26 22:53:41 +03:00
|- ^+ ..feel
?~ pointl
..feel
2019-07-19 01:26:15 +03:00
%+ public-keys-give
2019-06-26 22:53:41 +03:00
(~(get ju ney.zim) who.i.pointl)
[%full (my i.pointl ~)]
2019-07-19 01:26:15 +03:00
=* who who.public-keys-result
=/ a-diff=diff:point diff.public-keys-result
2019-06-26 21:31:37 +03:00
=/ maybe-point (~(get by pos.zim) who)
=/ =point (fall maybe-point *point)
=. point
2019-07-19 01:26:15 +03:00
?- -.a-diff
2019-07-06 00:17:09 +03:00
%spon
2019-07-19 01:26:15 +03:00
point(sponsor to.a-diff)
2019-06-26 21:31:37 +03:00
::
2019-07-06 00:17:09 +03:00
%rift
2019-07-19 01:26:15 +03:00
point(rift to.a-diff)
2019-06-26 21:31:37 +03:00
::
2019-07-06 00:17:09 +03:00
%keys
2019-06-26 21:31:37 +03:00
%_ point
2019-07-19 01:26:15 +03:00
life life.to.a-diff
2019-06-26 21:31:37 +03:00
keys
%+ ~(put by keys.point)
2019-07-19 01:26:15 +03:00
life.to.a-diff
[crypto-suite pass]:to.a-diff
2019-06-26 21:31:37 +03:00
==
==
=. pos.zim (~(put by pos.zim) who point)
2019-07-19 01:26:15 +03:00
%+ public-keys-give
2019-06-26 21:31:37 +03:00
(~(get ju ney.zim) who)
?~ maybe-point
[%full (my [who point]~)]
2019-07-19 01:26:15 +03:00
[%diff who a-diff]
2019-06-25 21:54:42 +03:00
:: :: ++vein:feel:su
2019-06-26 21:31:37 +03:00
++ private-keys :: kick private keys
|= [=life =ring]
2019-06-25 21:54:42 +03:00
^+ ..feel
2019-06-26 21:31:37 +03:00
?: &(=(lyf.own life) =((~(get by jaw.own) life) `ring))
2019-06-25 21:54:42 +03:00
..feel
2019-06-26 21:31:37 +03:00
=. lyf.own life
=. jaw.own (~(put by jaw.own) life ring)
(exec yen.own [%give %private-keys lyf.own jaw.own])
2019-06-25 21:54:42 +03:00
::
2019-06-26 21:31:37 +03:00
++ sources
|= [whos=(set ship) =source]
2019-06-25 21:54:42 +03:00
^+ ..feel
2019-06-26 22:53:41 +03:00
?: ?=(%& -.source)
2019-06-26 23:14:45 +03:00
=/ send-message
|= =message
[hen %pass /public-keys %a %want p.source /k/public-keys message]
=. ..feel
(emit (send-message %nuke whos))
(emit (send-message %public-keys whos))
2019-06-26 21:31:37 +03:00
=^ =source-id this-su (get-source-id source)
=. ..feed
?~ whos
..feed(default-source.etn source-id)
=/ whol=(list ship) ~(tap in `(set ship)`whos)
=. ship-sources.etn
|- ^- (map ship ^source-id)
?~ whol
ship-sources.etn
(~(put by $(whol t.whol)) i.whol source-id)
=. ship-sources-reverse
%- ~(gas ju ship-sources-reverse)
(turn whol |=(=ship [source-id ship]))
..feed
(exec yen.etn [%give %source whos source])
2019-06-25 21:54:42 +03:00
--
:: :: ++meet:su
++ meet :: seen after breach
|= [who=ship =life =pass]
2019-06-26 21:31:37 +03:00
:: XX rethink meet
2019-06-25 21:54:42 +03:00
^+ +>
2019-06-26 21:31:37 +03:00
!!
2019-06-25 21:54:42 +03:00
--
--
:: ::::
:::: # vane :: interface
:: ::::
::
:: lex: all durable %kale state
::
=| lex/state
|= $: ::
:: our: identity
:: now: current time
:: eny: unique entropy
:: ski: namespace resolver
::
our=ship
now=@da
eny=@uvJ
ski=sley
==
^?
|%
:: :: ++call
++ call :: request
|= $: :: hen: cause of this event
:: hic: event data
::
hen/duct
hic/(hypo (hobo task:able))
==
^- [(list move) _..^$]
=/ =task:able
?. ?=($soft -.q.hic)
q.hic
(task:able p.q.hic)
=^ did lex
abet:(~(call of [our now eny] lex) hen task)
[did ..^$]
:: :: ++load
++ load :: upgrade
|= $: :: old: previous state
::
2019-06-26 21:31:37 +03:00
old/*
:: old/state
2019-06-25 21:54:42 +03:00
==
^+ ..^$
..^$
:: ..^$(lex old)
:: :: ++scry
++ scry :: inspect
|= $: :: fur: event security
:: ren: access mode
:: why: owner
:: syd: desk (branch)
:: lot: case (version)
:: tyl: rest of path
::
fur/(unit (set monk))
ren/@tas
why/shop
syd/desk
lot/coin
tyl/spur
==
^- (unit (unit cage))
:: XX review for security, stability, cases other than now
::
?. =(lot [%$ %da now]) ~
?. =(%$ ren) [~ ~]
?+ syd
~
::
%code
?. ?=([@ ~] tyl) [~ ~]
?. =([%& our] why)
[~ ~]
=/ who (slaw %p i.tyl)
?~ who [~ ~]
2019-06-26 21:31:37 +03:00
=/ sec (~(got by jaw.own.pki.lex) lyf.own.pki.lex)
2019-06-25 21:54:42 +03:00
=/ cub (nol:nu:crub:crypto sec)
:: XX use pac:ex:cub?
::
``[%noun !>((end 6 1 (shaf %pass (shax sec:ex:cub))))]
::
%life
?. ?=([@ ~] tyl) [~ ~]
?. =([%& our] why)
[~ ~]
=/ who (slaw %p i.tyl)
?~ who [~ ~]
:: fake ships always have life=1
::
2019-06-26 21:31:37 +03:00
?: fak.own.pki.lex
2019-06-25 21:54:42 +03:00
``[%atom !>(1)]
?: =(u.who p.why)
2019-06-26 21:31:37 +03:00
``[%atom !>(lyf.own.pki.lex)]
=/ pub (~(get by pos.zim.pki.lex) u.who)
2019-06-25 21:54:42 +03:00
?~ pub ~
``[%atom !>(life.u.pub)]
::
%rift
?. ?=([@ ~] tyl) [~ ~]
?. =([%& our] why)
[~ ~]
=/ who (slaw %p i.tyl)
?~ who [~ ~]
:: fake ships always have rift=1
::
2019-06-26 21:31:37 +03:00
?: fak.own.pki.lex
2019-06-25 21:54:42 +03:00
``[%atom !>(1)]
2019-06-26 21:31:37 +03:00
=/ pos (~(get by pos.zim.pki.lex) u.who)
2019-06-25 21:54:42 +03:00
?~ pos ~
2019-06-26 21:31:37 +03:00
``[%atom !>(rift.u.pos)]
2019-06-25 21:54:42 +03:00
::
%deed
?. ?=([@ @ ~] tyl) [~ ~]
?. &(?=(%& -.why) =(p.why our))
[~ ~]
=/ who (slaw %p i.tyl)
=/ lyf (slaw %ud i.t.tyl)
?~ who [~ ~]
?~ lyf [~ ~]
=/ rac (clan:title u.who)
::
?: ?=(%pawn rac)
?. =(u.who p.why)
[~ ~]
?. =(1 u.lyf)
[~ ~]
2019-06-26 21:31:37 +03:00
=/ sec (~(got by jaw.own.pki.lex) u.lyf)
2019-06-25 21:54:42 +03:00
=/ cub (nol:nu:crub:crypto sec)
=/ sig (sign:as:cub (shaf %self (sham [u.who 1 pub:ex:cub])))
:^ ~ ~ %noun
!> ^- deed:ames
[1 pub:ex:cub `sig]
::
?: ?=(%earl rac)
?. =(u.who p.why)
[~ ~]
2019-06-26 21:31:37 +03:00
?: (gth u.lyf lyf.own.pki.lex)
2019-06-25 21:54:42 +03:00
~
2019-06-26 21:31:37 +03:00
?: (lth u.lyf lyf.own.pki.lex)
2019-06-25 21:54:42 +03:00
[~ ~]
2019-06-26 21:31:37 +03:00
=/ sec (~(got by jaw.own.pki.lex) u.lyf)
2019-06-25 21:54:42 +03:00
=/ cub (nol:nu:crub:crypto sec)
:^ ~ ~ %noun
!> ^- deed:ames
2019-06-26 21:31:37 +03:00
[u.lyf pub:ex:cub sig.own.pki.lex]
2019-06-25 21:54:42 +03:00
::
2019-06-26 21:31:37 +03:00
=/ pub (~(get by pos.zim.pki.lex) u.who)
2019-06-25 21:54:42 +03:00
?~ pub
~
?: (gth u.lyf life.u.pub)
~
2019-06-26 21:31:37 +03:00
=/ pas (~(get by keys.u.pub) u.lyf)
2019-06-25 21:54:42 +03:00
?~ pas
~
:^ ~ ~ %noun
2019-06-26 21:31:37 +03:00
!> `deed:ames`[u.lyf pass.u.pas ~]
2019-06-25 21:54:42 +03:00
::
%earl
?. ?=([@ @ @ ~] tyl) [~ ~]
?. =([%& our] why)
[~ ~]
=/ who (slaw %p i.tyl)
=/ lyf (slaw %ud i.t.tyl)
=/ pub (slaw %ux i.t.t.tyl)
?~ who [~ ~]
?~ lyf [~ ~]
?~ pub [~ ~]
2019-06-26 21:31:37 +03:00
?: (gth u.lyf lyf.own.pki.lex)
2019-06-25 21:54:42 +03:00
~
2019-06-26 21:31:37 +03:00
?: (lth u.lyf lyf.own.pki.lex)
2019-06-25 21:54:42 +03:00
[~ ~]
:: XX check that who/lyf hasn't been booted
::
2019-06-26 21:31:37 +03:00
=/ sec (~(got by jaw.own.pki.lex) u.lyf)
2019-06-25 21:54:42 +03:00
=/ cub (nol:nu:crub:crypto sec)
=/ sig (sign:as:cub (shaf %earl (sham u.who u.lyf u.pub)))
``[%atom !>(sig)]
::
%sein
?. ?=([@ ~] tyl) [~ ~]
?. =([%& our] why)
[~ ~]
=/ who (slaw %p i.tyl)
?~ who [~ ~]
:^ ~ ~ %atom
!> ^- ship
(~(sein of [our now eny] lex) u.who)
::
%saxo
?. ?=([@ ~] tyl) [~ ~]
?. =([%& our] why)
[~ ~]
=/ who (slaw %p i.tyl)
?~ who [~ ~]
:^ ~ ~ %noun
!> ^- (list ship)
(~(saxo of [our now eny] lex) u.who)
::
2019-06-26 21:31:37 +03:00
%sources
2019-06-25 21:54:42 +03:00
?. ?=(~ tyl) [~ ~]
:^ ~ ~ %noun !>
2019-06-26 21:31:37 +03:00
etn.lex
2019-06-25 21:54:42 +03:00
::
%snap
?. ?=(~ tyl) [~ ~]
?: =(~ snaps.sap.lex)
`~
:^ ~ ~ %noun !>
|- ^- snapshot
=^ snap=[@ud snap=snapshot] snaps.sap.lex
~(get to snaps.sap.lex)
?: =(~ snaps.sap.lex)
snap.snap
$
::
%turf
?. ?=(~ tyl) [~ ~]
2019-06-26 21:31:37 +03:00
[~ ~ %noun !>(tuf.own.pki.lex)]
2019-06-25 21:54:42 +03:00
==
:: :: ++stay
++ stay :: preserve
lex
:: :: ++take
++ take :: accept
|= $: :: tea: order
:: hen: cause
:: hin: result
::
tea/wire
hen/duct
hin/(hypo sign)
==
^- [(list move) _..^$]
=^ did lex abet:(~(take of [our now eny] lex) tea hen q.hin)
[did ..^$]
--