diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2021-06-02 14:39:27 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2021-06-02 14:39:27 +0200 |
commit | 6e04ae48997ae5fa6e0f803792b674ca24bad8f0 (patch) | |
tree | 3cd5fd2150d0677aecbfa7cb453447740659ad54 /trillian/util.go | |
parent | 0d55439c5292ced60e7c2cfd3761f9ef990414ce (diff) |
added refactored GetConsistencyProof
Diffstat (limited to 'trillian/util.go')
-rw-r--r-- | trillian/util.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/trillian/util.go b/trillian/util.go new file mode 100644 index 0000000..87e64b6 --- /dev/null +++ b/trillian/util.go @@ -0,0 +1,33 @@ +package trillian + +import ( + "fmt" + + trillian "github.com/google/trillian/types" + siglog "github.com/system-transparency/stfe/types" +) + +func treeHeadFromLogRoot(lr *trillian.LogRootV1) *siglog.TreeHead { + var hash [siglog.HashSize]byte + th := siglog.TreeHead{ + Timestamp: uint64(lr.TimestampNanos / 1000 / 1000 / 1000), + TreeSize: uint64(lr.TreeSize), + RootHash: &hash, + } + copy(th.RootHash[:], lr.RootHash) + return &th +} + +func nodePathFromHashes(hashes [][]byte) ([]*[siglog.HashSize]byte, error) { + var path []*[siglog.HashSize]byte + for _, hash := range hashes { + if len(hash) != siglog.HashSize { + return nil, fmt.Errorf("unexpected hash length: %v", len(hash)) + } + + var h [siglog.HashSize]byte + copy(h[:], hash) + path = append(path, &h) + } + return path, nil +} |