From 90379789a008395946c585d0c204d01efeba4b01 Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 23 Nov 2018 22:52:49 +0100 Subject: [PATCH 1/2] Update keygen in accordance with latest spec For details on these changes, see urbit/fora-posts#9. --- lib/keygen.hoon | 10 +++++++++- tests/lib/keygen.hoon | 11 +++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/keygen.hoon b/lib/keygen.hoon index 6d9303982e..e4074b2a5c 100644 --- a/lib/keygen.hoon +++ b/lib/keygen.hoon @@ -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 diff --git a/tests/lib/keygen.hoon b/tests/lib/keygen.hoon index 00bfd21c02..61ac4bf49b 100644 --- a/tests/lib/keygen.hoon +++ b/tests/lib/keygen.hoon @@ -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) -- From e42463583247688c3bad080436ae624fe4466c0f Mon Sep 17 00:00:00 2001 From: Fang Date: Fri, 23 Nov 2018 22:56:55 +0100 Subject: [PATCH 2/2] Use actual @q notation for tickets --- tests/lib/keygen.hoon | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/lib/keygen.hoon b/tests/lib/keygen.hoon index 61ac4bf49b..eb3ea23068 100644 --- a/tests/lib/keygen.hoon +++ b/tests/lib/keygen.hoon @@ -156,7 +156,7 @@ !> =- -(network *uode) %- full-wallet-from-ticket :+ ~nec :: 1 - 4^0x1.0102 ::TODO .~doznec-marbud + 4^.~doznec-marbud [0 ~] :: ++ test-generate-wallet-1 @@ -246,7 +246,7 @@ =- -(voting *node) %- full-wallet-from-ticket :+ ~matbyr :: 65.012 - 8^0x102.af04.0506.0798 ::TODO .~marbud-tidsev-litsut-hidfep + 8^.~marbud-tidsev-litsut-hidfep [0 ~] :: ++ test-generate-wallet-2 @@ -326,13 +326,10 @@ %- full-wallet-from-ticket :+ ~zod :- 48 - 0xc5a.b5ba.ea8e.e798.21d3.fc9f.8876.6da1. - 95bd.d4a6.3375.32fe.8f7f.d92f.d5f4.446a. - f9bf.0006.a211.823b.fbc9.a701.01e6.6f1f - ::TODO .~wacfus-dabpex-danted-mosfep-pasrud-lavmer- - :: nodtex-taslus-pactyp-milpub-pildeg-fornev- - :: ralmed-dinfeb-fopbyr-sanbet-sovmyl-dozsut- - :: mogsyx-mapwyc-sorrup-ricnec-marnys-lignex + .~wacfus-dabpex-danted-mosfep-pasrud-lavmer- + nodtex-taslus-pactyp-milpub-pildeg-fornev- + ralmed-dinfeb-fopbyr-sanbet-sovmyl-dozsut- + mogsyx-mapwyc-sorrup-ricnec-marnys-lignex [6 `'froot loops'] :: ++ test-derive-network-seed-rev-0