Use Struct inside a Struct #122
-
HI. I am trying to building a circuit that can have a variable number of inputs. For example:
type PublicKey = eddsa.PublicKey
type exoticCircuit struct {
quoteQuery frontend.Variable `gnark:",public"`
PublicKeyCpt1 PublicKey `gnark:",public"`
PublicKeyCpt2 PublicKey `gnark:",public"`
PublicKeyCpt3 PublicKey `gnark:",public"`
} My dounbt is: Can I have an array instead of having fixed 3 variables, PublicKeyCpt1, PublicKeyCpt2 and PublicKeyCpt3, I would have only one: PublicKeyCpt PublicKey I tried this code below, but didn't work: type PublicKey = eddsa.PublicKey
type PublicKeyCptArray struct {
PublicKeyCpt []PublicKey
}
type exoticCircuit struct {
quoteQuery frontend.Variable `gnark:",public"`
publicKeyCpt PublicKeyCptArray `gnark:",public"`
} I tried but it is saying invalid operation: cannot index circuit.publicKeyCpt (variable of type PublicKeyCptArray) Sorry, but I am new to Go and I am not sure if it is how gnark is suppose to work or if I am coding it wrong. thanks for the help |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @fosgate29 , in your case since you need only 3 PublicKeys the simplest solution is to write it like this:
Also the fields in the struct Let us know if you still have issues. |
Beta Was this translation helpful? Give feedback.
Hi @fosgate29 ,
in your case since you need only 3 PublicKeys the simplest solution is to write it like this:
Also the fields in the struct
exoticCircuit
must be exported for the circuit to be compiled, to do that make sure the name of the fields start with an upper case.Let us know if you still have issues.