2020-09-30 13:32:09 +03:00
|
|
|
## NOTE
|
|
|
|
The below requires norsyr's fix to `decompress-point` in order to work.
|
2020-09-28 11:09:04 +03:00
|
|
|
|
|
|
|
## base58
|
|
|
|
Converts a base58 zpub to hex
|
|
|
|
```
|
|
|
|
+bip84 "zpub6rFR7y4Q2AijBEqTUquhVz398htDFrtymD9xYYfG1m4wAcvPhXNfE3EfH1r1ADqtfSdVCToUG868RvUUkgDKf31mGDtKsAYz2oz2AGutZYs"
|
|
|
|
```
|
2020-09-28 14:08:14 +03:00
|
|
|
|
2020-09-30 09:40:26 +03:00
|
|
|
### btc-address
|
2020-09-30 11:12:52 +03:00
|
|
|
**Import lib; optionally set up env**
|
2020-09-30 09:40:26 +03:00
|
|
|
```
|
2020-09-30 10:05:52 +03:00
|
|
|
=btca -build-file %/lib/btc-address/hoon
|
2020-09-30 13:32:09 +03:00
|
|
|
=bip32 -build-file %/lib/bip32/hoon
|
2020-09-30 16:42:40 +03:00
|
|
|
=ecc secp256k1:secp:crypto
|
2020-09-30 16:15:37 +03:00
|
|
|
=xpub "xpub6DnWFmBQfQm1wxvKkCJjXwE6H4v8FTwUuhjDQ9ZpJnFDfhA8Dwmg71yPKyjUE93D2CB6MdnWNvGmwsb3fpd4oRJ2YcyMZoMpLU3BjpmQAny"
|
2020-09-30 16:42:40 +03:00
|
|
|
=parent-zpub "zpub6rmyMSPvm5aexi2PidLFG5ERHCeNQgT3KrkXT6pEPK82zFntRUE5MqwEZCanG5NPzmDvfJ9vAr6NxzTx9FAPTAEN1JFPcL1M7CXNd5WKcP9"
|
|
|
|
=zpub "zpub6sLyD5WyhVybzoATevSndC5jmhHjfxKjDA5A21DXzoYUJyFyfUo9cW7WX7veTkKVzHjh2Npvfcm5KTT89go29p3PJtscYH4CiYzVbwV5iJW"
|
2020-09-30 11:12:52 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
**Test child public key from xpub**
|
|
|
|
```
|
2020-09-30 16:15:37 +03:00
|
|
|
`@ux`(child-from-xpub:btca xpub 0)
|
2020-09-30 11:12:52 +03:00
|
|
|
(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))
|
|
|
|
```
|
|
|
|
|
2020-09-30 13:32:09 +03:00
|
|
|
**Same, with Jose's bip32 library**
|
|
|
|
```
|
2020-09-30 16:15:37 +03:00
|
|
|
`@ux`(compress-point:secp256k1:secp:crypto pub:(derive-public:(from-extended:bip32 xpub) 0))
|
2020-09-30 16:42:40 +03:00
|
|
|
`@ux`(compress-point:secp256k1:secp:crypto pub:(derive-public:(from-extended:bip32 zpub) 0))
|
|
|
|
|
|
|
|
:: get same zpub point as above starting from parent-zpub
|
|
|
|
`@ux`(compress-point:ecc pub:(derive-public:(derive-public:(from-extended:bip32 parent-zpub) 0) 0))
|
2020-09-30 13:32:09 +03:00
|
|
|
```
|
|
|
|
|
2020-09-30 16:42:40 +03:00
|
|
|
## Deprecateed: Sample Child Derivations
|
|
|
|
|
2020-09-30 11:12:52 +03:00
|
|
|
**Test xpub parsing**
|
|
|
|
```
|
|
|
|
(parse-xpub:btca xpub)
|
|
|
|
```
|
|
|
|
|
|
|
|
**Test addition and ECC point checking**
|
|
|
|
```
|
2020-09-30 16:15:37 +03:00
|
|
|
=px (parse-xpub:btca xpub)
|
2020-09-30 11:12:52 +03:00
|
|
|
=pubk ?~ px ~ pubk.u.px
|
2020-09-30 10:05:52 +03:00
|
|
|
(is-point:btca pubk)
|
2020-09-30 13:32:09 +03:00
|
|
|
(pubkey-to-point:btca pubk)
|
2020-09-30 11:12:52 +03:00
|
|
|
=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)))
|
2020-09-28 14:08:14 +03:00
|
|
|
```
|