Skip to content

Conversation

@holiman
Copy link
Contributor

@holiman holiman commented Nov 11, 2018

This PR is still a bit of a WIP, but I think it can be a good first step. It implements an additional backend for the account manager. The backend integrates with clef, and invokes an external signer for operations.
It currently can sign only transactions, for more advanced usages, such as signing Clique headers and/or data, we'll wait for the PR from @PaulRBerg to get implemented into clef.

Also some other things are missing, and could be added later on:

  • enable some user-friendly mechanism to allow both local and external accounts, without too much confusion
  • Implement signing of things other than transactions
  • Implement ipc integration, not only http

I'm not sure if the current scheme for Accounts.URL is the best, not quite sure how it is intended (e..g, should we have wallet URL be the same as the Backend URL? -- and should we really expose the plain backend URL or use some indirection, such as a hash or the remote url? )

@holiman holiman requested a review from karalabe as a code owner November 11, 2018 12:44
@holiman holiman changed the title External signer API External signer API (WIP) Nov 11, 2018
@holiman holiman added the clef label Nov 11, 2018
@holiman holiman changed the title External signer API (WIP) External signer API (first iteration) Nov 23, 2018
Copy link
Member

Choose a reason for hiding this comment

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

I think this s slipped in by accident

@holiman
Copy link
Contributor Author

holiman commented Nov 29, 2018

Formatted, rebased

@holiman
Copy link
Contributor Author

holiman commented Dec 3, 2018

Formatted, conflicts fixed, rebased

@fjl
Copy link
Contributor

fjl commented Dec 4, 2018

As promised, here's my critique of SignCliqueHeader:

I think this method is too specific. Code in accounts/ shouldn't know about clique and other use cases that require custom display/rule logic will come up later. I propose you add the following method instead of SignCliqueHeader:

// SignData signs hashfunc(data). The only supported hash function
// is "keccak256". The mimetype paremeter
// describes the type of data being signed.
SignData(mimetype, hashfunc string, data []byte) (sig []byte, err error)

This method can be supported by all account management backends including clef. If a backend wants to present the signed data to the user in a custom way, it can do so by looking at the mime type. For other backends such as the keystore, the mime type serves no particular purpose and is discarded.

Using this method, the clique code would sign headers by calling SignData("application/x-clique-header", "keccak256", encodeHeader(h)) where encodeHeader performs RLP encoding of the header like CliqueHash does.

When a clique header is being signed through clef, the frontend would parse the RLP header and display it accordingly. The same processing may happen in rule scripts. The rule script engine would need to be extended to know about the mime type of the data being signed so it can decode it.

@holiman
Copy link
Contributor Author

holiman commented Dec 6, 2018

Ok I have now addressed your concern @fjl , except I didn't see any point in having a hashfunc string.

@holiman
Copy link
Contributor Author

holiman commented Dec 7, 2018

formatted. ptal @fjl

@holiman
Copy link
Contributor Author

holiman commented Dec 7, 2018

Since I've been messing about with the clique signing, let's not merge this until after the monday release. When we merge it, I want to try it out on the rinkeby signer before it makes it into a release.

@holiman
Copy link
Contributor Author

holiman commented Jan 8, 2019

Rebased, ptal @fjl

Copy link
Contributor

@fjl fjl left a comment

Choose a reason for hiding this comment

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

The integration looks very clean now. I think the hash function parameter is required though. Clef should not allow feeding arbitrary data into the signature calculation because it might enable attacks on signature math, leading to key extraction. It is much safer to perform hashing on the clef side.

// Note, the method requires the extra data to be at least 65 bytes, otherwise it
// panics. This is done to avoid accidentally using both forms (signature present
// or not), which could be abused to produce different hashes for the same header.
func CliqueHash(header *types.Header) (hash common.Hash) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm honestly not sure right now. I'll take a look if it can be removed

@holiman
Copy link
Contributor Author

holiman commented Feb 4, 2019

Clef should not allow feeding arbitrary data into the signature calculation because it might enable attacks on signature math, leading to key extraction. It is much safer to perform hashing on the clef side.

I'm not sure what you are referring to. Clef doesn't allow arbitrary data being signed anywhere...?

@fjl fjl added this to the 1.9.0 milestone Feb 4, 2019
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 24, 2025
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Jan 24, 2025
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.

3 participants