Exemple #1
0
func emptyKeys(t *graphs.Tree) {
	t.PriKey = ""
	t.PubKey = ""
	for _, c := range t.Children {
		emptyKeys(c)
	}
}
Exemple #2
0
// ConstructTree takes a map of host -> public keys and a branching factor
// so it can constructs a regular tree. THe returned tree is the root
// it is constructed bfs style
func constructTree(hosts, pubs []string, bf int) *graphs.Tree {
	var root *graphs.Tree = new(graphs.Tree)
	root.Name = hosts[0]
	root.PubKey = pubs[0]
	var index int = 1
	bfs := make([]*graphs.Tree, 1)
	bfs[0] = root
	for len(bfs) > 0 && index < len(hosts) {
		t := bfs[0]
		t.Children = make([]*graphs.Tree, 0)
		lbf := 0
		// create space for enough children
		// init them
		for lbf < bf && index < len(hosts) {
			child := new(graphs.Tree)
			child.Name = hosts[index]
			child.PubKey = pubs[index]
			// append the children to the list of trees to visit
			bfs = append(bfs, child)
			t.Children = append(t.Children, child)
			index += 1
			lbf += 1
		}
		bfs = bfs[1:]
	}
	return root
}
Exemple #3
0
// Simple ephemeral helper for compatibility issues
// From base64 => hexadecimal
func convertTree(suite abstract.Suite, t *graphs.Tree) {
	if t.PubKey != "" {
		point, err := cliutils.ReadPub64(suite, strings.NewReader(t.PubKey))
		if err != nil {
			dbg.Fatal("Could not decode base64 public key")
		}

		str, err := cliutils.PubHex(suite, point)
		if err != nil {
			dbg.Fatal("Could not encode point to hexadecimal")
		}
		t.PubKey = str
	}
	for _, c := range t.Children {
		convertTree(suite, c)
	}
}