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

Handler (non-pointer) nested structs inside Circuits #169

Closed
gbotrel opened this issue Nov 9, 2021 · 0 comments
Closed

Handler (non-pointer) nested structs inside Circuits #169

gbotrel opened this issue Nov 9, 2021 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@gbotrel
Copy link
Collaborator

gbotrel commented Nov 9, 2021

// Circuit defines a simple circuit
// x**3 + x + 5 == y
type Circuit struct {
	// struct tags on a variable is optional
	// default uses variable name and secret visibility.
	D Data
}

type Data struct {
	X frontend.Variable `gnark:"x"`
	Y frontend.Variable `gnark:",public"`
}

// Define declares the circuit constraints
// x**3 + x + 5 == y
func (circuit Circuit) Define(curveID ecc.ID, api frontend.API) error {
	x3 := api.Mul(circuit.D.X, circuit.D.X, circuit.D.X)
	api.AssertIsEqual(circuit.D.Y, api.Add(x3, circuit.D.X, 5))
	return nil
}

Note the method definition on Circuit, not *Circuit.

The frontend.Compile doesn't allocate Variables correctly in this case.

@gbotrel gbotrel added the bug Something isn't working label Nov 9, 2021
@gbotrel gbotrel added this to the v0.6.0 milestone Nov 9, 2021
@gbotrel gbotrel self-assigned this Nov 9, 2021
gbotrel added a commit that referenced this issue Nov 11, 2021
@gbotrel gbotrel closed this as completed in d3a99c0 Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant