Commit acc06ccf authored by duanjinfei's avatar duanjinfei

update container sign

parent ade4d256
package controllers package controllers
import ( import (
"bytes"
"crypto/ecdsa" "crypto/ecdsa"
"encoding/json" "encoding/json"
"github.com/astaxie/beego" "github.com/astaxie/beego"
...@@ -31,14 +30,14 @@ func (c *LLMController) GetContainerSign() { ...@@ -31,14 +30,14 @@ func (c *LLMController) GetContainerSign() {
return return
} }
signPrv := beego.AppConfig.String("sign_prv") signPrv := beego.AppConfig.String("sign_prv")
if signData.TaskResult == nil || signData.TaskParam == nil || signData.TaskId == "" { if signData.TaskResult == "" || signData.TaskParam == "" || signData.TaskId == "" {
c.ResponseInfo(500, "sign container is failed", nil) c.ResponseInfo(500, "sign container is failed", nil)
return return
} }
bridgePrv := stringToPrivateKey(signPrv) bridgePrv := stringToPrivateKey(signPrv)
reqHash := crypto.Keccak256Hash(signData.TaskParam) reqHash := crypto.Keccak256Hash([]byte(signData.TaskParam))
respHash := crypto.Keccak256Hash(signData.TaskResult) respHash := crypto.Keccak256Hash([]byte(signData.TaskResult))
signHash := crypto.Keccak256Hash(bytes.NewBufferString(signData.TaskId).Bytes(), reqHash.Bytes(), respHash.Bytes()) signHash := crypto.Keccak256Hash([]byte(signData.TaskId), reqHash.Bytes(), respHash.Bytes())
signature, err := crypto.Sign(signHash.Bytes(), bridgePrv) signature, err := crypto.Sign(signHash.Bytes(), bridgePrv)
if err != nil { if err != nil {
return return
......
...@@ -8,8 +8,8 @@ type SignInfoRep struct { ...@@ -8,8 +8,8 @@ type SignInfoRep struct {
type TaskInfo struct { type TaskInfo struct {
TaskId string `json:"task_id"` TaskId string `json:"task_id"`
TaskParam []byte `json:"task_param"` TaskParam string `json:"task_param"`
TaskResult []byte `json:"task_result"` TaskResult string `json:"task_result"`
} }
type ModelInfo struct { type ModelInfo struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment