From 21775ec090dcde66065ca057de8bca5ad15bd663 Mon Sep 17 00:00:00 2001 From: yosoyubik Date: Thu, 5 Aug 2021 12:38:07 +0200 Subject: [PATCH] azimuth-rpc: encrypt/auth keys as hex strings --- pkg/arvo/lib/azimuth-rpc.hoon | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/pkg/arvo/lib/azimuth-rpc.hoon b/pkg/arvo/lib/azimuth-rpc.hoon index 1087cd3695..a48adab989 100644 --- a/pkg/arvo/lib/azimuth-rpc.hoon +++ b/pkg/arvo/lib/azimuth-rpc.hoon @@ -55,11 +55,15 @@ |= params=(map @t json) ^- (unit [encrypt=@ auth=@ crypto-suite=@ breach=?]) ?~ data=(~(get by params) 'data') ~ + =; ans=(unit [cryp=(unit @ux) auth=(unit @ux) suit=@ brec=?]) + ?~ ans ~ + ?: |(?=(~ cryp.u.ans) ?=(~ auth.u.ans)) ~ + (some [u.cryp.u.ans u.auth.u.ans suit.u.ans brec.u.ans]) %. u.data %- ot - :~ ['encrypt' so] - ['auth' so] - ['cryptoSuite' so] + :~ ['encrypt' (cu to-hex so)] + ['auth' (cu to-hex so)] + ['cryptoSuite' no] ['breach' bo] == :: @@ -286,15 +290,15 @@ =* net net.point :* ['rift' (numb rift.net)] :: + =, mimes:html :- 'keys' %- pairs :~ ['life' (numb life.keys.net)] ['suite' (numb suite.keys.net)] - ['auth' (numb auth.keys.net)] - ['crypt' (numb crypt.keys.net)] + ['auth' (hex (as-octs auth.keys.net))] + ['crypt' (hex (as-octs crypt.keys.net))] == :: - ['rift' (numb rift.net)] :- 'sponsor' %- pairs ~[['has' b+has.sponsor.net] ['who' (ship who.sponsor.net)]] @@ -360,16 +364,9 @@ ++ to-hex |= =cord ^- (unit @ux) + ?. =((end [3 2] cord) '0x') ~ (rush (rsh [3 2] cord) hex) :: - ++ validate - |% - ++ params - |= params=(map @t json) - ^- ? - =((lent ~(tap by params)) 4) - -- - :: ++ build-l2-tx |= [=l2-tx from=[@p proxy:naive] params=(map @t json)] ^- (unit tx:naive) @@ -465,7 +462,7 @@ ++ process-rpc |= [id=@t params=(map @t json) action=l2-tx] ^- [(unit cage) response:rpc] - ?. (params:validate params) + ?. =((lent ~(tap by params)) 4) [~ ~(params error:json-rpc id)] =+ ^- $: sig=(unit @) from=(unit [ship proxy:naive]) @@ -563,9 +560,8 @@ nonce=(unit @ud) from=(unit [@p proxy:naive]) == - :+ (tx:from-json params) - (nonce:from-json params) - (from:from-json params) + =, from-json + [(tx params) (nonce params) (from params)] ?: |(?=(~ nonce) ?=(~ from) ?=(~ l2-tx)) ~(parse error:json-rpc id) =/ tx=(unit tx:naive) (build-l2-tx u.l2-tx u.from params)