Skip to content

Commit

Permalink
docs(frontend): unify docs for options
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokub committed Jan 13, 2022
1 parent c367ef9 commit bfd9393
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions frontend/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,32 +135,43 @@ func bootstrap(builder Builder, circuit Circuit) (err error) {
return
}

// CompileOption defines option for altering the behaviour of the Compile
// method. See the descriptions of the functions returning instances of this
// type for available options.
type CompileOption func(opt *compileConfig) error

// CompileOption enables to set optional argument to call of frontend.Compile()
type compileConfig struct {
capacity int
ignoreUnconstrainedInputs bool
newBuilder NewBuilder
}

// WithOutput is a Compile option that specifies the estimated capacity needed for internal variables and constraints
// WithCapacity is a compile option that specifies the estimated capacity needed
// for internal variables and constraints. If not set, then the initial capacity
// is 0 and is dynamically allocated as needed.
func WithCapacity(capacity int) CompileOption {
return func(opt *compileConfig) error {
opt.capacity = capacity
return nil
}
}

// IgnoreUnconstrainedInputs when set, the Compile function doesn't check for unconstrained inputs
// IgnoreUnconstrainedInputs is a compile option which allow compiling input
// circuits where not all inputs are not constrained. If not set, then the
// compiler returns an error if there exists an unconstrained input.
//
// This option is useful for debugging circuits, but should not be used in
// production settings as it means that there is a potential error in the
// circuit definition or that it is possible to optimize witness size.
func IgnoreUnconstrainedInputs() CompileOption {
return func(opt *compileConfig) error {
opt.ignoreUnconstrainedInputs = true
return nil
}
}

// WithBuilder enables the compiler to build the constraint system with a user-defined builder
// WithBuilder is a compile option which enables the compiler to build the
// constraint system with a user-defined builder.
//
// /!\ This is highly experimental and may change in upcoming releases /!\
func WithBuilder(builder NewBuilder) CompileOption {
Expand Down

0 comments on commit bfd9393

Please sign in to comment.