rename seckey to prikey
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import ticrypto from 'tic-crypto'
|
||||
import { TIC } from '../tic'
|
||||
|
||||
export const seckey2pubkey = seckey => ticrypto.seckey2pubkey(seckey)
|
||||
export const seckey2pubkey = prikey => ticrypto.seckey2pubkey(prikey)
|
||||
export const secword2address = secword => ticrypto.secword2address(secword)
|
||||
export const secword2account = secword => ticrypto.secword2account(secword)
|
||||
// export const randomSecword = lang => ticrypto.randomSecword(lang)
|
||||
|
||||
@@ -4,10 +4,10 @@ import * as worker from 'workerize-loader!./tic-bg'
|
||||
const instance = worker()
|
||||
|
||||
export default {
|
||||
seckey2pubkey: seckey => instance.seckey2pubkey(seckey),
|
||||
seckey2pubkey: prikey => instance.seckey2pubkey(prikey),
|
||||
secword2address: secword => instance.secword2address(secword),
|
||||
isAddress: address => instance.isAddress(address),
|
||||
secword2account: secword => instance.secword2account(secword),
|
||||
// randomSecword: async lang => instance.randomSecword(lang),
|
||||
transferTic: params => instance.transferTic(params),
|
||||
transferTic: params => instance.transferTic(params)
|
||||
}
|
||||
|
||||
@@ -7,22 +7,22 @@ const TicActionTransfer = ticAction.ActionTransfer
|
||||
const TIC_TXFEE = 10
|
||||
|
||||
export class TIC {
|
||||
constructor (seckey, option = {}) {
|
||||
if (!seckey || !Ticrypto.isSeckey(seckey))
|
||||
constructor (prikey, option = {}) {
|
||||
if (!prikey || !Ticrypto.isSeckey(prikey))
|
||||
throw Error('ERROR:Invalid Seckey')
|
||||
Object.defineProperties(this, {
|
||||
seckey: {
|
||||
value: seckey,
|
||||
prikey: {
|
||||
value: prikey,
|
||||
enumerable: true,
|
||||
writable: false
|
||||
},
|
||||
pubkey: {
|
||||
value: Ticrypto.seckey2pubkey(seckey),
|
||||
value: Ticrypto.seckey2pubkey(prikey),
|
||||
enumerable: true,
|
||||
writable: false
|
||||
},
|
||||
address: {
|
||||
value: Ticrypto.pubkey2address(Ticrypto.seckey2pubkey(seckey)),
|
||||
value: Ticrypto.pubkey2address(Ticrypto.seckey2pubkey(prikey)),
|
||||
enumerable: true,
|
||||
writable: false
|
||||
}
|
||||
@@ -40,14 +40,14 @@ export class TIC {
|
||||
|
||||
static generateNewAccount () {
|
||||
var secword = Ticrypto.randomSecword()
|
||||
return Object.assign(new TIC(Ticrypto.secword2keypair(secword).seckey), {
|
||||
return Object.assign(new TIC(Ticrypto.secword2keypair(secword).prikey), {
|
||||
secword: secword
|
||||
})
|
||||
}
|
||||
static fromMnemonic (secword) {
|
||||
if (!secword || !Ticrypto.isSecword(secword))
|
||||
throw Error('ERROR:Invalid Secword')
|
||||
return new TIC(Ticrypto.secword2keypair(secword).seckey)
|
||||
return new TIC(Ticrypto.secword2keypair(secword).prikey)
|
||||
}
|
||||
static async getBalance (address) {
|
||||
if (!address) {
|
||||
@@ -108,7 +108,7 @@ export class TIC {
|
||||
})
|
||||
// 对交易数据签名,packMe 内的参数是交易发起人的keypair
|
||||
action.packMe({
|
||||
seckey: this.seckey,
|
||||
prikey: this.prikey,
|
||||
pubkey: this.pubkey,
|
||||
address: this.address
|
||||
})
|
||||
@@ -140,18 +140,18 @@ export class TIC {
|
||||
})
|
||||
// sign for txBody use function packMe, which needs actor's keypair as parameter
|
||||
action.packMe({
|
||||
seckey: this.seckey,
|
||||
prikey: this.prikey,
|
||||
pubkey: this.pubkey,
|
||||
address: this.address
|
||||
})
|
||||
return action
|
||||
}
|
||||
// default key for sign&encrypt is account's seckey,other keys are optional.
|
||||
sign (message, key = this.seckey) {
|
||||
// default key for sign&encrypt is account's prikey,other keys are optional.
|
||||
sign (message, key = this.prikey) {
|
||||
return Ticrypto.sign(message, key)
|
||||
}
|
||||
verify (message, signature) {
|
||||
return Ticrypto.sign(message, signature, this.seckey)
|
||||
return Ticrypto.sign(message, signature, this.prikey)
|
||||
}
|
||||
encrypt (key) {
|
||||
return TIC.encrypt(this, key)
|
||||
|
||||
Reference in New Issue
Block a user