8000 hash160/ripemd160: concrete hash missing in output script · Issue #126 · sipa/miniscript · GitHub
[go: up one dir, main page]

Skip to content

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

Open

Description

@benma

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

Activity

  1. benma commented on Jan 5, 2023

    @benma
    ContributorAuthor

    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).

  2. landabaso commented on Jan 23, 2023

    @landabaso

    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.

  3. added a commit that references this issue on Jan 23, 2023
    cf40a2d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0