vue-tronlink
Version:
Vue support for the TronLink browser extension
26 lines (22 loc) • 657 B
JavaScript
import {byteArray2hexStr} from './bytes';
import {
getBase58CheckAddress,
genPriKey,
getAddressFromPriKey,
getPubKeyFromPriKey
} from './crypto';
export function generateAccount() {
const priKeyBytes = genPriKey();
const pubKeyBytes = getPubKeyFromPriKey(priKeyBytes);
const addressBytes = getAddressFromPriKey(priKeyBytes);
const privateKey = byteArray2hexStr(priKeyBytes);
const publicKey = byteArray2hexStr(pubKeyBytes);
return {
privateKey,
publicKey,
address: {
base58: getBase58CheckAddress(addressBytes),
hex: byteArray2hexStr(addressBytes)
}
}
}