27 lines
597 B
Go
27 lines
597 B
Go
package consensus
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/Secured-Finance/dione/consensus/types"
|
|
"github.com/Secured-Finance/dione/sigs"
|
|
types2 "github.com/Secured-Finance/dione/types"
|
|
"github.com/mitchellh/hashstructure/v2"
|
|
)
|
|
|
|
func verifyTaskSignature(msg types.ConsensusMessage) error {
|
|
cHash, err := hashstructure.Hash(msg.Task, hashstructure.FormatV2, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = sigs.Verify(
|
|
&types2.Signature{Type: types2.SigTypeEd25519, Data: msg.Task.Signature},
|
|
[]byte(msg.Task.Miner),
|
|
[]byte(fmt.Sprintf("%v", cHash)),
|
|
)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|