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

Ethereum signature verification #169

Closed
wants to merge 17 commits into from
Closed

Ethereum signature verification #169

wants to merge 17 commits into from

Conversation

yusefnapora
Copy link
Contributor

@yusefnapora yusefnapora commented Jan 18, 2017

This is branched off of #168, and depends on my fork of js-libp2p-crypto until we can get that merged in.

Adds support for verifying messages signed by ethereum nodes, in the form of a verifyEthereum method on the PublicSigningKey class. If the PublicSigningKey's underlying key is a libp2p Secp256k1PublicKey, and the signature length is the expected 65 bytes produced by geth, we call through to verifyEthereum from the main verify method.

We can load an ethereum public key from either a marshaled libp2p-crypto PublicKey protobuf, or a Buffer containing either a standard SEC1 public key (compressed or uncompressed), or ethereum's predictably non-standard variant, where they chop off the leading byte of the uncompressed key (wtf dude).

We can also recover the public key from the combination of a message, the signature produced by an ethereum node, and that node's address. If the recovered key matches the address, we use it, otherwise throw an error.

TODO:

  • finish the libp2p-crypto work and get it merge in
  • test statement signing / verification

`${CONCAT_PUBLISHER_ID_PUB58}.privateKey`)
const CONCAT_MESSAGE_FIXTURES = require('./resources/fixtures/concat-message-signature')
const ETH_MESSAGE_FIXTURES = require('./resources/fixtures/ethereum-message-signature')

describe('Signature verification', () => {
let publisherId

Copy link
Contributor

Choose a reason for hiding this comment

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

should add deterministic signature checking here as well, by analogy to my branch

@yusefnapora
Copy link
Contributor Author

last couple of commits add support for using the web3.eth.sign method to create an EthereumPublisherId, using the RPC call as a stand-in for a private key. Basically we sign a message, recover the public key & compare to the expected ethereum address, then get the publisher.id58 string and use the RPC call to sign statements. Lots of duct tape, but it works 😄

Also, I had to add dependencies to lots of forks - the libp2p stuff and ethereumjs-utils; hopefully we can clean this up soon

@vyzo
Copy link
Contributor

vyzo commented Jan 24, 2017

Perhaps rename the publisher .id files to something that github will recognize as binary so that they don't pollute the diff?

@parkan
Copy link
Contributor

parkan commented Feb 10, 2017

shrinkwrap 😡

@yusefnapora yusefnapora changed the title WIP - ethereum signature verification Ethereum signature verification Feb 10, 2017
@yusefnapora
Copy link
Contributor Author

btw, the libp2p guys are tweaking the secp module loading stuff a bit (libp2p/js-libp2p-crypto#74). The changes are all good, but we'll need to update a few things here once they land. We should either wait a bit to merge this, or pin the version in package.json. Shrinkwrap will technically pin it for us, but I don't really want to lean on that.

@parkan
Copy link
Contributor

parkan commented Feb 13, 2017

Upstream changes lgtm but let's cut a release w/o waiting for them anyway

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 this pull request may close these issues.

None yet

3 participants