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

lib: method for eip-1271 #80

Merged
merged 4 commits into from
May 10, 2022
Merged

lib: method for eip-1271 #80

merged 4 commits into from
May 10, 2022

Conversation

q9f
Copy link
Owner

@q9f q9f commented May 6, 2022

closes #44

@q9f
Copy link
Owner Author

q9f commented May 6, 2022

paging @w4ll3 - could you please take a look if this would make sense for you?

c = Contract.create(file: "spec/fixtures/contracts/signer.sol", contract_index: 1)
# => #<Eth::Contract::Signer:0x0000556cd236ff30>
g = Eth::Client.create "/tmp/geth.ipc"
# => #<Eth::Client::Ipc:0x0000556cd23c34a0 @gas_limit=21000, @id=0, @max_fee_per_gas=0.2e11, @max_priority_fee_per_gas=0, @path="/tmp/geth.ipc">
m = "I am authentic!"
# => "I am authentic!"
p = Signature.prefix_message m
# => "\u0019Ethereum Signed Message:\n15I am authentic!"
h = Util.keccak256 p
# => "p\xFB\xC5w\xC8\xE0zo\xD0!r%\xD8\x7Fc\x8B~\xD2n/R\x12\x93\x1DI\xD3$\xDA\a\xF3\x1D\xF2"
s = Util.hex_to_bin "2166d149f4cddd5cf0e8f165366322a3fce0d05e82269371477199f12160c72c0de17dea759a80e# 2c40334903a2ec5b7d53ba47e0eb9d8dd996a921e811a58a61c"
=> "!f\xD1I\xF4\xCD\xDD\\\xF0\xE8\xF1e6c\"\xA3\xFC\xE0\xD0^\x82&\x93qGq\x99\xF1!`\xC7,\r\xE1}\xEAu\x9A\x80\xE2\xC4\x034\x90:.\xC5\xB7\xD5;\xA4~\x0E\xB9\xD8\xDD\x99j\x92\x1E\x81\x1AX\xA6\x1C"
_ = g.deploy_and_wait(c)
# => "0x967ce372d0f30ba9d466d1b047b0362f82e29ab9"
g.is_valid_signature c, h, s
# => true

@q9f q9f changed the title lib: module for eip-1271 lib: method for eip-1271 May 6, 2022
@q9f q9f marked this pull request as ready for review May 6, 2022 15:09
@codecov-commenter
Copy link

codecov-commenter commented May 6, 2022

Codecov Report

Merging #80 (3205de0) into main (07befbe) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main      #80   +/-   ##
=======================================
  Coverage   99.73%   99.73%           
=======================================
  Files          67       67           
  Lines        3754     3780   +26     
=======================================
+ Hits         3744     3770   +26     
  Misses         10       10           
Impacted Files Coverage Δ
lib/eth/client.rb 100.00% <100.00%> (ø)
spec/eth/client_spec.rb 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

Copy link
Collaborator

@kurotaky kurotaky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great !

@q9f q9f merged commit d973b5b into main May 10, 2022
@q9f q9f deleted the q9f/contracts/1271 branch May 10, 2022 10:50
@q9f q9f added the enhancement New feature or request label May 13, 2022
mculp pushed a commit to mculp/eth.rb that referenced this pull request Aug 1, 2022
* spec: add signer contract for eip-1271

* eth/client: implement is_valid_signature

* eth/client: document is_valid_signature

* docs: update readme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Eip 1271 support
3 participants