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

QIP-6: Add btc_ecrecover precompiled contract to Qtum's EVM #7

Open
Earlz opened this issue Nov 29, 2018 · 1 comment
Open

QIP-6: Add btc_ecrecover precompiled contract to Qtum's EVM #7

Earlz opened this issue Nov 29, 2018 · 1 comment

Comments

@Earlz
Copy link
Contributor

Earlz commented Nov 29, 2018

Abstract

In Qtum, bitcoin style pubkeyhash addresses are typically used as msg.sender. In this proposal it is made possible to test the signature produced by a pubkeyhash address and to recover that address from signed data.

Motivation

Currently in Qtum, by using the ecrecover function in Solidity, it is impossible to compare the address returned from it, to the pay-to-pubkeyhash address in msg.sender. This has been worked around by some projects by using a solidity Secp256K1.sol library contract. This is of course very expensive and cumbersome.

Specification

A new precompiled contract will be added to Qtum's version of the EVM, along with a library contract to allow it easy access to the precompiled contract function within contracts.

The interface should exactly match ecrecover, but instead is called btc_ecrecover. The recovered public key should be hashed using the pubkeyhash format: RIPEMD160(SHA256(SHA256(public key))). The gas costs and any other interface considerations should exactly match ecrecover.

Rationale

Though this is trivial to change, it is already a live network and there could be contracts making use of the current ecrecover functionality. Thus, it is unsafe to make a retroactive change of this magnitude. It is much safer, though slightly harder to use, to instead add a new precompiled contract with this functionality.

Strategy

This should be implemented in a hard fork at the same time as the EVM upgrades

@hayeah
Copy link

hayeah commented May 6, 2019

See: qtumproject/qtum#664

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

No branches or pull requests

2 participants