-
-
Notifications
You must be signed in to change notification settings - Fork 60
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
💥 Version 0x00
of EIP-191 in ECDSA Library Implementation
#78
Comments
0x00
version of EIP191 in ECDSA Library 0x00
Version of EIP-191 in ECDSA Library
@YamenMerhi thanks for raising this point - actually I find it a reasonable addition to 🐍 snekmate. I would actually propose the following solution (ignoring the function docstrings): # @dev A Vyper contract cannot call directly between two `external` functions.
# To bypass this, we can use an interface.
interface IECDSA:
def to_data_with_intended_validator_hash(validator: address, data: Bytes[1024]) -> bytes32: pure
@external
@view
def to_data_with_intended_validator_hash_self(data: Bytes[1024]) -> bytes32:
return IECDSA(self).to_data_with_intended_validator_hash(self, data)
@external
@pure
def to_data_with_intended_validator_hash(validator: address, data: Bytes[1024]) -> bytes32:
return keccak256(concat(b"\x19\x00", convert(validator, bytes20), data)) This includes two functions PS: I removed the default param |
@pcaversaccio Your code makes sense, will do the PR. 👍 Also, I don't mind the additional function, as in most of the cases of data with the intended validator, it will be used by some sort of a smart contract account that will validate the signature based on self. |
Sounds like a plan 👍 |
0x00
Version of EIP-191 in ECDSA Library0x00
of EIP-191 in ECDSA Library Implementation
Describe the desired feature:
🧐 Motivation
In the current
ECDSA
library, there is support to construct a message to sign according to the EIP191 Standard with the following:0x45
(E) withto_eth_signed_message_hash(..)
function0x01
with theto_typed_data_hash(..)
function.But we are missing the
0x00
version.📝 Details
Version
0x00
version is not that used because people are misusing the standard, they are using the0x45
version for everything: signing messages for off-chain verification, for smart contract execution based on signatures, which is dangerous.As people could be easily tricked into signing a normal message, thinking it is for login purposes, and then end up having execution based on this signature, so we should have a different mechanism, then different handling for execution based on signatures, and that's why we should make people use the
0x00
version for this case. + some projects are starting to use it like xenium and the lsp-smart-contracts.I am suggesting adding a new function
to_data_with_intended_validator
orto_data_with_intended_validator_hash
to be compatible with the version0x00
taking 2 parameters,<address validator>
and<bytes dataToSign>
.A library that supports the case: EIP-191 Signer.
The Opened issue in OpenZeppelin: Implement 0x00 version of EIP191 in ECDSA Library
If you're okay with it I am happy to open the PR, otherwise, you can close the issue 😄
Code example that solves the feature:
The text was updated successfully, but these errors were encountered: