func (b *ConstraintBuilder) outputSpec(w io.Writer) {
	if !b.buildSpec {
		log.Fatal("Can't output spec: buildSpec is false")
	}

	// When creating something that can be spliced into an existing spec file, we don't need inputs
	// and outputs

	//  fmt.Fprintf(w, "START_INPUT\n")
	//  for i := 0; i < b.inputNum; i++ {
	//      b.printVar(w, fmt.Sprintf("I%v", i))
	//  }
	//  fmt.Fprintf(w, "END_INPUT\n\n")
	//
	//  fmt.Fprintf(w, "START_OUTPUT\n")
	//  for i := b.inputNum; i < b.nextInputOutputSub; i++ {
	//      b.printVar(w, fmt.Sprintf("O%v", i))
	//  }
	//  fmt.Fprintf(w, "END_OUTPUT\n\n")

	fmt.Fprintf(w, "START_VARIABLES\n")
	for _, v := range b.extVars {
		b.printVar(w, v)
	}
	for i := 0; i < b.nextSubcript; i++ {
		b.printVar(w, fmt.Sprintf("V%v", i))
	}
	fmt.Fprintf(w, "END_VARIABLES\n\n")

	fmt.Fprintf(w, "START_CONSTRAINTS\n")
	util.CopyOrDie(w, b.cmdsFile)
	fmt.Fprintf(w, "END_CONSTRAINTS\n")
}
func (b *ConstraintBuilder) outputPWS(w io.Writer) {
	if b.buildSpec {
		log.Fatal("Can't output PWS: buildSpec is true")
	}
	if b.outputTmpl {
		b.printTmplHeader(w)
	}

	util.CopyOrDie(w, b.cmdsFile)
}
Exemple #3
0
func main() {
	var dbSize int
	flag.IntVar(&dbSize, "dbSize", 16, "")

	var hashType string
	flag.StringVar(&hashType, "hashType", "ggh", "")

	var fnames [3]string
	flag.StringVar(&fnames[0], "pwsFile", "", "")
	flag.StringVar(&fnames[1], "f1File", "", "")
	flag.StringVar(&fnames[2], "qapFile", "", "")

	flag.Parse()

	var files [3]*os.File
	util.OpenFiles(fnames[:], files[:])

	fmt.Fprintf(os.Stderr, "dbSize: %d\n", dbSize)

	var qapMats [3]*os.File
	for i := 0; i < 3; i++ {
		qapMats[i] = util.OpenTempFile("qapMat" + strconv.Itoa(i))
	}

	m := merkle.NewMerkle(dbSize, hashType, nil, files[0], qapMats[0], qapMats[1], qapMats[2], files[1], false)
	//	m.GenSumConstraints()
	//	m.GenGetPutConstraints()
	m.GenOp("get", 1)
	m.WriteFiles()

	qapFile := files[2]
	for i, f := range qapMats {
		util.CopyOrDie(qapFile, f)
		if i < len(qapMats)-1 {
			fmt.Fprintln(qapFile)
		}
	}
	qapFile.Close()

	m.GetCB().PrintParams(os.Stderr)
}