How to use the trezor-connect.getPublicKey function in trezor-connect

To help you get started, we’ve selected a few trezor-connect 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 Mrtenz / FindETH / src / wallets / Trezor.ts View on Github external
protected async getKeyInfo(path: DerivationPath): Promise {
    if (this.cache[path.prefix]) {
      return this.cache[path.prefix];
    }

    const response = await TrezorConnect.getPublicKey({ path: path.prefix });

    return {
      publicKey: response.payload.publicKey,
      chainCode: response.payload.chainCode
    };
  }
github urbit / bridge / src / views / Login / Trezor.js View on Github external
async values => {
      TrezorConnect.manifest({
        email: 'bridge-trezor@urbit.org',
        appUrl: 'https://github.com/urbit/bridge',
      });

      const { success, payload } = await TrezorConnect.getPublicKey({
        path: values.hdPath,
      });

      if (!success) {
        return { [FORM_ERROR]: 'Failed to authenticate with your Trezor.' };
      }

      const publicKey = Buffer.from(payload.publicKey, 'hex');
      const chainCode = Buffer.from(payload.chainCode, 'hex');
      const pub = secp256k1.publicKeyConvert(publicKey, true);
      const hd = bip32.fromPublicKey(pub, chainCode);

      setWallet(Just(hd));
      setWalletHdPath(values.hdPath);
    },
    [setWallet, setWalletHdPath]
github Mrtenz / FindETH / packages / web / src / wallets / Trezor.ts View on Github external
protected async getKeyInfo(path: DerivationPath): Promise {
    if (this.cache[path.prefix]) {
      return this.cache[path.prefix];
    }

    const response = await TrezorConnect.getPublicKey({ path: path.prefix });

    return {
      publicKey: response.payload.publicKey,
      chainCode: response.payload.chainCode
    };
  }
github Mrtenz / FindETH / packages / web / src / wallets / Trezor.ts View on Github external
public async prefetch(paths: DerivationPath[]): Promise<{ [key: string]: KeyInfo }> {
    const bundle = paths.filter(path => !path.isHardened).map(path => ({ path: path.prefix }));

    const response = await TrezorConnect.getPublicKey({ bundle });

    for (const { serializedPath, chainCode, publicKey } of response.payload) {
      this.cache[serializedPath] = { chainCode, publicKey };
    }

    return this.cache;
  }
github Mrtenz / FindETH / src / wallets / Trezor.ts View on Github external
public async prefetch(paths: DerivationPath[]): Promise<{ [key: string]: KeyInfo }> {
    const bundle = paths.filter(path => !path.isHardened).map(path => ({ path: path.prefix }));

    const response = await TrezorConnect.getPublicKey({ bundle });

    for (const { serializedPath, chainCode, publicKey } of response.payload) {
      this.cache[serializedPath] = { chainCode, publicKey };
    }

    return this.cache;
  }
github MyCryptoHQ / MyCrypto / common / v2 / services / WalletService / deterministic / trezor.ts View on Github external
return new Promise(resolve => {
      TrezorConnect.getPublicKey({
        path: dpath
      }).then((res: any) => {
        if (res.success) {
          resolve({
            publicKey: res.payload.publicKey,
            chainCode: res.payload.chainCode
          });
        } else {
          throw new Error(res.error);
        }
      });
    });
  }
github urbit / bridge / src / views / Trezor.js View on Github external
async pollDevice() {
    const { setWallet, setWalletHdPath } = this.props;
    const { hdpath } = this.state;

    TrezorConnect.manifest({
      email: 'bridge-trezor@urbit.org',
      appUrl: 'https://github.com/urbit/bridge',
    });
    TrezorConnect.getPublicKey({ path: hdpath }).then(info => {
      if (info.success === true) {
        const payload = info.payload;
        const publicKey = Buffer.from(payload.publicKey, 'hex');
        const chainCode = Buffer.from(payload.chainCode, 'hex');
        const pub = secp256k1.publicKeyConvert(publicKey, true);
        const hd = bip32.fromPublicKey(pub, chainCode);
        setWallet(Maybe.Just(hd));
        setWalletHdPath(hdpath);
      } else {
        setWallet(Maybe.Nothing());
      }
    });
  }