随着 tic.crypto 升级到 secp256k1 的公私钥和签名,把 signMe, packMe, verifySig 改成 async 的

This commit is contained in:
Luk Lu
2020-02-20 18:53:00 +08:00
parent 4e2a4b35db
commit c9f04b24eb
2 changed files with 18 additions and 18 deletions

View File

@@ -13,15 +13,15 @@ const MOM = DAD.prototype
MOM.__proto__ = Action.prototype
// MOM._table=DAD.name // 注释掉从而继承父类Action的数据库表格名
MOM.signMe = function (seckey) { // 由前端调用,后台不该进行签名
MOM.signMe = async function (seckey) { // 由前端调用,后台不该进行签名
let json = this.getJson({ exclude: ['hash', 'blockHash', 'actorSignature', 'json'] }) // 是前端用户发起事务时签字这时候还不知道进入哪个区块所以不能计入blockHash
this.actorSignature = wo.Crypto.sign(json, seckey)
this.actorSignature = await wo.Crypto.sign(json, seckey)
return this
}
MOM.verifySig = function () {
MOM.verifySig = async function () {
let json = this.getJson(({ exclude: ['hash', 'blockHash', 'actorSignature', 'json'] }))
let res = wo.Crypto.verify(json, this.actorSignature, this.actorPubkey)
let res = await wo.Crypto.verify(json, this.actorSignature, this.actorPubkey)
return res
}
@@ -38,12 +38,12 @@ MOM.verifyHash = function () {
return this.hash === wo.Crypto.hash(this.getJson({ exclude: ['hash', 'blockHash', 'json'] }))
}
MOM.packMe = function (keypair) { // 由前端调用,后台不创建
MOM.packMe = async function (keypair) { // 由前端调用,后台不创建
this.actorPubkey = keypair.pubkey
this.actorAddress = wo.Crypto.pubkey2address(keypair.pubkey)
this.timestamp = new Date()
this.signMe(keypair.seckey)
await this.signMe(keypair.seckey)
this.hashMe()
return this
}
@@ -59,7 +59,7 @@ MOM.checkMultiSig = function (account) {
}
for (let i of sigers) // 该交易内已签名的每一个公钥
{
if (account.multiSignatures.keysgroup.indexOf(i) !== -1 && wo.Crypto.verify(json, this.json[i], i)) {
if (account.multiSignatures.keysgroup.indexOf(i) !== -1 && await wo.Crypto.verify(json, this.json[i], i)) {
M++
}
}