示例#1
0
文件: main.go 项目: Roasbeef/versum
func main() {
	core.RegisterTypes()

	flag.Parse()

	db := core.ContinueDB(filepath.Join(*BaseDbPath, "balances"), *treapToken)

	logtreap := new(verified.LogTreap)
	logtreap.MakeOpaque()
	ads.GetInfo(logtreap).Token = *treapToken

	pagingC := core.NewPagingC(db)
	pagingC.Load(ads.GetInfo(logtreap))

	c := pagingC

	c.Use(logtreap)
	length := logtreap.Count(c)
	hash := logtreap.Slice(0, length, c)

	// this hash is what we commit to....
	c.Use(hash)
	tree := hash.Finish(c).(verified.LogTree)

	c.Use(tree)
	lastReturn := tree.Index(length-1, c)

	c.Use(lastReturn)
	balances := lastReturn.ArgsOrResults[0].(bitrie.Bitrie)

	c.Use(balances)
	// core.Dump(bitrie.Bits{}, balances, c)

	fmt.Println(logtreap.Count(c))
	fmt.Println(commitmentToBalances(hash, c))
	n := 1000
	sizes := make([]int, 0)
	for i := 0; i < n; i++ {
		sizes = append(sizes, randomBalance(balances, c))
	}
	sort.Ints(sizes)
	fmt.Println(sizes)

	sizes = make([]int, 0)
	for i := 0; i < n; i++ {
		j := rand.Intn(int(logtreap.Count(c) - 1))
		hash := logtreap.Slice(0, int32(j+1), c)
		sizes = append(sizes, nextstep(hash, c))
	}

	for i := 0; i < 20; i++ {
		j := rand.Intn(int(logtreap.Count(c) - 5000 - 1))
		for k := j; k < j+5000; k++ {
			hash := logtreap.Slice(0, int32(k+1), c)
			sizes = append(sizes, nextstep(hash, c))
		}
	}
	sort.Ints(sizes)
	fmt.Println(sizes)
}
示例#2
0
文件: main.go 项目: Roasbeef/versum
func main() {
	core.RegisterTypes()
	transactions.RegisterTypes()

	flag.Parse()

	db := core.ContinueDB(filepath.Join(*BaseDbPath, "transactions"), *treapToken)

	logtreap := new(verified.LogTreap)
	logtreap.MakeOpaque()
	ads.GetInfo(logtreap).Token = *treapToken

	pagingC := core.NewPagingC(db)
	pagingC.Load(ads.GetInfo(logtreap))

	c := pagingC

	c.Use(logtreap)
	length := logtreap.Count(c)
	hash := logtreap.Slice(0, length, c)

	// this hash is what we commit to....
	c.Use(hash)
	tree := hash.Finish(c).(verified.LogTree)

	c.Use(tree)
	lastReturn := tree.Index(length-1, c)

	c.Use(lastReturn)
	transactions := lastReturn.ArgsOrResults[0].(bitrie.Bitrie)

	c.Use(transactions)
	fmt.Println(BitrieSize(transactions, c))

	for i := 0; i < 100; i++ {
		fmt.Println(core.RandomKey(bitrie.Bits{}, transactions, c))
	}
}