Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hash160/ripemd160: concrete hash missing in output script #126

Open
benma opened this issue Jan 5, 2023 · 2 comments · May be fixed by #132
Open

hash160/ripemd160: concrete hash missing in output script #126

benma opened this issue Jan 5, 2023 · 2 comments · May be fixed by #132

Comments

@benma
Copy link
Contributor

benma commented Jan 5, 2023

At https://bitcoin.sipa.be/miniscript/, if I enter this miniscript:

sha256(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)

I receive the expected script structure:

OP_SIZE <20> OP_EQUALVERIFY OP_SHA256
<aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> OP_EQUAL

For hash160/ripemd160 however, the hash is missing in the script. For example:

hash160(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) results in:

OP_SIZE <20> OP_EQUALVERIFY OP_HASH160  OP_EQUAL

(<a....> is missing before OP_EQUAL).

using hash160(H) correctly outputs:

OP_SIZE <20> OP_EQUALVERIFY OP_HASH160 <h> OP_EQUAL
@benma
Copy link
Contributor Author

benma commented Jan 5, 2023

I also just noticed this inconsistency:

In the translation table for the hash functions, the Bitcoin Script uses decimal <32>:

SIZE <32> EQUALVERIFY SHA256 <h> EQUAL

While the script structure compilation output prints it in hex <20>:

OP_SIZE <20> OP_EQUALVERIFY OP_HASH160 <h> OP_EQUAL

Did a double-take there - would be good to make this consistent and document which format is used for clarity (or maybe use the 0x prefix for hex values).

@landabaso
Copy link

landabaso commented Jan 23, 2023

There's also a subtle ~typo.
hash160(H) & ripemd160(H) (using upper case H as a variable) ends up producing ASM with <h> (lower case h).
Keeping case sensitive would also be nice.
sha256 and hash256 work as expected.

BTW: I'd rather keep the notation <20>, where 20 is in fact 0x20 when enclosed within angle quotation marks.

landabaso pushed a commit to bitcoinerlab/miniscript-sipa that referenced this issue Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants