naive: fix +tx

This commit is contained in:
Philip Monk 2021-04-28 22:04:11 -07:00
parent 75eeef544e
commit 27949c5d8a
No known key found for this signature in database
GPG Key ID: B66E1F02604E44EC
4 changed files with 31 additions and 23 deletions

View File

@ -41,15 +41,15 @@
|= sig=(unit @t)
^- @t
=/ account (hex-to-num:eth '0xb026b0AA6e686F2386051b31A03E5fB95513e1c0')
=/ tx=octs (set-spawn-proxy:l2:tt 0 ~ravmun-mitbus %ravmun %own account)
=/ prep=octs [(sub p.tx 65) (rsh 3^65 q.tx)]
=/ nonced=octs [(add p.prep 4) (can 3 4^1 prep ~)]
=/ tx=octs
(take-ship-address:bits:l2:tt %set-spawn-proxy ~ravmun-mitbus %own account)
=/ prepped=octs (prepare-for-sig:tt 3 0 tx)
?~ sig
(cat 3 'sign: ' (print-for-web3 nonced))
(cat 3 'sign: ' (print-for-web3 prepped))
=/ batch=@t
%: rap 3
'0x26887f26'
(print-for-batch prep)
(print-for-batch tx)
(rsh 3^2 u.sig)
~
==

View File

@ -136,7 +136,7 @@
::
++ launch 4.601.630
++ public launch
++ chain-id 1
++ chain-id 3
--
::
:: Local contract addresses

View File

@ -125,10 +125,10 @@
|%
:: ethereum address, 20 bytes.
::
+$ address @ux
+$ nonce @ud
+$ dominion ?(%l1 %l2 %spawn)
+$ keys [=life suite=@ud auth=@ crypt=@]
+$ address @ux
+$ nonce @ud
+$ dominion ?(%l1 %l2 %spawn)
+$ keys [=life suite=@ud auth=@ crypt=@]
++ point
$: :: domain
::
@ -206,7 +206,11 @@
$% [%bat batch=@]
[%log =event-log]
==
:: ECDSA verifier
:: ECDSA verifier.
::
:: Must keccak `dat` and recover the ethereum address which signed.
:: Must not crash. `v` will normally be between 0 and 3; if it is not,
:: should produce null.
::
+$ verifier $-([dat=octs v=@ r=@ s=@] (unit address))
-- =>
@ -333,7 +337,7 @@
^- ?
|^
=/ point (get-point state ship.from.tx.raw-tx)
?> ?=(^ point) :: we never parse more than four bytes
?> ?=(^ point) :: we never parse more than four bytes for a ship
=/ need=[=address =nonce]
?- proxy.from.tx.raw-tx
%own owner.own.u.point
@ -708,7 +712,7 @@
`net.point
=/ =keys [+(life.keys.net.point) 0 0 0]
:- :~ [%point ship %rift +(rift.net.point)]
[%point ship %keys keys] :: TODO: 0?
[%point ship %keys keys]
==
[+(rift.net.point) keys sponsor.net.point escape.net.point]
=/ effects-3

View File

@ -65,16 +65,7 @@
::
++ sign-tx
|= [pk=@ nonce=@ud tx=octs] ^- octs
=/ prepared-data=octs
=/ chain-t (rsh [3 2] (scot %ui 1.337))
%: cad:naive 3
14^'UrbitIDV1Chain'
(met 3 chain-t)^chain-t
1^':'
4^nonce
tx
~
==
=/ prepared-data (prepare-for-sig 1.337 nonce tx)
=/ sign-data
=/ len (rsh [3 2] (scot %ui p.prepared-data))
%- keccak-256:keccak:crypto
@ -87,6 +78,19 @@
=+ (ecdsa-raw-sign:secp256k1:secp:crypto sign-data pk)
(cad:naive 3 1^v 32^s 32^r tx ~)
::
++ prepare-for-sig
|= [chain-id=@ud nonce=@ud tx=octs]
^- octs
=/ chain-t (rsh [3 2] (scot %ui chain-id))
%: cad:naive 3
14^'UrbitIDV1Chain'
(met 3 chain-t)^chain-t
1^':'
4^nonce
tx
~
==
::
++ l1
|%
::