util

package
v1.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 20 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckpointValidator added in v0.2.0

func CheckpointValidator(strToValidate string) bool

func CreateAndSignCheckpoint added in v0.12.0

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

func FileOrURLReadCloser(ctx context.Context, url string, content []byte) (io.ReadCloser, error)

FileOrURLReadCloser Note: caller is responsible for closing ReadCloser returned from method!

func PrefixSHA added in v0.6.0

func PrefixSHA(sha string) string

PrefixSHA sets the prefix of a sha hash to match how it is stored based on the length.

func SignedCheckpointValidator added in v0.2.0

func SignedCheckpointValidator(strToValidate string) bool

func SignedNoteValidator added in v0.3.0

func SignedNoteValidator(strToValidate string) bool

func UnprefixSHA added in v1.3.5

func UnprefixSHA(sha string) (crypto.Hash, string)

Types

type Checkpoint added in v0.2.0

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 added in v0.4.0

func (c Checkpoint) MarshalCheckpoint() ([]byte, error)

MarshalText returns the common format representation of this Checkpoint.

func (Checkpoint) String added in v0.2.0

func (c Checkpoint) String() string

String returns the String representation of the Checkpoint

func (*Checkpoint) UnmarshalCheckpoint added in v0.4.0

func (c *Checkpoint) UnmarshalCheckpoint(data []byte) error

UnmarshalText 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 added in v0.2.0

type SignedCheckpoint struct {
	Checkpoint
	SignedNote
}

func CreateSignedCheckpoint added in v0.3.0

func CreateSignedCheckpoint(c Checkpoint) (*SignedCheckpoint, error)

func (*SignedCheckpoint) UnmarshalText added in v0.2.0

func (r *SignedCheckpoint) UnmarshalText(data []byte) error

type SignedNote added in v0.3.0

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 added in v0.3.0

func (s SignedNote) MarshalText() ([]byte, error)

MarshalText returns the common format representation of this SignedNote.

func (*SignedNote) Sign added in v0.3.0

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 added in v0.3.0

func (s SignedNote) String() string

String returns the String representation of the SignedNote

func (*SignedNote) UnmarshalText added in v0.3.0

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

func (SignedNote) Verify added in v0.3.0

func (s SignedNote) Verify(verifier signature.Verifier) bool

Verify checks that one of the signatures can be successfully verified using the supplied public key

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL