Commit acc06ccf authored by duanjinfei's avatar duanjinfei

update container sign

parent ade4d256
package controllers
import (
"bytes"
"crypto/ecdsa"
"encoding/json"
"github.com/astaxie/beego"
......@@ -31,14 +30,14 @@ func (c *LLMController) GetContainerSign() {
return
}
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)
return
}
bridgePrv := stringToPrivateKey(signPrv)
reqHash := crypto.Keccak256Hash(signData.TaskParam)
respHash := crypto.Keccak256Hash(signData.TaskResult)
signHash := crypto.Keccak256Hash(bytes.NewBufferString(signData.TaskId).Bytes(), reqHash.Bytes(), respHash.Bytes())
reqHash := crypto.Keccak256Hash([]byte(signData.TaskParam))
respHash := crypto.Keccak256Hash([]byte(signData.TaskResult))
signHash := crypto.Keccak256Hash([]byte(signData.TaskId), reqHash.Bytes(), respHash.Bytes())
signature, err := crypto.Sign(signHash.Bytes(), bridgePrv)
if err != nil {
return
......
......@@ -8,8 +8,8 @@ type SignInfoRep struct {
type TaskInfo struct {
TaskId string `json:"task_id"`
TaskParam []byte `json:"task_param"`
TaskResult []byte `json:"task_result"`
TaskParam string `json:"task_param"`
TaskResult string `json:"task_result"`
}
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