diff --git a/pkg/arvo/lib/naive-transactions.hoon b/pkg/arvo/lib/naive-transactions.hoon index 6a4983163..949b13167 100644 --- a/pkg/arvo/lib/naive-transactions.hoon +++ b/pkg/arvo/lib/naive-transactions.hoon @@ -8,26 +8,6 @@ :: |% :: -:: ++ gen-tx-octs -:: :: takes in a nonce, tx:naive, and private key and returned a signed transactions as octs -:: :: -:: |= [=nonce tx=tx:naive pk=@] ^- octs -:: =/ raw=octs -:: ?- +<.tx -:: %spawn (get-spawn:bits -.tx +>.tx) -:: %transfer-point (get-transfer:bits -.tx +>.tx) -:: %configure-keys (get-keys:bits -.tx +>.tx) -:: %escape (get-escape:bits -.tx +.tx) -:: %cancel-escape (get-escape:bits -.tx +.tx) -:: %adopt (get-escape:bits -.tx +.tx) -:: %reject (get-escape:bits -.tx +.tx) -:: %detach (get-escape:bits -.tx +.tx) -:: %set-management-proxy (get-ship-address:bits -.tx +.tx) -:: %set-spawn-proxy (get-ship-address:bits -.tx +.tx) -:: %set-transfer-proxy (get-ship-address:bits -.tx +.tx) -:: == -:: %^ sign-tx pk nonce raw -:: :: TODO: does this uniquely produce the pubkey? ++ verifier ^- ^verifier:naive @@ -73,10 +53,14 @@ ~ == :: -++ gen-tx-octs - :: takes in a nonce, tx:naive, and private key and returned a signed transactions as octs - :: +++ gen-tx |= [=nonce tx=tx:naive pk=@] + :: takes in a nonce, tx:naive, and private key and returned a signed transactions as octs + %^ sign-tx pk nonce (gen-tx-octs tx) +:: +++ gen-tx-octs + :: generates octs for a transaction + |= tx=tx:naive |^ ^- octs =/ raw=octs @@ -93,7 +77,8 @@ %set-spawn-proxy (get-ship-address +.tx) %set-transfer-proxy (get-ship-address +.tx) == - %^ sign-tx pk nonce raw + raw + ::%^ sign-tx pk nonce raw :: ++ get-spawn |= [child=ship to=address] ^- octs diff --git a/pkg/arvo/tests/lib/naive.hoon b/pkg/arvo/tests/lib/naive.hoon index b3730f8b9..18c57df1e 100644 --- a/pkg/arvo/tests/lib/naive.hoon +++ b/pkg/arvo/tests/lib/naive.hoon @@ -194,8 +194,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-transfer %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 1 marbud-transfer-2 %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 marbud-transfer %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 1 marbud-transfer-2 %marbud-key-0)) owner.own:(~(got by points.state) ~marbud) :: ++ test-l1-changed-spawn-proxy ^- tang @@ -307,7 +307,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-sproxy %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 marbud-sproxy %marbud-key-0)) spawn-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-set-transfer-proxy ^- tang @@ -319,7 +319,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-tproxy %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 marbud-tproxy %marbud-key-0)) transfer-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-set-management-proxy ^- tang @@ -331,7 +331,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-mproxy %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 marbud-mproxy %marbud-key-0)) management-proxy.own:(~(got by points.state) ~marbud) :: ++ test-l2-spawn-proxy-deposit ^- tang @@ -355,7 +355,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 [marbud-own lt-spawn] %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 [marbud-own lt-spawn] %marbud-key-0)) transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) :: %+ expect-eq @@ -365,8 +365,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-sproxy %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 [marbud-spn lt-spawn] %marbud-skey)) + =^ f state (n state %bat q:(gen-tx 0 marbud-sproxy %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 [marbud-spn lt-spawn] %marbud-skey)) transfer-proxy.own:(~(got by points.state) ~linnup-torsyx) == :: @@ -380,9 +380,9 @@ |. =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-sproxy %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 1 lt-spawn-0 %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 lt-spawn-1 %marbud-skey)) + =^ f state (n state %bat q:(gen-tx 0 marbud-sproxy %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 1 lt-spawn-0 %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 lt-spawn-1 %marbud-skey)) state :: ++ test-marbud-l2-change-keys ^- tang @@ -396,7 +396,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 [marbud-own new-keys] %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 [marbud-own new-keys] %marbud-key-0)) |1:keys.net:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -405,13 +405,27 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-mproxy %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 [marbud-mgt new-keys] %marbud-mkey)) + =^ f state (n state %bat q:(gen-tx 0 marbud-mproxy %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 [marbud-mgt new-keys] %marbud-mkey)) |1:keys.net:(~(got by points.state) ~marbud) :: :: TODO: make sure nobody else can change these keys == :: +++ new-test-marbud-l2-change-keys ^- tang + =/ new-keys [%configure-keys suit encr auth |] + =| =^state:naive + =^ f state (init-marbud state) + =/ expect-state state + :: not sure why this isn't working, maybe check the +increment-nonce code for an example + %+ expect-eq + !> expect-state + ::!> state(keys.net:(~(got by points.state ~marbud)) [1 suit auth encr]) + :: + !> + =^ f state (n state %bat q:(gen-tx 0 [marbud-own new-keys] %marbud-key-1)) + state + :: :: TODO: transfer breach via transfer proxy ++ test-marbud-l2-proxies-transfer ^- tang =/ marbud-new-keys [marbud-own %configure-keys suit encr auth |] @@ -438,10 +452,10 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-sproxy %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 1 marbud-mproxy %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 2 marbud-tproxy %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-xfr-breach %marbud-key-1)) + =^ f state (n state %bat q:(gen-tx 0 marbud-sproxy %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 1 marbud-mproxy %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 2 marbud-tproxy %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 marbud-xfr-breach %marbud-key-1)) ^- [[@ @] [@ @] [@ @] [@ @] [@ @]] own:(~(got by points.state) ~marbud) :: @@ -453,8 +467,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-new-keys %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 1 marbud-transfer-breach %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 marbud-new-keys %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 1 marbud-transfer-breach %marbud-key-0)) |1:keys.net:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -470,10 +484,10 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-sproxy %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 1 marbud-mproxy %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 2 marbud-tproxy %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-xfr-no-breach %marbud-key-1)) + =^ f state (n state %bat q:(gen-tx 0 marbud-sproxy %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 1 marbud-mproxy %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 2 marbud-tproxy %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 marbud-xfr-no-breach %marbud-key-1)) ^- [[@ @] [@ @] [@ @] [@ @] [@ @]] own:(~(got by points.state) ~marbud) :: @@ -485,8 +499,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 marbud-new-keys %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 1 marbud-transfer-no-breach %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 marbud-new-keys %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 1 marbud-transfer-no-breach %marbud-key-0)) |1:keys.net:(~(got by points.state) ~marbud) == :: @@ -509,8 +523,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 new-keys-no-reset %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 1 new-keys-no-reset %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 new-keys-no-reset %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 1 new-keys-no-reset %marbud-key-0)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -520,7 +534,7 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 new-keys-yes-reset %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 new-keys-yes-reset %marbud-key-0)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -532,9 +546,9 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 new-keys-yes-reset %marbud-key-0)) :: inc life and rift - =^ f state (n state %bat q:(gen-tx-octs 1 zero-keys-no-reset %marbud-key-0)) :: inc life - =^ f state (n state %bat q:(gen-tx-octs 2 zero-keys-yes-reset %marbud-key-0)) :: inc rift + =^ f state (n state %bat q:(gen-tx 0 new-keys-yes-reset %marbud-key-0)) :: inc life and rift + =^ f state (n state %bat q:(gen-tx 1 zero-keys-no-reset %marbud-key-0)) :: inc life + =^ f state (n state %bat q:(gen-tx 2 zero-keys-yes-reset %marbud-key-0)) :: inc rift [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -545,8 +559,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 new-keys-yes-reset %marbud-key-0)) :: inc life and rift - =^ f state (n state %bat q:(gen-tx-octs 1 new-keys-yes-reset %marbud-key-0)) :: inc life and rift + =^ f state (n state %bat q:(gen-tx 0 new-keys-yes-reset %marbud-key-0)) :: inc life and rift + =^ f state (n state %bat q:(gen-tx 1 new-keys-yes-reset %marbud-key-0)) :: inc life and rift [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -556,10 +570,10 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 new-keys-no-reset %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 1 marbud-transfer-no-breach %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 new-keys-no-reset %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 1 marbud-transfer-no-breach %marbud-key-0)) :: TODO: shouldn't the nonce by zero for the next tx? - =^ f state (n state %bat q:(gen-tx-octs 2 zero-keys-yes-reset %marbud-key-1)) + =^ f state (n state %bat q:(gen-tx 2 zero-keys-yes-reset %marbud-key-1)) [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -570,10 +584,10 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 new-keys-no-reset %marbud-key-0)) :: inc life - =^ f state (n state %bat q:(gen-tx-octs 1 marbud-transfer-yes-breach %marbud-key-0)) :: inc life and rift + =^ f state (n state %bat q:(gen-tx 0 new-keys-no-reset %marbud-key-0)) :: inc life + =^ f state (n state %bat q:(gen-tx 1 marbud-transfer-yes-breach %marbud-key-0)) :: inc life and rift :: TODO: shouldn't the nonce by zero for the next tx? - =^ f state (n state %bat q:(gen-tx-octs 2 new-keys-no-reset %marbud-key-1)) ::inc life + =^ f state (n state %bat q:(gen-tx 2 new-keys-no-reset %marbud-key-1)) ::inc life [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: %+ expect-eq @@ -587,9 +601,9 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 new-keys-yes-reset %marbud-key-0)) :: inc life and rift - =^ f state (n state %bat q:(gen-tx-octs 1 zero-keys-no-reset %marbud-key-0)) :: inc life - =^ f state (n state %bat q:(gen-tx-octs 2 marbud-transfer-yes-breach %marbud-key-0)) :: inc rift + =^ f state (n state %bat q:(gen-tx 0 new-keys-yes-reset %marbud-key-0)) :: inc life and rift + =^ f state (n state %bat q:(gen-tx 1 zero-keys-no-reset %marbud-key-0)) :: inc life + =^ f state (n state %bat q:(gen-tx 2 marbud-transfer-yes-breach %marbud-key-0)) :: inc rift [rift.net life.keys.net]:(~(got by points.state) ~marbud) :: == @@ -603,7 +617,7 @@ !> =| =^state:naive =^ f state (init-dopbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 pp-spawn %dopbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 pp-spawn %dopbud-key-0)) transfer-proxy.own:(~(got by points.state) ~palsep-picdun) :: ++ test-dopbud-l2-spawn-after-transfer ^- tang @@ -616,9 +630,9 @@ !> =| =^state:naive =^ f state (init-dopbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 pp-spawn %dopbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 pp-spawn %dopbud-key-0)) =^ f state (n state (owner-changed:l1 ~dopbud (addr %dopbud-key-1))) - =^ f state (n state %bat q:(gen-tx-octs 1 lr-spawn %dopbud-key-1)) + =^ f state (n state %bat q:(gen-tx 1 lr-spawn %dopbud-key-1)) transfer-proxy.own:(~(got by points.state) ~laclur-rachul) :: :: ++ test-sambud-double-spawn ^- tang @@ -661,8 +675,8 @@ !> =| =^state:naive =^ f state (init-marbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 lt-spawn %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 [lt-xfr lt-transfer-yes-breach] %lt-key-0)) + =^ f state (n state %bat q:(gen-tx 0 lt-spawn %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 [lt-xfr lt-transfer-yes-breach] %lt-key-0)) owner.own:(~(got by points.state) ~linnup-torsyx) :: ++ test-palsep-picdun-l2-transfer-ownership ^- tang @@ -675,8 +689,8 @@ !> =| =^state:naive =^ f state (init-dopbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 pp-spawn %dopbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 pp-transfer-yes-breach %pp-key-0)) + =^ f state (n state %bat q:(gen-tx 0 pp-spawn %dopbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 pp-transfer-yes-breach %pp-key-0)) owner.own:(~(got by points.state) ~palsep-picdun) :: ++ test-linnup-torsyx-l2-escape-request ^- tang @@ -690,9 +704,9 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 lt-spawn %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 lt-transfer-yes-breach %lt-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 [lt-own [%escape ~litbud]] %lt-key-0)) + =^ f state (n state %bat q:(gen-tx 0 lt-spawn %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 lt-transfer-yes-breach %lt-key-0)) + =^ f state (n state %bat q:(gen-tx 0 [lt-own [%escape ~litbud]] %lt-key-0)) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-cancel-escape-request ^- tang @@ -706,10 +720,10 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 lt-spawn %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 lt-transfer-yes-breach %lt-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 [lt-own [%escape ~litbud]] %lt-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 1 [lt-own [%cancel-escape ~litbud]] %lt-key-0)) + =^ f state (n state %bat q:(gen-tx 0 lt-spawn %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 lt-transfer-yes-breach %lt-key-0)) + =^ f state (n state %bat q:(gen-tx 0 [lt-own [%escape ~litbud]] %lt-key-0)) + =^ f state (n state %bat q:(gen-tx 1 [lt-own [%cancel-escape ~litbud]] %lt-key-0)) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-adopt-accept ^- tang @@ -723,10 +737,10 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 lt-spawn %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 lt-transfer-yes-breach %lt-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 [lt-own [%escape ~litbud]] %lt-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 [litbud-own [%adopt ~linnup-torsyx]] %litbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 lt-spawn %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 lt-transfer-yes-breach %lt-key-0)) + =^ f state (n state %bat q:(gen-tx 0 [lt-own [%escape ~litbud]] %lt-key-0)) + =^ f state (n state %bat q:(gen-tx 0 [litbud-own [%adopt ~linnup-torsyx]] %litbud-key-0)) [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-adopt-reject ^- tang @@ -742,10 +756,10 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 lt-spawn %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 lt-transfer-yes-breach %lt-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 [lt-own [%escape ~litbud]] %lt-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 [litbud-own [%reject ~linnup-torsyx]] %litbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 lt-spawn %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 lt-transfer-yes-breach %lt-key-0)) + =^ f state (n state %bat q:(gen-tx 0 [lt-own [%escape ~litbud]] %lt-key-0)) + =^ f state (n state %bat q:(gen-tx 0 [litbud-own [%reject ~linnup-torsyx]] %litbud-key-0)) escape.net:(~(got by points.state) ~linnup-torsyx) :: ++ test-linnup-torsyx-l2-detach ^- tang @@ -759,9 +773,9 @@ =| =^state:naive =^ f state (init-marbud state) =^ f state (init-litbud state) - =^ f state (n state %bat q:(gen-tx-octs 0 lt-spawn %marbud-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 0 lt-transfer-yes-breach %lt-key-0)) - =^ f state (n state %bat q:(gen-tx-octs 1 [marbud-own [%detach ~linnup-torsyx]] %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 lt-spawn %marbud-key-0)) + =^ f state (n state %bat q:(gen-tx 0 lt-transfer-yes-breach %lt-key-0)) + =^ f state (n state %bat q:(gen-tx 1 [marbud-own [%detach ~linnup-torsyx]] %marbud-key-0)) [escape.net sponsor.net]:(~(got by points.state) ~linnup-torsyx) :: :: TODO: signature format changed; regenerate