mirroring

package module
v0.0.0-...-7f28903 Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: Apache-2.0 Imports: 28 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendArtifactsToFile

func AppendArtifactsToFile(artifacts []Artifact) error

consider loading filenames/paths from viper registry

func ComputeRoot

func ComputeRoot(maxSize int64) ([]byte, error)
func ComputeRootRecursive(maxSize int64) ([]byte, error) {
	return computeRootRecursive(0, maxSize)
}
func computeRootRecursive(minSize, maxSize int64) ([]byte, error) {
	if minSize == maxSize-1 {
		artifact, err := ReadLeaveFromFile(minSize)
		if err != nil {
			return nil, err
		}
		str := artifact.MerkleTreeHash

		hash, err := hex.DecodeString(str)
		if err != nil {
			return nil, err
		}
		return hash, nil
	} else {
		separator := powerOfTwo(maxSize)
		leftHash, err := computeRootRecursive(minSize, separator)
		if err != nil {
			return nil, err
		}
		rightHash, err := computeRootRecursive(separator, maxSize)
		if err != nil {
			return nil, err
		}
		hash := rfc6962.DefaultHasher.HashChildren(leftHash, rightHash)
		return hash, nil
	}
}

func ComputeRootFromMemory

func ComputeRootFromMemory(artifacts []Artifact) ([]byte, error)

func FetchLeavesByRange

func FetchLeavesByRange(initSize, finalSize int64) error

FetchLeavesByRange fetches leaves by range and saves them into a file.

func GetLogEntryByIndex

func GetLogEntryByIndex(logIndex int64, rekorClient *client.Rekor) (string, models.LogEntryAnon, error)

GetLogEntryByIndex returns an object with the log index, integratedTime, UUID, and body

logEntry := models.LogEntry{
	hex.EncodeToString(leaf.MerkleLeafHash): models.LogEntryAnon{
		LogIndex:       &leaf.LeafIndex,
		Body:           leaf.LeafValue,
		IntegratedTime: leaf.IntegrateTimestamp.AsTime().Unix(),
	},
}

func GetLogInfo

func GetLogInfo() (*models.LogInfo, error)

GetLogInfo retrieves the root hash, the tree size, the key hint, log root, and signature of the log through the Rekor API.

func GetPublicKey

func GetPublicKey() (string, error)

GetPublicKey returns public key of entity that signed STH in string type.

func NewClient

func NewClient() (*client.Rekor, error)

NewClient creates a Rekor Client for log queries.

func ParseEntry

func ParseEntry(uuid string, e models.LogEntryAnon) (getCmdOutput, error)

this function also verifies the integrity of an entry.

func SaveTreeMetadata

func SaveTreeMetadata() error

func UpdateMetadataByIndex

func UpdateMetadataByIndex(i int64) error

func UpdateMetadataBySTH

func UpdateMetadataBySTH() error

func VerifySignature

func VerifySignature(pub string) error

VerifySignature verifies the integrity of the signed tree hash.

Types

type Artifact

type Artifact struct {
	Pk             string `json:"pk,omitempty"`
	DataHash       string `json:"data_hash,omitempty"`
	Sig            string `json:"sig,omitempty"`
	MerkleTreeHash string `json:"merkle_tree_hash,omitempty"`
}

func GetLogEntryData

func GetLogEntryData(logIndex int64, rekorClient *client.Rekor) (Artifact, error)

func ReadLeaveFromFile

func ReadLeaveFromFile(idx int64) (Artifact, error)

type TreeMetadata

type TreeMetadata struct {
	PublicKey     string          `json:"public_key,omitempty"`
	LogInfo       *models.LogInfo `json:"log_info,omitempty"`
	SavedMaxIndex int64           `json:"saved_max_index,omitempty"`
}

func LoadTreeMetadata

func LoadTreeMetadata() (TreeMetadata, error)

Jump to

Keyboard shortcuts

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