Include continuity flag in relative public key state

This commit is contained in:
Fang 2018-08-30 02:02:17 +02:00
parent 2d04795fd9
commit c5c4d0f65f
2 changed files with 63 additions and 44 deletions

View File

@ -61,7 +61,7 @@
== ::
$= puk :: public keys (pubs)
$: yen=(jug ship duct) :: trackers
kyz=(map ship (map life pass)) :: public key versions
kyz=(map ship public) :: public key state
== ::
$= eth :: ethereum (vent)
::TODO the subscribers here never hear dns or hul...
@ -900,11 +900,10 @@
++ pubs
|= who=ship
%_ ..feed
moz =/ zen (~(get by kyz.puk) who)
?~ zen moz
=/ lyf (roll ~(tap in ~(key by u.zen)) max)
?: =(0 lyf) moz
[[hen %give %pubs lyf u.zen] moz]
moz =/ pub (~(get by kyz.puk) who)
?~ pub moz
?: =(0 life.u.pub) moz
[[hen %give %pubs u.pub] moz]
yen.puk (~(put ju yen.puk) who hen)
==
:: :: ++vein:feed:su
@ -933,33 +932,25 @@
|%
:: :: ++pubs:feel:su
++ pubs :: kick public keys
|= kez=(map ship (map life pass))
=/ kes ~(tap by kez)
:: puz: new public key states
|= puz=(map ship public)
=/ pus ~(tap by puz)
::
:: process change for each ship separately
::
|- ^+ ..feel
?~ kes ..feel
=; fel $(kes t.kes, ..feel fel)
=* who p.i.kes
=* kyn q.i.kes
=/ lyf (roll ~(tap in ~(key by kyn)) max)
::
:: build new public key store
::
=+ %+ ~(put by kyz.puk) who
=- (~(uni by -) kyn)
(fall (~(get by kyz.puk) who) ~)
?~ pus ..feel
=; fel $(pus t.pus, ..feel fel)
=* who p.i.pus
=* pub q.i.pus
::
:: update public key store and notify subscribers
:: of the change
:: of the new state
::
:: XX we're sending a map here, but it only contains the update
:: send full key history? or use [%pubs =life =pass]
::
%+ exec(kyz.puk -)
~& [%sending-pubs-about who]
%+ exec(kyz.puk (~(put by kyz.puk) who pub))
(~(get ju yen.puk) who)
[%give %pubs lyf kyn]
[%give %pubs pub]
:: :: ++vein:feel:su
++ vein :: kick private keys
^+ ..feel
@ -1077,22 +1068,39 @@
?:(new &+evs |+evs)
::
=+ vez=(order-events:ez ~(tap by evs))
=| kyz=(map ship (map life pass))
=| kyz=(map ship public)
|^ ?~ vez (pubs:feel kyz)
=^ kyn ..file (file-event i.vez)
$(vez t.vez, kyz kyn)
::
++ get-public
|= who=ship
^- public
%+ fall (~(get by kyz) who)
::NOTE we can only do this because ++pubs:feel
:: sends out entire new state, rather than
:: just the processed changes.
%+ fall (~(get by kyz.puk) who)
%*(. *public live |)
::
++ file-keys
|= [who=ship =life =pass]
^+ kyz
=/ zen (fall (~(get by kyz) who) ~)
=/ pub (~(get by zen) life)
?~ pub
%+ ~(put by kyz)
who
(~(put by zen) life pass)
~| [%key-mismatch who life]
?>(=(u.pub pass) kyz)
=/ pub (get-public who)
=/ puk (~(get by pubs.pub) life)
?^ puk
:: key known, nothing changes
~| [%key-mismatch who life]
?>(=(u.puk pass) kyz)
%+ ~(put by kyz) who
:+ live.pub
(max life life.pub)
(~(put by pubs.pub) life pass)
::
++ file-discontinuity
|= who=ship
=+ (get-public who)
(~(put by kyz) who -(live |))
::
++ file-event
|= [wer=event-id dif=diff-constitution]
@ -1117,10 +1125,14 @@
|= [who=ship dif=diff-hull]
^+ [kyz ..file]
=- ::TODO =; with just the type
:- ?~ kez kyz
(file-keys who u.kez)
:- ?: ?=(%& -.new)
(file-keys who p.new)
?: p.new kyz
(file-discontinuity who)
..file(hul.eth (~(put by hul.eth) who hel))
^- [hel=hull kez=(unit (pair life pass))]
:: hel: updated hull
:: new: new keypair or "kept continuity?" (yes is no-op)
^- [hel=hull new=(each (pair life pass) ?)]
=+ hul=(fall (~(get by hul.eth) who) *hull)
::
:: sanity checks, should never fail if we operate correctly
@ -1134,14 +1146,16 @@
=(new.dif +(continuity-number.u.net.hul))
==
::
:: apply hull changes, catch key changes
:: apply hull changes, catch continuity and key changes
::
:- (apply-hull-diff hul dif)
?+ -.dif ~
%keys `[life pass]:dif
%full ?~ net.new.dif ~
::TODO do we want/need to do a diff-check
`[life pass]:u.net.new.dif
=* nop |+& :: no-op
?+ -.dif nop
%continuity |+|
%keys &+[life pass]:dif
%full ?~ net.new.dif nop
::TODO do we want/need to do a diff-check
&+[life pass]:u.net.new.dif
==
::
++ file-dns

View File

@ -1989,7 +1989,7 @@
== == ::
++ gift :: out result <-$
$% [%mack p=(unit tang)] :: message n/ack
[%pubs =life pubs=(map life pass)] :: public keys
[%pubs public] :: public keys
{$vest p/tally} :: balance update
[%vein =life vein=(map life ring)] :: private keys
{$vine p/(list change)} :: all raw changes
@ -2003,6 +2003,11 @@
[%a %want p=sock q=path r=*] :: send message
[%j %vent-result p=chain] :: tmp workaround
== ::
++ public :: public key state
$: live=? :: seen in current era
life=life :: current key number
pubs=(map life pass) :: pubkeys by number
== ::
++ remote :: remote notification
%+ each safe :: &/addition
safe :: |/replacement