Documentation
¶
Index ¶
- func CheckpointValidator(strToValidate string) bool
- func CreateAndSignCheckpoint(ctx context.Context, hostname string, treeID int64, treeSize uint64, ...) ([]byte, error)
- func FileOrURLReadCloser(ctx context.Context, url string, content []byte) (io.ReadCloser, error)
- func PrefixSHA(sha string) string
- func SignedCheckpointValidator(strToValidate string) bool
- func SignedNoteValidator(strToValidate string) bool
- func UnprefixSHA(sha string) (crypto.Hash, string)
- type Checkpoint
- type SignedCheckpoint
- type SignedNote
- func (s SignedNote) MarshalText() ([]byte, error)
- func (s *SignedNote) Sign(identity string, signer signature.Signer, opts signature.SignOption) (*note.Signature, error)
- func (s SignedNote) String() string
- func (s *SignedNote) UnmarshalText(data []byte) error
- func (s SignedNote) Verify(verifier signature.Verifier) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckpointValidator ¶
func CreateAndSignCheckpoint ¶
func CreateAndSignCheckpoint(ctx context.Context, hostname string, treeID int64, treeSize uint64, rootHash []byte, signer signature.Signer) ([]byte, error)
CreateAndSignCheckpoint creates a signed checkpoint as a commitment to the current root hash
func FileOrURLReadCloser ¶
FileOrURLReadCloser Note: caller is responsible for closing ReadCloser returned from method!
func PrefixSHA ¶
PrefixSHA sets the prefix of a sha hash to match how it is stored based on the length.
func SignedNoteValidator ¶
Types ¶
type Checkpoint ¶
type Checkpoint struct {
// Origin is the unique identifier/version string
Origin string
// Size is the number of entries in the log at this checkpoint.
Size uint64
// Hash is the hash which commits to the contents of the entire log.
Hash []byte
// OtherContent is any additional data to be included in the signed payload; each element is assumed to be one line
OtherContent []string
}
func (Checkpoint) MarshalCheckpoint ¶
func (c Checkpoint) MarshalCheckpoint() ([]byte, error)
MarshalCheckpoint returns the common format representation of this Checkpoint.
func (Checkpoint) String ¶
func (c Checkpoint) String() string
String returns the String representation of the Checkpoint
func (*Checkpoint) UnmarshalCheckpoint ¶
func (c *Checkpoint) UnmarshalCheckpoint(data []byte) error
UnmarshalCheckpoint parses the common formatted checkpoint data and stores the result in the Checkpoint.
The supplied data is expected to begin with the following 3 lines of text, each followed by a newline: <ecosystem/version string> <decimal representation of log size> <base64 representation of root hash> <optional non-empty line of other content>... <optional non-empty line of other content>...
This will discard any content found after the checkpoint (including signatures)
type SignedCheckpoint ¶
type SignedCheckpoint struct {
Checkpoint
SignedNote
}
func CreateSignedCheckpoint ¶
func CreateSignedCheckpoint(c Checkpoint) (*SignedCheckpoint, error)
func (*SignedCheckpoint) UnmarshalText ¶
func (r *SignedCheckpoint) UnmarshalText(data []byte) error
type SignedNote ¶
type SignedNote struct {
// Textual representation of a note to sign.
Note string
// Signatures are one or more signature lines covering the payload
Signatures []note.Signature
}
func (SignedNote) MarshalText ¶
func (s SignedNote) MarshalText() ([]byte, error)
MarshalText returns the common format representation of this SignedNote.
func (*SignedNote) Sign ¶
func (s *SignedNote) Sign(identity string, signer signature.Signer, opts signature.SignOption) (*note.Signature, error)
Sign adds a signature to a SignedCheckpoint object The signature is added to the signature array as well as being directly returned to the caller
func (SignedNote) String ¶
func (s SignedNote) String() string
String returns the String representation of the SignedNote
func (*SignedNote) UnmarshalText ¶
func (s *SignedNote) UnmarshalText(data []byte) error
UnmarshalText parses the common formatted signed note data and stores the result in the SignedNote. THIS DOES NOT VERIFY SIGNATURES INSIDE THE CONTENT!
The supplied data is expected to contain a single Note, followed by a single line with no comment, followed by one or more lines with the following format:
\u2014 name signature
- name is the string associated with the signer
- signature is a base64 encoded string; the first 4 bytes of the decoded value is a hint to the public key; it is a big-endian encoded uint32 representing the first 4 bytes of the SHA256 hash of the public key