mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-14 08:34:25 +03:00
consolidate into lib
This commit is contained in:
parent
ce2ce2f586
commit
ca760c2a61
@ -8,6 +8,11 @@ Converts a base58 zpub to hex
|
||||
+bip84 "zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs"
|
||||
```
|
||||
|
||||
### btc-address
|
||||
```
|
||||
=btca -build-file %/lib/btc-address.hoon
|
||||
```
|
||||
|
||||
### decoded hex from base58
|
||||
Get the public key (start at 45 and take 33 bytes):
|
||||
```
|
||||
|
@ -1,7 +1,7 @@
|
||||
/+ bip84, bip32
|
||||
/+ btca=btc-address
|
||||
:- %say
|
||||
|= [[now=@da eny=@uvJ bec=beak] [zpub=tape ~] ~]
|
||||
:- %noun
|
||||
=/ bs=(list @ux)
|
||||
(zpub-bytes:bip84 zpub)
|
||||
(pubkey-to-point:bip32 bs)
|
||||
=/ bs=[(list @ux) (list @ux)]
|
||||
(parse-zpub:btca zpub)
|
||||
bs
|
||||
|
@ -1,11 +0,0 @@
|
||||
|%
|
||||
++ pubkey-to-point
|
||||
|= pubkey-bytes=(list @ux)
|
||||
^- pont:secp:crypto
|
||||
=/ as-atom=@
|
||||
(rap 3 (flop (swag [45 33] pubkey-bytes)))
|
||||
(decompress-point:secp256k1:secp:crypto as-atom)
|
||||
++ is-point
|
||||
|= pubkey=(list @ux) ^- ?
|
||||
%.y
|
||||
--
|
@ -1,10 +0,0 @@
|
||||
|%
|
||||
++ zpub-bytes
|
||||
|= zpub=tape
|
||||
^- (list @ux)
|
||||
=/ as-atom=@
|
||||
(de-base58:mimes:html zpub)
|
||||
%+ turn
|
||||
(flop (rip 3 as-atom))
|
||||
|=(bytes=@ `@ux`bytes)
|
||||
--
|
36
lib/btc-address.hoon
Normal file
36
lib/btc-address.hoon
Normal file
@ -0,0 +1,36 @@
|
||||
|%
|
||||
:: bytes rip: 0x6261 -> ~[98 97]
|
||||
::
|
||||
+$ pubkey (list @ux)
|
||||
+$ chaincode (list @ux)
|
||||
++ big-endian-brip
|
||||
|= a=@ux
|
||||
^- (list @ux)
|
||||
(flop (rip 3 a))
|
||||
:: bytes rap: ~[98 97] -> 0x6261
|
||||
::
|
||||
++ big-endian-brap
|
||||
|= bytes=(list @ux)
|
||||
^- @ux
|
||||
(swp 3 (rap 3 bytes))
|
||||
::
|
||||
++ parse-zpub
|
||||
|= zpub=tape
|
||||
^- [cc=chaincode pubk=pubkey]
|
||||
=/ as-atom=@ux
|
||||
(de-base58:mimes:html zpub)
|
||||
=/ bytes=(list @ux)
|
||||
(big-endian-brip as-atom)
|
||||
[(swag [13 32] bytes) (swag [45 33] bytes)]
|
||||
::
|
||||
++ pubkey-to-point
|
||||
|= pubkey-bytes=pubkey
|
||||
^- pont:secp:crypto
|
||||
=/ as-atom=@
|
||||
(rap 3 (flop (swag [45 33] pubkey-bytes)))
|
||||
(decompress-point:secp256k1:secp:crypto as-atom)
|
||||
::
|
||||
++ is-point
|
||||
|= pubkey=pubkey ^- ?
|
||||
-:(mule |.((pubkey-to-point pubkey)))
|
||||
--
|
Loading…
Reference in New Issue
Block a user