Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regarding the meaning of DEBUG content. #1414

Open
TheYangCode opened this issue Feb 7, 2025 · 2 comments
Open

Regarding the meaning of DEBUG content. #1414

TheYangCode opened this issue Feb 7, 2025 · 2 comments

Comments

@TheYangCode
Copy link

Hello, I apologize for disturbing you. I am a beginner using gnark. I wrote a test function for the Eddsa proof.

func Prove() {
	// compiles our circuit into a R1CS
	var circuit eddsaCircuit
	ccs, err := frontend.Compile(ecc.BN254.ScalarField(), r1cs.NewBuilder, &circuit)
	if err != nil {
		fmt.Println("failed to Compile. error:", err)
		return
	}

	// groth16 zkSNARK: Setup
	pk, vk, err := groth16.Setup(ccs)
	if err != nil {
		fmt.Println("failed to Setup. error:", err)
		return
	}

	witness, err := frontend.NewWitness(GetEddsaCircuit(), ecc.BN254.ScalarField())
	if err != nil {
		fmt.Println("failed to NewWitness. error:", err)
		return
	}
	publicWitness, err := witness.Public()
	if err != nil {
		fmt.Println("failed to witness.Public. error:", err)
		return
	}

	// groth16: Prove & Verify
	proof, err := groth16.Prove(ccs, pk, witness)
	if err != nil {
		fmt.Println("failed to Prove. error:", err)
		return
	}

	err = groth16.Verify(proof, vk, publicWitness)
	if err != nil {
		fmt.Println("Prove get invalid signature")
	} else {
		fmt.Println("Prove get valid signature")
	}
}

Test results obtained:
Image

But I am not very clear about the meanings of symbols in the DEBUG log and would like to obtain an official accurate answer.
I have the following questions:
1.Does constraint system solver done refers to groth16.Setup?
2.Does prover done refers to groth16.Prove?
3.Does verifier done refers to groth16.Verify?
4.Does took refers to the execution time of the function? Is the unit in ms?

@ivokub
Copy link
Collaborator

ivokub commented Feb 7, 2025

Hi, the lines:

  • "compiling circuit"
  • "parsed circuit inputs"
  • "building constraint builder"
    are from `frontend.Compile" call

lines:

  • "constraint system solver done"
  • "prover done"
    are from groth16.Prove

and

  • "verifier done"
    is from groth16.Verify

Particularly, proving a SNARK is split into two parts - solving the circuit witness from the initial assignment and computing the SNARK proof.

And the time in took field is indeed in milliseconds (ms).

@TheYangCode
Copy link
Author

Thank you for your response. My further understanding is that if I want to obtain the execution time of the frontend.Compile function and the groth16.Setup function, I can only measure it by myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants