29 lines
427 B
Go
29 lines
427 B
Go
package kgc
|
|
|
|
import (
|
|
"bytes"
|
|
"crypto/sha256"
|
|
"schain/proto/util"
|
|
)
|
|
|
|
func Certificateless_Verify(creatorBytes []byte, signature, msg []byte) error {
|
|
|
|
creator, err := util.UnmarshalCreator(creatorBytes)
|
|
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
publicKey := creator.IdBytes
|
|
|
|
digest := sha256.Sum256(msg)
|
|
|
|
data := append(publicKey, digest[:]...)
|
|
|
|
if equal := bytes.Equal(data, signature); equal {
|
|
return nil
|
|
}
|
|
|
|
return err
|
|
}
|