mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 16:51:42 +03:00
handle leading/trailing zeros correctly in hash-160
This commit is contained in:
parent
ffa34f53a8
commit
5b4619c1e8
@ -59,8 +59,14 @@ That one starts with pubkey below. The following runs it through sha256 and ripe
|
||||
Use `@uc` to make the Hash-160 into a BTC P2PKH address
|
||||
```
|
||||
=pubkey 0x2.5086.3ad6.4a87.ae8a.2fe8.3c1a.f1a8.403c.b53f.53e4.86d8.511d.ad8a.0488.7e5b.2352
|
||||
(p2pkh:bip173 pubkey)
|
||||
`@uc`(p2pkh:bip173 pubkey)
|
||||
(hash-160:bip173 pubkey)
|
||||
`@uc`(hash-160:bip173 pubkey)`@uc`(hash-160:bip173 pubkey)
|
||||
```
|
||||
|
||||
### trailing zeros
|
||||
Need to test with this because it shows need to input num bytes
|
||||
```
|
||||
0x3.f3c1.3839.3683.93e7.0caf.4148.4775.b805.312d.58be.d157.1308.3d27.5cf5.6998.0100
|
||||
```
|
||||
|
||||
## Deprecated: `btc-address` Child Derivations
|
||||
@ -91,3 +97,5 @@ Use `@uc` to make the Hash-160 into a BTC P2PKH address
|
||||
0x2.b092.22c4.98c3.ab97.ce2b.6c4d.e68f.07d4.b031.589c.4d6b.bd31.7791.068f.7347.5201
|
||||
|
||||
0x2.5086.3ad6.4a87.ae8a.2fe8.3c1a.f1a8.403c.b53f.53e4.86d8.511d.ad8a.0488.7e5b.2352
|
||||
0x2.3db4.d241.5936.c340.3de9.b0d9.e5e9.5dfb.43e6.0acd.aec9.0c9d.c17a.5c7c.26be.3150
|
||||
|
||||
|
@ -7,9 +7,10 @@
|
||||
++ hash-160
|
||||
|= pubkey=@ux
|
||||
^- @ux
|
||||
=/ sha (swp 3 (shax (swp 3 pubkey)))
|
||||
%- ripemd-160:ripemd:crypto
|
||||
[(met 3 sha) sha]
|
||||
=, ripemd:crypto
|
||||
:: use shay to preserve little endian length when there are trailing zeros
|
||||
=/ sha256 (swp 3 (shay 33 (swp 3 pubkey)))
|
||||
(ripemd-160 [32 sha256])
|
||||
:: Converts an atom to a list of n-bit numbers, flop to preserve big-endian
|
||||
::
|
||||
++ to-n-bit
|
||||
|
Loading…
Reference in New Issue
Block a user