Socket
Book a DemoInstallSign in
Socket

@ont-dev/hw-app-ont

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ont-dev/hw-app-ont

Ledger Javascript API for ONT and NEO.

Source
npmnpm
Version
1.0.2
Version published
Maintainers
2
Created
Source

Ledger javascript API for ONT and NEO

Usage

import Transport from "@ledgerhq/hw-transport-node-hid";
import App from "@ont-dev/hw-app-ont";
import * as elliptic from 'elliptic';
import { Crypto, Transaction } from 'ontology-ts-sdk';

(async function run() {
  const ledgerPath = "44'/1024'/0'/0/0";
  const transactionHex = '0123456789abcdef....';

  const transport = await Transport.create();
  transport.setExchangeTimeout(15000);
  const app = new App(transport);

  const uncompressedPublicKey = await app.getPublicKey(ledgerPath);
  console.log(uncompressedPublicKey);
  const ec = new elliptic.ec(Crypto.CurveLabel.SECP256R1.preset);
  const keyPair = ec.keyFromPublic(uncompressedPublicKey, 'hex');
  const compressedPublicKey = keyPair.getPublic(true, 'hex');
  console.log(compressedPublicKey);
  const ontPublicKey = new Crypto.PublicKey(compressedPublicKey);
  const ontAddress = Crypto.Address.fromPubKey(ontPublicKey);
  const addressBase58 = ontAddress.toBase58();
  console.log(addressBase58);

  const ontTransaction = Transaction.deserialize(transactionHex);
  const unsignedData = ontTransaction.serializeUnsignedData();
  const result = await this.app.signMessage(ledgerPath, unsignedData);
  const ontSignature = new Crypto.Signature(Crypto.SignatureScheme.ECDSAwithSHA256, result);
  const signatureHex = ontSignature.serializeHex();
  console.log(signatureHex);
})();

Keywords

Ledger

FAQs

Package last updated on 23 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts