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

Support signing with json exported from polkadot.js #1631

Closed
ethernomad opened this issue Jun 9, 2024 · 4 comments
Closed

Support signing with json exported from polkadot.js #1631

ethernomad opened this issue Jun 9, 2024 · 4 comments

Comments

@ethernomad
Copy link
Contributor

Accounts managed by https://polkadot.js.org/apps/ or the browser extension can be downloaded as an encrypted json file, for example:

{
  "encoded": "",
  "encoding": {
    "content": [
      "pkcs8",
      "sr25519"
    ],
    "type": [
      "scrypt",
      "xsalsa20-poly1305"
    ],
    "version": "3"
  },
  "address": "5DV3QBwhs7djHop5WEcUQ1BMFSmsqvqnDhrYh343x495AL4v",
  "meta": {
    "genesisHash": "",
    "name": "",
    "whenCreated": 1639212245729
  }
}

I'm not sure what the name of this format is.

It would be useful for subxt_signer to be able to load a keypair from a json file and the correct password.

I can implement a pull request for this.

@jsdw
Copy link
Collaborator

jsdw commented Jun 12, 2024

I suspect it's a semi arbitrary format that the PJS extension invented and that one or two other wallets then decided to allow import of.

Is it worth being able to do this programmatically eg via some utility function in Subxt signer I wonder? Or would it make more sense to have a binary that can spit out the relevant details to be passed to subxt-signer? (Can subkey do this already I wonder? https://docs.substrate.io/reference/command-line-tools/subkey/)

@ethernomad
Copy link
Contributor Author

I have a use case where a program needs to have an encrypted key on disk that can be decrypted interactively. This json file format seems ideal because an account can be created / exported with ease from the browser extension.

I've almost finished implementing a from_json() method in subxt_signer::sr25519::Keypair

@jsdw
Copy link
Collaborator

jsdw commented Jun 12, 2024

I've almost finished implementing a from_json() method in subxt_signer::sr25519::Keypair

Ok awesome, would be good to see! I imagine it needs additional dependencies so we may want to have this behind a feature flag. I'm also currently wondering whether it should be attached to a specific algorithm (eg sr25519) or be a standalone utility function which takes the JSon and gives back the private key or whatever, but let's see what you come up with!

@niklasad1
Copy link
Member

Closed by #1661

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

No branches or pull requests

3 participants