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

API call to sign arbitrary data #118

Conversation

WhoSoup
Copy link
Member

@WhoSoup WhoSoup commented Oct 8, 2019

There is currently no way to sign arbitrary data without retrieving a private key over the network, which is fundamentally a bad idea. Currently both FAT and PegNet sign their custom transaction entries by querying the private key of an address over the api, then signing locally.

This would add a "sign-data" method to the wallet that takes an FA address and arbitrary byte data as parameters:

type signDataRequest struct {
Address string `json:"address"`
Data []byte `json:"data"`
}

and returns a public key + signature pair:

type signDataResponse struct {
PubKey []byte `json:"pubkey"`
Signature []byte `json:"signature"`
}

The downside here is that you have to transfer the data to the wallet in order to sign it but with the advantage of never having to retrieve the private key over a potentially unsecure connection. If you need to sign a lot of data, you can still use the alternate method or just sign a hash of the data instead.

I think this would make the ecosystem a lot safer and the wallet a lot more useful for layer 2 applications.

The PR also includes a corresponding factom go client function to call this API endpoint:

factom/sign.go

Lines 7 to 12 in 5c3c980

type Signature struct {
PubKey []byte `json:"pubkey"`
Signature []byte `json:"signature"`
}
func SignData(addr string, data []byte) (*Signature, error) {

Copy link
Contributor

@sambarnes sambarnes left a comment

Choose a reason for hiding this comment

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

One question on making the command more general purpose for keys of any type. Other than that, code looks healthy to me and a very much needed addition.

sign.go Outdated Show resolved Hide resolved
@WhoSoup
Copy link
Member Author

WhoSoup commented Oct 8, 2019

alright, i renamed Address to Signer and you can now sign using FA address, EC address, or Identity key

Copy link
Contributor

@sambarnes sambarnes left a comment

Choose a reason for hiding this comment

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

Awesome, LGTM

@sambarnes sambarnes changed the base branch from develop to FD-1213_WalletdSignDataRPC October 8, 2019 15:40
@sambarnes sambarnes merged commit f81641a into FactomProject:FD-1213_WalletdSignDataRPC Oct 8, 2019
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.

2 participants