From f29739567671db29cb2a97ce061260bfa47eba02 Mon Sep 17 00:00:00 2001 From: John Guibas Date: Tue, 7 May 2024 23:32:51 -0700 Subject: [PATCH] feat: groth16 --- prover/src/install.rs | 6 +++--- recursion/gnark/main_test.go | 2 +- recursion/gnark/server/load.go | 14 +++++++------- recursion/gnark/sp1/groth16.go | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/prover/src/install.rs b/prover/src/install.rs index 750181e651..f37458ffc3 100644 --- a/prover/src/install.rs +++ b/prover/src/install.rs @@ -17,11 +17,11 @@ pub const GROTH16_ARTIFACTS_COMMIT: &str = "49fedbe4"; pub fn install_groth16_artifacts(build_dir: PathBuf) { // If build directory already exists, skip the download. if build_dir.exists() { - println!("[sp1]: groth16 artifacts already seem to exist at {}. if you want to re-download them, delete the directory", build_dir.display()); + println!("[sp1] groth16 artifacts already seem to exist at {}. if you want to re-download them, delete the directory", build_dir.display()); return; } else { println!( - "[sp1]: groth16 artifacts for commit {} do not exist at {}. downloading...", + "[sp1] groth16 artifacts for commit {} do not exist at {}. downloading...", GROTH16_ARTIFACTS_COMMIT, build_dir.display() ); @@ -61,7 +61,7 @@ pub fn install_groth16_artifacts(build_dir: PathBuf) { res.wait().unwrap(); println!( - "[sp1]: downloaded {} to {:?}", + "[sp1] downloaded {} to {:?}", download_url, build_dir.to_str().unwrap(), ); diff --git a/recursion/gnark/main_test.go b/recursion/gnark/main_test.go index df8527d4b1..ff40fe6b83 100644 --- a/recursion/gnark/main_test.go +++ b/recursion/gnark/main_test.go @@ -62,7 +62,7 @@ func TestMain(t *testing.T) { if err != nil { panic(err) } - fmt.Println("[sp1]: groth16 verifier constraints:", r1cs.GetNbConstraints()) + fmt.Println("[sp1] groth16 verifier constraints:", r1cs.GetNbConstraints()) // Run the dummy setup. var pk groth16.ProvingKey diff --git a/recursion/gnark/server/load.go b/recursion/gnark/server/load.go index 40a2e0271f..dbf8da1b68 100644 --- a/recursion/gnark/server/load.go +++ b/recursion/gnark/server/load.go @@ -66,7 +66,7 @@ func LoadCircuitArtifacts(dataDir, circuitType string) (constraint.ConstraintSys defer wg.Done() r1csFilePath := filepath.Join(dataDir, "circuit_"+circuitType+".bin") - fmt.Println("[sp1]: opening r1cs file at:", r1csFilePath) + fmt.Println("[sp1] opening r1cs file at:", r1csFilePath) r1csFile, err := os.Open(r1csFilePath) if err != nil { errR1CS = errors.Wrap(err, "opening R1CS file") @@ -77,11 +77,11 @@ func LoadCircuitArtifacts(dataDir, circuitType string) (constraint.ConstraintSys r1csReader := bufio.NewReader(r1csFile) r1csStart := time.Now() r1cs = groth16.NewCS(ecc.BN254) - fmt.Println("[sp1]: reading r1cs file...") + fmt.Println("[sp1] reading r1cs file...") if _, err = r1cs.ReadFrom(r1csReader); err != nil { errR1CS = errors.Wrap(err, "reading R1CS content from file") } else { - fmt.Printf("[sp1]: r1cs loaded in %s\n", time.Since(r1csStart)) + fmt.Printf("[sp1] r1cs loaded in %s\n", time.Since(r1csStart)) } }() @@ -90,7 +90,7 @@ func LoadCircuitArtifacts(dataDir, circuitType string) (constraint.ConstraintSys defer wg.Done() pkFilePath := filepath.Join(dataDir, "pk_"+circuitType+".bin") - fmt.Println("[sp1]: opening pk file at", pkFilePath) + fmt.Println("[sp1] opening pk file at", pkFilePath) pkFile, err := os.Open(pkFilePath) if err != nil { errPK = errors.Wrap(err, "opening PK file") @@ -101,12 +101,12 @@ func LoadCircuitArtifacts(dataDir, circuitType string) (constraint.ConstraintSys pkReader := bufio.NewReader(pkFile) pkStart := time.Now() pk = groth16.NewProvingKey(ecc.BN254) - fmt.Println("[sp1]: reading pk file...") + fmt.Println("[sp1] reading pk file...") err = pk.ReadDump(pkReader) if err != nil { errPK = errors.Wrap(err, "reading PK content from file") } - fmt.Printf("[sp1]: pk loaded in %s\n", time.Since(pkStart)) + fmt.Printf("[sp1] pk loaded in %s\n", time.Since(pkStart)) }() wg.Wait() @@ -136,7 +136,7 @@ func LoadCircuitArtifacts(dataDir, circuitType string) (constraint.ConstraintSys return nil, nil, nil, errors.Wrap(err, "error reading VK content") } - fmt.Printf("[sp1]: circuit artifacts loaded successfully in %s\n", time.Since(startTime)) + fmt.Printf("[sp1] circuit artifacts loaded successfully in %s\n", time.Since(startTime)) return r1cs, pk, vk, nil diff --git a/recursion/gnark/sp1/groth16.go b/recursion/gnark/sp1/groth16.go index ca099ba244..594408f538 100644 --- a/recursion/gnark/sp1/groth16.go +++ b/recursion/gnark/sp1/groth16.go @@ -32,7 +32,7 @@ func BuildGroth16(buildDir string) error { panic(err) } // p.Stop() - fmt.Println("[sp1]: groth16 verifier constraints", r1cs.GetNbConstraints()) + fmt.Println("[sp1] groth16 verifier constraints", r1cs.GetNbConstraints()) // Run the trusted setup. pk, vk, err := groth16.Setup(r1cs)