notary/internal/tlog: remove use of 'notary'

We are avoiding the term 'notary' to avoid confusion
with the CNCF Notary project.

For golang/go#30835.

Change-Id: Iebc053302128406f54bdb056c3b13fa208cff7bc
Reviewed-on: https://go-review.googlesource.com/c/exp/+/171977
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
diff --git a/notary/internal/tlog/note.go b/notary/internal/tlog/note.go
index a22c290..2212016 100644
--- a/notary/internal/tlog/note.go
+++ b/notary/internal/tlog/note.go
@@ -13,7 +13,7 @@
 	"strings"
 )
 
-// A Tree is a tree description signed by a notary.
+// A Tree is a tree description, to be signed by a go.sum database server.
 type Tree struct {
 	N    int64
 	Hash Hash
@@ -23,7 +23,7 @@
 //
 // The encoded form is three lines, each ending in a newline (U+000A):
 //
-//	go notary tree
+//	go.sum database tree
 //	N
 //	Hash
 //
@@ -32,19 +32,19 @@
 // A future backwards-compatible encoding may add additional lines,
 // which the parser can ignore.
 // A future backwards-incompatible encoding would use a different
-// first line (for example, "go notary tree v2").
+// first line (for example, "go.sum database tree v2").
 func FormatTree(tree Tree) []byte {
-	return []byte(fmt.Sprintf("go notary tree\n%d\n%s\n", tree.N, tree.Hash))
+	return []byte(fmt.Sprintf("go.sum database tree\n%d\n%s\n", tree.N, tree.Hash))
 }
 
 var errMalformedTree = errors.New("malformed tree note")
-var treePrefix = []byte("go notary tree\n")
+var treePrefix = []byte("go.sum database tree\n")
 
 // ParseTree parses a tree root description.
 func ParseTree(text []byte) (tree Tree, err error) {
 	// The message looks like:
 	//
-	//	go notary tree
+	//	go.sum database tree
 	//	2
 	//	nND/nri/U0xuHUrYSy0HtMeal2vzD9V4k/BO79C+QeI=
 	//
diff --git a/notary/internal/tlog/note_test.go b/notary/internal/tlog/note_test.go
index 97a21e1..78061be 100644
--- a/notary/internal/tlog/note_test.go
+++ b/notary/internal/tlog/note_test.go
@@ -12,7 +12,7 @@
 func TestFormatTree(t *testing.T) {
 	n := int64(123456789012)
 	h := RecordHash([]byte("hello world"))
-	golden := "go notary tree\n123456789012\nTszzRgjTG6xce+z2AG31kAXYKBgQVtCSCE40HmuwBb0=\n"
+	golden := "go.sum database tree\n123456789012\nTszzRgjTG6xce+z2AG31kAXYKBgQVtCSCE40HmuwBb0=\n"
 	b := FormatTree(Tree{n, h})
 	if string(b) != golden {
 		t.Errorf("FormatTree(...) = %q, want %q", b, golden)
@@ -20,7 +20,7 @@
 }
 
 func TestParseTree(t *testing.T) {
-	in := "go notary tree\n123456789012\nTszzRgjTG6xce+z2AG31kAXYKBgQVtCSCE40HmuwBb0=\n"
+	in := "go.sum database tree\n123456789012\nTszzRgjTG6xce+z2AG31kAXYKBgQVtCSCE40HmuwBb0=\n"
 	goldH := RecordHash([]byte("hello world"))
 	goldN := int64(123456789012)
 	tree, err := ParseTree([]byte(in))
@@ -31,8 +31,8 @@
 	// Check invalid trees.
 	var badTrees = []string{
 		"not-" + in,
-		"go notary tree\n0xabcdef\nTszzRgjTG6xce+z2AG31kAXYKBgQVtCSCE40HmuwBb0=\n",
-		"go notary tree\n123456789012\nTszzRgjTG6xce+z2AG31kAXYKBgQVtCSCE40HmuwBTOOBIG=\n",
+		"go.sum database tree\n0xabcdef\nTszzRgjTG6xce+z2AG31kAXYKBgQVtCSCE40HmuwBb0=\n",
+		"go.sum database tree\n123456789012\nTszzRgjTG6xce+z2AG31kAXYKBgQVtCSCE40HmuwBTOOBIG=\n",
 	}
 	for _, bad := range badTrees {
 		_, err := ParseTree([]byte(bad))
diff --git a/notary/internal/tlog/tile.go b/notary/internal/tlog/tile.go
index 855cb1e..e633958 100644
--- a/notary/internal/tlog/tile.go
+++ b/notary/internal/tlog/tile.go
@@ -138,7 +138,7 @@
 		return nil, err
 	}
 	if len(hashes) != len(indexes) {
-		return nil, fmt.Errorf("notary: ReadHashes(%d indexes) = %d hashes", len(indexes), len(hashes))
+		return nil, fmt.Errorf("tlog: ReadHashes(%d indexes) = %d hashes", len(indexes), len(hashes))
 	}
 
 	tile := make([]byte, size*HashSize)
@@ -216,7 +216,7 @@
 	return fmt.Sprintf("malformed tile path %q", e.path)
 }
 
-// A TileReader reads tiles from a notary's log.
+// A TileReader reads tiles from a go.sum database log.
 type TileReader interface {
 	// Height returns the height of the available tiles.
 	Height() int
diff --git a/notary/internal/tlog/tlog.go b/notary/internal/tlog/tlog.go
index 001523e..6703656 100644
--- a/notary/internal/tlog/tlog.go
+++ b/notary/internal/tlog/tlog.go
@@ -3,9 +3,9 @@
 // license that can be found in the LICENSE file.
 
 // Package tlog implements a tamper-evident log
-// used in the Go module notary.
+// used in the Go module go.sum database server.
 //
-// This package is part of a DRAFT of what the Go module notary will look like.
+// This package is part of a DRAFT of what the go.sum database server will look like.
 // Do not assume the details here are final!
 //
 // This package follows the design of Certificate Transparency (RFC 6962)
@@ -210,7 +210,7 @@
 		return nil, err
 	}
 	if len(old) != len(indexes) {
-		return nil, fmt.Errorf("notary: ReadHashes(%d indexes) = %d hashes", len(indexes), len(old))
+		return nil, fmt.Errorf("tlog: ReadHashes(%d indexes) = %d hashes", len(indexes), len(old))
 	}
 
 	// Build new hashes.
@@ -253,11 +253,11 @@
 		return Hash{}, err
 	}
 	if len(hashes) != len(indexes) {
-		return Hash{}, fmt.Errorf("notary: ReadHashes(%d indexes) = %d hashes", len(indexes), len(hashes))
+		return Hash{}, fmt.Errorf("tlog: ReadHashes(%d indexes) = %d hashes", len(indexes), len(hashes))
 	}
 	hash, hashes := subTreeHash(0, n, hashes)
 	if len(hashes) != 0 {
-		panic("notary: bad index math in TreeHash")
+		panic("tlog: bad index math in TreeHash")
 	}
 	return hash, nil
 }
@@ -271,7 +271,7 @@
 	for lo < hi {
 		k, level := maxpow2(hi - lo + 1)
 		if lo&(k-1) != 0 {
-			panic("notary: bad math in subTreeIndex")
+			panic("tlog: bad math in subTreeIndex")
 		}
 		need = append(need, StoredHashIndex(level, lo>>uint(level)))
 		lo += k
@@ -292,14 +292,14 @@
 	for lo < hi {
 		k, _ := maxpow2(hi - lo + 1)
 		if lo&(k-1) != 0 || lo >= hi {
-			panic("notary: bad math in subTreeHash")
+			panic("tlog: bad math in subTreeHash")
 		}
 		numTree++
 		lo += k
 	}
 
 	if len(hashes) < numTree {
-		panic("notary: bad index math in subTreeHash")
+		panic("tlog: bad index math in subTreeHash")
 	}
 
 	// Reconstruct hash.
@@ -317,7 +317,7 @@
 // ProveRecord returns the proof that the tree of size t contains the record with index n.
 func ProveRecord(t, n int64, r HashReader) (RecordProof, error) {
 	if t < 0 || n < 0 || n >= t {
-		return nil, fmt.Errorf("notary: invalid inputs in ProveRecord")
+		return nil, fmt.Errorf("tlog: invalid inputs in ProveRecord")
 	}
 	indexes := leafProofIndex(0, t, n, nil)
 	if len(indexes) == 0 {
@@ -328,12 +328,12 @@
 		return nil, err
 	}
 	if len(hashes) != len(indexes) {
-		return nil, fmt.Errorf("notary: ReadHashes(%d indexes) = %d hashes", len(indexes), len(hashes))
+		return nil, fmt.Errorf("tlog: ReadHashes(%d indexes) = %d hashes", len(indexes), len(hashes))
 	}
 
 	p, hashes := leafProof(0, t, n, hashes)
 	if len(hashes) != 0 {
-		panic("notary: bad index math in ProveRecord")
+		panic("tlog: bad index math in ProveRecord")
 	}
 	return p, nil
 }
@@ -345,7 +345,7 @@
 func leafProofIndex(lo, hi, n int64, need []int64) []int64 {
 	// See leafProof below for commentary.
 	if !(lo <= n && n < hi) {
-		panic("notary: bad math in leafProofIndex")
+		panic("tlog: bad math in leafProofIndex")
 	}
 	if lo+1 == hi {
 		return need
@@ -366,7 +366,7 @@
 func leafProof(lo, hi, n int64, hashes []Hash) (RecordProof, []Hash) {
 	// We must have lo <= n < hi or else the code here has a bug.
 	if !(lo <= n && n < hi) {
-		panic("notary: bad math in leafProof")
+		panic("tlog: bad math in leafProof")
 	}
 
 	if lo+1 == hi { // n == lo
@@ -397,7 +397,7 @@
 // with hash th has an n'th record with hash h.
 func CheckRecord(p RecordProof, t int64, th Hash, n int64, h Hash) error {
 	if t < 0 || n < 0 || n >= t {
-		return fmt.Errorf("notary: invalid inputs in CheckRecord")
+		return fmt.Errorf("tlog: invalid inputs in CheckRecord")
 	}
 	th2, err := runRecordProof(p, 0, t, n, h)
 	if err != nil {
@@ -415,7 +415,7 @@
 func runRecordProof(p RecordProof, lo, hi, n int64, leafHash Hash) (Hash, error) {
 	// We must have lo <= n < hi or else the code here has a bug.
 	if !(lo <= n && n < hi) {
-		panic("notary: bad math in runRecordProof")
+		panic("tlog: bad math in runRecordProof")
 	}
 
 	if lo+1 == hi { // m == lo
@@ -456,7 +456,7 @@
 // as a prefix all the records from the tree of smaller size n.
 func ProveTree(t, n int64, h HashReader) (TreeProof, error) {
 	if t < 1 || n < 1 || n > t {
-		return nil, fmt.Errorf("notary: invalid inputs in ProveTree")
+		return nil, fmt.Errorf("tlog: invalid inputs in ProveTree")
 	}
 	indexes := treeProofIndex(0, t, n, nil)
 	if len(indexes) == 0 {
@@ -467,12 +467,12 @@
 		return nil, err
 	}
 	if len(hashes) != len(indexes) {
-		return nil, fmt.Errorf("notary: ReadHashes(%d indexes) = %d hashes", len(indexes), len(hashes))
+		return nil, fmt.Errorf("tlog: ReadHashes(%d indexes) = %d hashes", len(indexes), len(hashes))
 	}
 
 	p, hashes := treeProof(0, t, n, hashes)
 	if len(hashes) != 0 {
-		panic("notary: bad index math in ProveTree")
+		panic("tlog: bad index math in ProveTree")
 	}
 	return p, nil
 }
@@ -483,7 +483,7 @@
 func treeProofIndex(lo, hi, n int64, need []int64) []int64 {
 	// See treeProof below for commentary.
 	if !(lo < n && n <= hi) {
-		panic("notary: bad math in treeProofIndex")
+		panic("tlog: bad math in treeProofIndex")
 	}
 
 	if n == hi {
@@ -509,7 +509,7 @@
 func treeProof(lo, hi, n int64, hashes []Hash) (TreeProof, []Hash) {
 	// We must have lo < n <= hi or else the code here has a bug.
 	if !(lo < n && n <= hi) {
-		panic("notary: bad math in treeProof")
+		panic("tlog: bad math in treeProof")
 	}
 
 	// Reached common ground.
@@ -543,7 +543,7 @@
 // contains as a prefix the tree of size n with hash h.
 func CheckTree(p TreeProof, t int64, th Hash, n int64, h Hash) error {
 	if t < 1 || n < 1 || n > t {
-		return fmt.Errorf("notary: invalid inputs in CheckTree")
+		return fmt.Errorf("tlog: invalid inputs in CheckTree")
 	}
 	h2, th2, err := runTreeProof(p, 0, t, n, h)
 	if err != nil {
@@ -562,7 +562,7 @@
 func runTreeProof(p TreeProof, lo, hi, n int64, old Hash) (Hash, Hash, error) {
 	// We must have lo < n <= hi or else the code here has a bug.
 	if !(lo < n && n <= hi) {
-		panic("notary: bad math in runTreeProof")
+		panic("tlog: bad math in runTreeProof")
 	}
 
 	// Reached common ground.