19 lines
534 B
Go
19 lines
534 B
Go
package bloat
|
|
|
|
import (
|
|
"bytes"
|
|
|
|
"aead.dev/minisign"
|
|
)
|
|
|
|
// Verify checks the minisign signature and returns the body if valid.
|
|
func (b *Bloat[T]) verify(message []byte) ([]byte, bool, error) {
|
|
// signature is last 4 lines:
|
|
separated := bytes.Split(message, []byte("\n"))
|
|
signature := bytes.Join(separated[len(separated)-4:len(separated)], []byte("\n"))
|
|
body := bytes.Join(separated[:len(separated)-4], []byte("\n"))
|
|
if !minisign.Verify(b.SignPub, body, signature) {
|
|
return []byte(""), false, nil
|
|
}
|
|
return body, true, nil
|
|
}
|