本文整理汇总了TypeScript中bcrypto.secp256k1.privateKeyVerify方法的典型用法代码示例。如果您正苦于以下问题:TypeScript secp256k1.privateKeyVerify方法的具体用法?TypeScript secp256k1.privateKeyVerify怎么用?TypeScript secp256k1.privateKeyVerify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bcrypto.secp256k1
的用法示例。
在下文中一共展示了secp256k1.privateKeyVerify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: importWallet
/**
* import an account wallet from server using a private key
* @param {string} privateKey - the private key of the account being imported
* @returns {Promise} Promise object containing boolean - if imported successfully or not
*/
importWallet(privateKey): Promise<any> {
this.startLoading()
var deferred = new $.Deferred()
if (!!(privateKey.match(/[0-9a-fA-F]{64}/)) == false) {
deferred.reject({
error: 'Invalid private key.'
})
return deferred.promise()
}
if (typeof(privateKey) == 'string') privateKey = new Buffer(privateKey, 'hex')
// check if private key valid
try {
if (secp256k1.privateKeyVerify(privateKey)) {
let addr = this.getAddressFromPrivateKey(privateKey)
// get balance from API
let that = this
this.node.getBalance({address: addr}, function(err, data) {
if (err || data.error) {
deferred.reject({error: err})
} else {
that.userWallet = {
address: addr,
balance: data.result.balance,
nonce: data.result.nonce,
privateKey: privateKey.toString('hex')
}
deferred.resolve({
result: true
})
}
that.endLoading()
})
} else {
deferred.reject({
error: 'Invalid private key.'
})
this.endLoading()
}
} catch (e) {
deferred.reject({
error: e
})
this.endLoading()
}
return deferred.promise()
}