diff options
| author | Thibaut Horel <thibaut.horel@gmail.com> | 2016-05-04 15:54:19 -0400 |
|---|---|---|
| committer | Thibaut Horel <thibaut.horel@gmail.com> | 2016-05-04 15:54:19 -0400 |
| commit | 7943430749a22e6f26aa16ca2c48e97e9277998f (patch) | |
| tree | 51a4d95e987d60f1b2936d5a5da9f5040efdf835 /main.go | |
| download | pos-7943430749a22e6f26aa16ca2c48e97e9277998f.tar.gz | |
Initial commit
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -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)) +} |
