rename ticc.sign/verify/encrypt/decrypt/hash to ticc.xxx_easy

This commit is contained in:
陆柯 2022-07-23 16:03:24 +08:00
parent f70b97cbb2
commit 8cf67bf90c
3 changed files with 19 additions and 10 deletions

View File

@ -52,18 +52,22 @@ MOM.packMe = async function (keypair) {
MOM.signMe = async function (seckey) { MOM.signMe = async function (seckey) {
// 由前端调用,后台不该进行签名 // 由前端调用,后台不该进行签名
let json = this.getJson({ exclude: ['hash', 'blockHash', 'actorSignature'] }) // 是前端用户发起事务时签字这时候还不知道进入哪个区块所以不能计入blockHash let json = this.getJson({ exclude: ['hash', 'blockHash', 'actorSignature'] }) // 是前端用户发起事务时签字这时候还不知道进入哪个区块所以不能计入blockHash
this.actorSignature = await ticc.sign(json, seckey) this.actorSignature = await ticc.sign_easy({ data: json, seckey })
return this return this
} }
MOM.hashMe = function () { MOM.hashMe = function () {
this.hash = ticc.hash(this.getJson({ exclude: ['hash', 'blockHash'] })) // block.hash 受到所包含的actionList影响所以action不能受blockHash影响否则循环了 this.hash = ticc.hash_easy(this.getJson({ exclude: ['hash', 'blockHash'] })) // block.hash 受到所包含的actionList影响所以action不能受blockHash影响否则循环了
return this return this
} }
MOM.verifySig = async function () { MOM.verifySig = async function () {
let json = this.getJson({ exclude: ['hash', 'blockHash', 'actorSignature'] }) let json = this.getJson({ exclude: ['hash', 'blockHash', 'actorSignature'] })
let result = await ticc.verify(json, this.actorSignature, this.actorPubkey) let result = await ticc.verify_easy({
data: json,
signature: this.actorSignature,
pubkey: this.actorPubkey
})
return result return result
} }
DAD.verifySig = async function (actionData) { DAD.verifySig = async function (actionData) {
@ -83,7 +87,8 @@ DAD.verifyAddress = function (actionData) {
MOM.verifyHash = function () { MOM.verifyHash = function () {
return ( return (
this.hash === ticc.hash(this.getJson({ exclude: ['hash', 'blockHash'] })) this.hash ===
ticc.hash_easy(this.getJson({ exclude: ['hash', 'blockHash'] }))
) )
} }
DAD.verifyHash = function (actionData) { DAD.verifyHash = function (actionData) {

View File

@ -19,7 +19,7 @@ MOM.signMe = async function (seckey) {
let json = this.getJson({ let json = this.getJson({
exclude: ['hash', 'blockHash', 'actorSignature', 'json'] exclude: ['hash', 'blockHash', 'actorSignature', 'json']
}) // 是前端用户发起事务时签字这时候还不知道进入哪个区块所以不能计入blockHash }) // 是前端用户发起事务时签字这时候还不知道进入哪个区块所以不能计入blockHash
this.actorSignature = await ticc.sign(json, seckey) this.actorSignature = await ticc.sign_easy({ data: json, seckey })
return this return this
} }
@ -27,7 +27,7 @@ MOM.verifySig = async function () {
let json = this.getJson({ let json = this.getJson({
exclude: ['hash', 'blockHash', 'actorSignature', 'json'] exclude: ['hash', 'blockHash', 'actorSignature', 'json']
}) })
let res = await ticc.verify({ let res = await ticc.verify_easy({
data: json, data: json,
signature: this.actorSignature, signature: this.actorSignature,
pubkey: this.actorPubkey pubkey: this.actorPubkey
@ -42,7 +42,7 @@ MOM.verifyAddress = function () {
} }
MOM.hashMe = function () { MOM.hashMe = function () {
this.hash = ticc.hash( this.hash = ticc.hash_easy(
this.getJson({ exclude: ['hash', 'blockHash', 'json'] }) this.getJson({ exclude: ['hash', 'blockHash', 'json'] })
) // block.hash 受到所包含的actionList影响所以action不能受blockHash影响否则循环了 ) // block.hash 受到所包含的actionList影响所以action不能受blockHash影响否则循环了
return this return this
@ -51,7 +51,7 @@ MOM.hashMe = function () {
MOM.verifyHash = function () { MOM.verifyHash = function () {
return ( return (
this.hash === this.hash ===
ticc.hash(this.getJson({ exclude: ['hash', 'blockHash', 'json'] })) ticc.hash_easy(this.getJson({ exclude: ['hash', 'blockHash', 'json'] }))
) )
} }
@ -81,7 +81,11 @@ MOM.checkMultiSig = async function (account) {
// 该交易内已签名的每一个公钥 // 该交易内已签名的每一个公钥
if ( if (
account.multiSignatures.keysgroup.indexOf(i) !== -1 && account.multiSignatures.keysgroup.indexOf(i) !== -1 &&
(await ticc.verify(json, this.json[i], i)) (await ticc.verify_easy({
data: json,
signature: this.json[i],
pubkey: i
}))
) { ) {
M++ M++
} }

View File

@ -73,7 +73,7 @@ class ActionTac extends Action {
) )
) )
tac.address = ticc.pubkey_to_address({ tac.address = ticc.pubkey_to_address({
pubkey: ticc.hash(action.actorSignature, action.hash) pubkey: ticc.hash_easy(action.actorSignature, action.hash)
}) })
return await tac.addMe() return await tac.addMe()
case 'transfer': case 'transfer':