forked from NethermindEth/starknet.go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
opts.go
38 lines (31 loc) · 817 Bytes
/
opts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package caigo
type curveOptions struct {
initConstants bool
paramsPath string
}
// funcCurveOptions wraps a function that modifies curveOptions into an
// implementation of the CurveOption interface.
type funcCurveOption struct {
f func(*curveOptions)
}
func (fso *funcCurveOption) apply(do *curveOptions) {
fso.f(do)
}
func newFuncCurveOption(f func(*curveOptions)) *funcCurveOption {
return &funcCurveOption{
f: f,
}
}
type CurveOption interface {
apply(*curveOptions)
}
// functions that require pedersen hashes must be run on
// a curve initialized with constant points
func WithConstants(paramsPath ...string) CurveOption {
return newFuncCurveOption(func(o *curveOptions) {
o.initConstants = true
if len(paramsPath) == 1 && paramsPath[0] != "" {
o.paramsPath = paramsPath[0]
}
})
}