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

bip-taproot: Internal pubkey construction seems to be inconsistent. #127

Closed
rajarshimaitra opened this issue Nov 6, 2019 · 3 comments · Fixed by #128
Closed

bip-taproot: Internal pubkey construction seems to be inconsistent. #127

rajarshimaitra opened this issue Nov 6, 2019 · 3 comments · Fixed by #128

Comments

@rajarshimaitra
Copy link

In the implementation of taproot_tweak_pubkey() :

def taproot_tweak_pubkey(pubkey, h):
    t = int_from_bytes(tagged_hash("TapTweak", pubkey + h))
    if t >= SECP256K1_ORDER:
        raise ValueError
    Q = point_mul(point(pubkey), t)
    return bytes_from_int(x(Q)), has_square_y(Q)

Internal pubkey is calculated as Q=point_mul(point(pubkey), t).
Which feels (at least to me) like point multiplication, and that would be Q = (t * P).

But Script Validation Rule is stating :

If Q ≠ P + int(t)G, fail.

This is same as Q = P + (t * G)

And these are two distinct operation and gives distinct results, and can be a source of confusion.

Assuming the protocol document to be correct.

I suggest changing the implementation as:

Q= point(pubkey) + point_mul(G, t)

@sipa
Copy link
Owner

sipa commented Nov 6, 2019

This seems like a mistake, indeed.

@rajarshimaitra
Copy link
Author

Is the suggested change acceptable? I would open pr then.

@sipa
Copy link
Owner

sipa commented Nov 6, 2019

It should be point_add(point(pubkey), point_mul(G, t)), I think.

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