Skip to content

valar999/bitgo-sign

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BitGo Sign Transaction example

This example shows how to sign a transaction with your private key.

hash, signature, err := SignTx(key, address, amountStr, expire, seqId)

Params:

  • key - ECDSA private key in hex. See below
  • address - recipient address in 0x1234... format
  • amountStr - transaction amount, as integer
  • expire - timestamp when transaction should expire, see BigGo documentation
  • seqId - internal transaction sequence number, received from tx/build

Result:

  • hash - operationHash, hash of recipient, amount, expire and seqId
  • signature - signature of hash with the key

Key

BitGo gives a key for Ethereum in "wallet" format. It is encrypted with password and looks like this:

{"iv":"XJSKS29eLUoF5FDCdg2g2Q==","v":1,"iter":10000,"ks":256,"ts":64,"mode"
:"ccm","adata":"","cipher":"aes","salt":"m2F+tC4jtTs=","ct":"XXfuUJD4XOvQTz
x0tJGye3T7TtNbiqFTwaLBNInukGdEoXeLZSpIcWWfhLg6LVmTdwz3tk41aqW9fbX2zh8/l/B1h
zXngBVf4QWM5Q2ZQHswva6LBhBzpGGcy6auRVDyxNcXm59db/oHUvw+59pdV2ZKpwogRh0="}

First we need to convert it to "xprv" format. We can do it with following JS code:

import { BitGoAPI } from '@bitgo/sdk-api';

const bitgo = new BitGoAPI({});

const key = '{"iv":"XJSKS29eLUoF5FDCdg2g2Q==","v":1,...';
const password = "secret-password";

const prv = bitgo.decrypt({ input: key, password });

Second, convert "xprv" to "raw" key

const { bip32 } = require('@bitgo/utxo-lib');
const ethUtil = require('ethereumjs-util');

const xprv = "xprv9s...";
const node = bip32.fromBase58(xprv);
const key = node.privateKey.toString('hex');

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages