jx/internal/folio/signature.go

36 lines
618 B
Go
Raw Normal View History

2024-09-19 07:57:26 +00:00
// Copyright 2024 Matthew Rich <matthewrich.conf@gmail.com>. All rights reserved.
package folio
import (
"decl/internal/data"
"decl/internal/signature"
"errors"
"encoding/hex"
)
var (
ErrInvalidSignature error = errors.New("Invalid signature")
)
type Signature []byte
func (s Signature) Verify(res data.ContentHasher) error {
i := &signature.Ident{}
return i.VerifySum(res.Hash(), s)
}
func (s *Signature) SetHexString(sig string) error {
if v, e := hex.DecodeString(sig); e == nil {
*s = v
} else {
return e
}
return nil
}
func (s *Signature) String() string {
return hex.EncodeToString(*s)
}