7c891bd5f2
message: Initial commit, can create master commit and verify previous master commits change_hash: ADgeVBdfi1hA0TTDrBIkYHaQQYoxZaInZz1p/BAH35Ng credentials: - type: pgp_signature pub_key_id: 95C46FA6A41148AC body: iQIzBAABAgAdFiEEJ6tQKp6olvZKJ0lwlcRvpqQRSKwFAl5IbRgACgkQlcRvpqQRSKzWjg/+P0a3einWQ8wFUe05qXUbmMQ4K86Oa4I85pF6kubZlFy/UbcjiPnTPRMKAhmGZi4WCz1sW1F2al4qKvtq3nvn6+hZY8dj0SjPgGG2lkMMLEVy1hjsO7d9S9ZEfUv0cHOcvkphgVQk+InkegBXvFS45mwKQLDOiW5tPcTFDHTHBmC/nlCV/sKCrZEmQGU7KaELJKOf26LSY2zXe6fbVCa8njpIycYS7Wulu2OODcI5n6Ye2U6DvxN6MvuNvziyX7VMePS1xEdJYpltsNMhSkMMGLU7dovxbrhD617uwOsm1847YX9HTJ3Ixs+M0yobHmz8ob4OBcZx8r3AoiyDo+HNMmAZ96ue8pPHmI+2O9jEmbmbH61yq4crhUVAP8PncSTdq0tiYKj/zaSTJ8CT2W0uicX/3v9EtIFn0thqe/qZzHh6upixvpXDpNjZZ5SxiVm8MITnWzInQRbo9yvFsfgd7LqMGKZeGv5q5rgNTRM4fwGrJDuslwj8V2B4uw1ofPncL+LHmXArXWiewvvJFU2uRpfvsl+u4is2dl2SGVpe7ixm+a088gllOQCMRgLbuaN8dQ/eqdkfdxUg+SYQlx6vykrdJOSQrs9zaX/JuxnaNBTi/yLY1FqFXaXBGID6qX1cnPilw+J6vEZYt1MBtzXX+UEjHyVowIhMRsnts6Wq3Z8= account: mediocregopher
51 lines
1.6 KiB
Go
51 lines
1.6 KiB
Go
package sigcred
|
|
|
|
import (
|
|
"dehub/fs"
|
|
"dehub/typeobj"
|
|
)
|
|
|
|
// Signifier reprsents a single signing method being defined in the Config. Only
|
|
// one field should be set on each Signifier.
|
|
type Signifier struct {
|
|
PGPPublicKey *SignifierPGP `type:"pgp_public_key"`
|
|
PGPPublicKeyFile *SignifierPGPFile `type:"pgp_public_key_file"`
|
|
}
|
|
|
|
// MarshalYAML implements the yaml.Marshaler interface.
|
|
func (s Signifier) MarshalYAML() (interface{}, error) {
|
|
return typeobj.MarshalYAML(s)
|
|
}
|
|
|
|
// UnmarshalYAML implements the yaml.Unmarshaler interface.
|
|
func (s *Signifier) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
|
return typeobj.UnmarshalYAML(s, unmarshal)
|
|
}
|
|
|
|
// Interface returns the SignifierInterface instance encapsulated by this
|
|
// Signifier object.
|
|
func (s Signifier) Interface() (SignifierInterface, error) {
|
|
el, _, err := typeobj.Element(s)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return el.(SignifierInterface), nil
|
|
}
|
|
|
|
// SignifierInterface describes the methods that all Signifiers must implement.
|
|
type SignifierInterface interface {
|
|
// Sign returns a Credential containing a signature of the given data.
|
|
//
|
|
// tree can be used to find the Signifier at a particular snapshot.
|
|
Sign(fs fs.FS, data []byte) (Credential, error)
|
|
|
|
// Signed returns true if the Signifier was used to sign the Credential.
|
|
Signed(fs fs.FS, cred Credential) (bool, error)
|
|
|
|
// Verify asserts that the Signifier produced the given Credential for the
|
|
// given data set, or returns an error.
|
|
//
|
|
// tree can be used to find the Signifier at a particular snapshot.
|
|
Verify(fs fs.FS, data []byte, cred Credential) error
|
|
}
|