How to use the @ethersproject/hdnode.HDNode.fromSeed function in @ethersproject/hdnode

To help you get started, we’ve selected a few @ethersproject/hdnode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 3box / 3box-js / src / 3id / keyring.js View on Github external
constructor (seed) {
    this._seed = seed
    const seedNode = HDNode.fromSeed(this._seed)
    const baseNode = seedNode.derivePath(BASE_PATH)

    this.signingKey = baseNode.derivePath("0")
    const tmpEncKey = Buffer.from(baseNode.derivePath("2").privateKey.slice(2), 'hex')
    this.asymEncryptionKey = nacl.box.keyPair.fromSecretKey(new Uint8Array(tmpEncKey))
    this.symEncryptionKey = new Uint8Array(Buffer.from(baseNode.derivePath("3").privateKey.slice(2), 'hex'))

    this.ethereumKey = seedNode.derivePath(MM_PATH).derivePath("0")
  }
github 3box / identity-wallet-js / src / keyring.js View on Github external
static encryptWithAuthSecret (message, authSecret) {
    const node = HDNode.fromSeed(ensure0x(authSecret)).derivePath(AUTH_PATH_ENCRYPTION)
    const key = Keyring.hexToUint8Array(node.privateKey.slice(2))
    return Keyring.symEncryptBase(message, key)
  }
github 3box / identity-wallet-js / src / keyring.js View on Github external
static walletForAuthSecret (authSecret) {
    const node = HDNode.fromSeed(ensure0x(authSecret)).derivePath(AUTH_PATH_WALLET)
    return new Wallet(node.privateKey)
  }
github 3box / identity-wallet-js / src / keyring.js View on Github external
constructor (seed) {
    this._seed = seed
    this._baseNode = HDNode.fromSeed(this._seed).derivePath(BASE_PATH)
    const rootNode = this._baseNode.derivePath(ROOT_STORE_PATH)
    this._rootKeys = {
      signingKey: rootNode.derivePath('0'),
      managementKey: rootNode.derivePath('1'),
      asymEncryptionKey: nacl.box.keyPair.fromSecretKey(new Uint8Array(
        Buffer.from(rootNode.derivePath('2').privateKey.slice(2), 'hex')
      )),
      symEncryptionKey: Keyring.hexToUint8Array(rootNode.derivePath('3').privateKey.slice(2))
    }
    this._spaceKeys = {}
  }
github 3box / identity-wallet-js / src / keyring.js View on Github external
static decryptWithAuthSecret (ciphertext, nonce, authSecret) {
    const node = HDNode.fromSeed(ensure0x(authSecret)).derivePath(AUTH_PATH_ENCRYPTION)
    const key = Keyring.hexToUint8Array(node.privateKey.slice(2))
    return Keyring.symDecryptBase(ciphertext, key, nonce)
  }