Update keygen in accordance with latest spec

For details on these changes, see urbit/fora-posts#9.
This commit is contained in:
Fang 2018-11-23 22:52:49 +01:00
parent 717073b22d
commit 90379789a0
2 changed files with 20 additions and 1 deletions

View File

@ -28,6 +28,14 @@
%+ to-seed:bip39 nom
(trip (fall pass ''))
::
++ derive-network-seed
|= [mngs=@ rev=@ud]
^- @ux
=+ (seed:ds 64^mngs (weld "network" (a-co:co rev)))
?: =(0 rev) -
:: hash again to prevent length extension attacks
(sha-256l:sha 32 -)
::
++ full-wallet-from-ticket
:: who: username
:: ticket: password
@ -62,7 +70,7 @@
%+ to-seed:bip39
seed:management
(trip (fall pass ''))
=+ sed=(seed:ds 64^mad (weld "network" (a-co:co rev)))
=+ sed=(derive-network-seed mad rev)
[rev sed (urbit:ds sed)]
::
++ ds :: derive from raw seed

View File

@ -334,4 +334,15 @@
:: ralmed-dinfeb-fopbyr-sanbet-sovmyl-dozsut-
:: mogsyx-mapwyc-sorrup-ricnec-marnys-lignex
[6 `'froot loops']
::
++ test-derive-network-seed-rev-0
%+ expect-eq
!> (seed:ds 64^0x5eed "network0")
!> (derive-network-seed 0x5eed 0)
::
++ test-derive-network-seed-rev-up
%+ expect-eq
!> |
!> .= (seed:ds 64^0x5eed "network1")
(derive-network-seed 0x5eed 1)
--