aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorThibaut Horel <thibaut.horel@gmail.com>2016-05-04 15:54:19 -0400
committerThibaut Horel <thibaut.horel@gmail.com>2016-05-04 15:54:19 -0400
commit7943430749a22e6f26aa16ca2c48e97e9277998f (patch)
tree51a4d95e987d60f1b2936d5a5da9f5040efdf835 /main.go
downloadpos-7943430749a22e6f26aa16ca2c48e97e9277998f.tar.gz
Initial commit
Diffstat (limited to 'main.go')
-rw-r--r--main.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..bfe2d4b
--- /dev/null
+++ b/main.go
@@ -0,0 +1,40 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "log"
+ "os"
+ "runtime/pprof"
+)
+
+type Prover struct {
+ Merkle
+}
+
+func NewProver(height int64, fname string, mtype string) *Prover {
+ m := NewMerkle(mtype, height, fname)
+ return &Prover{m}
+}
+
+func main() {
+ height := flag.Int64("height", 0, "number of nodes is 2 ** height - 1")
+ fname := flag.String("db", "test.db", "filename for the database")
+ mtype := flag.String("mtype", "bfs", "type of Merkle tree (bfs or post)")
+ prof := flag.String("prof", "prof.prof", "filename for profile information")
+ flag.Parse()
+
+ f, err := os.Create(*prof)
+ if err != nil {
+ log.Fatal(err)
+ }
+ pprof.StartCPUProfile(f)
+ defer pprof.StopCPUProfile()
+
+ p := NewProver(*height, *fname, *mtype)
+ root := p.Build()
+ fmt.Println(root)
+ id := p.Size() / 2
+ proof := p.Proof(id)
+ fmt.Println(verify(id, proof))
+}