From 8cf67bf90c262883b78e6915833b528883fb6d1f Mon Sep 17 00:00:00 2001 From: "luk.lu" Date: Sat, 23 Jul 2022 16:03:24 +0800 Subject: [PATCH] rename ticc.sign/verify/encrypt/decrypt/hash to ticc.xxx_easy --- Action.js | 13 +++++++++---- ActionMultisig.js | 14 +++++++++----- ActionTac.js | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Action.js b/Action.js index 53d61aa..af77708 100644 --- a/Action.js +++ b/Action.js @@ -52,18 +52,22 @@ MOM.packMe = async function (keypair) { MOM.signMe = async function (seckey) { // 由前端调用,后台不该进行签名 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 } 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 } MOM.verifySig = async function () { 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 } DAD.verifySig = async function (actionData) { @@ -83,7 +87,8 @@ DAD.verifyAddress = function (actionData) { MOM.verifyHash = function () { return ( - this.hash === ticc.hash(this.getJson({ exclude: ['hash', 'blockHash'] })) + this.hash === + ticc.hash_easy(this.getJson({ exclude: ['hash', 'blockHash'] })) ) } DAD.verifyHash = function (actionData) { diff --git a/ActionMultisig.js b/ActionMultisig.js index eb0a021..c2603eb 100644 --- a/ActionMultisig.js +++ b/ActionMultisig.js @@ -19,7 +19,7 @@ MOM.signMe = async function (seckey) { let json = this.getJson({ exclude: ['hash', 'blockHash', 'actorSignature', 'json'] }) // 是前端用户发起事务时签字,这时候还不知道进入哪个区块,所以不能计入blockHash - this.actorSignature = await ticc.sign(json, seckey) + this.actorSignature = await ticc.sign_easy({ data: json, seckey }) return this } @@ -27,7 +27,7 @@ MOM.verifySig = async function () { let json = this.getJson({ exclude: ['hash', 'blockHash', 'actorSignature', 'json'] }) - let res = await ticc.verify({ + let res = await ticc.verify_easy({ data: json, signature: this.actorSignature, pubkey: this.actorPubkey @@ -42,7 +42,7 @@ MOM.verifyAddress = function () { } MOM.hashMe = function () { - this.hash = ticc.hash( + this.hash = ticc.hash_easy( this.getJson({ exclude: ['hash', 'blockHash', 'json'] }) ) // block.hash 受到所包含的actionList影响,所以action不能受blockHash影响,否则循环了 return this @@ -51,7 +51,7 @@ MOM.hashMe = function () { MOM.verifyHash = function () { return ( 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 ( 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++ } diff --git a/ActionTac.js b/ActionTac.js index 861feea..4866c37 100644 --- a/ActionTac.js +++ b/ActionTac.js @@ -73,7 +73,7 @@ class ActionTac extends Action { ) ) 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() case 'transfer':