urbit/bippy-scratch.md

940 B

base58

Converts a base58 zpub to hex

+bip84 "zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs"

btc-address

Import lib; optionally set up env

=btca -build-file %/lib/btc-address/hoon
=xpub "zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs"

Test child public key from xpub

(child-from-xpub:btca xpub 1)
(child-from-xpub:btca xpub (dec (bex 31)))

::  should error as index is too high (hardened key range)
(child-from-xpub:btca xpub (bex 31))

Test xpub parsing

(parse-xpub:btca xpub)

Test addition and ECC point checking

=px (parse-xpub:btca xpub)
=pubk ?~  px  ~  pubk.u.px
(is-point:btca pubk)
=index 256
`@ux`(add (lsh 3 4 (big-endian-brap:btca pubk)) index)

Test computing I

(bind px |=(px=parsed-xpub:btca (compute-i:btca px 1)))