updates +moon to create keyfile with signature
user-specified moon, or generated from hashed entropy
-:: Generate random moon and corresponding ticket
+:: Create a private key-file for a random (or specified) moon
::
:::: /hoon/moon/gen
::
/? 310
-/- sole
-/+ old-zuse
-=, old-zuse
-=, sole
+/- *sole
::
::::
::
:- %ask
-|= $: {now/@da eny/@uvJ bec/beak}
- ~
+|= $: [now=@da eny=@uvJ bec=beak]
+ arg=?(~ [mon=@p ~])
~
==
-=/ ran (clan p.bec)
+=* our p.bec
+=/ ran (clan:title our)
?: ?=({?($earl $pawn)} ran)
%- sole-so
:- %tang :_ ~
leaf+"can't create a moon from a {?:(?=($earl ran) "moon" "comet")}"
-=/ mon (mix (lsh 5 1 (end 5 1 eny)) p.bec)
-=/ tic .^(@ /a/(scot %p p.bec)/tick/(scot %da now)/(scot %p mon))
-(sole-so [%tang leaf+"ticket: {<`@p`tic>}" leaf+"moon: {<`@p`mon>}" ~])
+=/ mon=ship
+ ?^ arg
+ mon.arg
+ (add our (lsh 5 1 (end 5 1 (shaz eny))))
+=/ seg=ship (sein:title our now mon)
+?. =(our seg)
+ %- sole-so
+ :- %tang :_ ~
+ leaf+"can't create keys for {(scow %p mon)}, which belongs to {(scow %p seg)}"
+=/ cub=acru:ames (pit:nu:crub:crypto 512 eny)
+=/ lyf=life .^(@ud j+/(scot %p our)/life/(scot %da now)/(scot %p our))
+=/ sig=oath:pki:jael
+ .^(@ j+/(scot %p our)/earl/(scot %da now)/(scot %p mon)/(scot %ud lyf)/(scot %ux pub:ex:cub))
+=/ sed=seed:able:jael
+ [mon lyf sec:ex:cub `sig]
+%+ sole-yo leaf+"moon: {(scow %p mon)}"
+%- sole-so [%atom (scot %uw (jam sed))]
