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

Move loadKey to ara-util #55

Open
vipyne opened this issue Dec 10, 2018 · 0 comments
Open

Move loadKey to ara-util #55

vipyne opened this issue Dec 10, 2018 · 0 comments
Labels
enhancement New feature or request

Comments

@vipyne
Copy link
Contributor

vipyne commented Dec 10, 2018

  async loadKey() {
    if (!this.did || !this.password) {
      throw new Error('Missing ara identity or password')
    }

    let keystore
    let password
    try {
      const publicKey = Buffer.from(this.did, 'hex')
      const hash = crypto.blake2b(publicKey).toString('hex')
      const path = resolve(rc.network.identity.root, hash, 'keystore/ara')
      keystore = JSON.parse(await pify(readFile)(path, 'utf8'))
      password = crypto.blake2b(Buffer.from(this.password))
    } catch (err) {
      throw new Error('Failed to load keystore')
    }

    try {
      this.secretKey = ss.decrypt(keystore, { key: password.slice(0, 16) })
    } catch (err) {
      debug(err)
      throw new Error('Password failed to decrypt key')
    }
  }

from https://github.com/AraBlocks/ara-reward-dcdn/blob/master/src/user.js to https://github.com/AraBlocks/ara-util/blob/master/keyring.js

see comment in #50

Specifications

  • Version: 0.8.0
  • Platform:
  • Subsystem:
@vipyne vipyne added the enhancement New feature or request label Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant