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

Infer key type from public key and private key bytes #403

Closed
10 tasks
robdefeo opened this issue Nov 19, 2019 · 3 comments
Closed
10 tasks

Infer key type from public key and private key bytes #403

robdefeo opened this issue Nov 19, 2019 · 3 comments

Comments

@robdefeo
Copy link
Member

Is your feature request related to a problem? Please describe.
Mailchain requires private keys to, decrypt and sign transactions. To add a private key to mailchain the used needs to include the private key and key type. It is not expected that users understand what key type they have.
While ethereum and other protocols support a single key type, substrate supports, ed25519, sr25519, and secp256k1.

Describe the solution you'd like
Create a method that can determine the key type from the public and private key bytes combination.

  • create method in crypto/multikey
  • method signature GetKeyKindFromBytes(publicKey []byte, privateKey []byte) (crypto.PrivateKey, error)
  • check each key type to see if the private and public keys match
    • create PrivateKey from []byte
    • compare output of .Bytes() to publicKey []byte
  • check all candidate key types
  • if a single match return crypto.PrivateKey for the matching key type
  • use "github.com/mailchain/mailchain/crypto" package
  • no match return error
  • multiple match return inconsistent/inconclusive error

Additional context
More key types will be added in the future

@asnimansari
Copy link

Shall I do this ?

@robdefeo robdefeo added this to To do in protocol/substrate via automation Dec 31, 2019
@olimpias
Copy link
Contributor

Hi @robdefeo, could you assign the task to me? Thanks!

@robdefeo
Copy link
Member Author

robdefeo commented Feb 3, 2020

closed by #535

@robdefeo robdefeo closed this as completed Feb 3, 2020
protocol/substrate automation moved this from To do to Done Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

3 participants