-
Notifications
You must be signed in to change notification settings - Fork 9
/
copy.go
32 lines (25 loc) · 843 Bytes
/
copy.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
package gates
import (
"github.com/AlexandreBelling/gnark/frontend"
"github.com/consensys/gnark-crypto/ecc/bn254/fr"
)
// IdentityGate performs a copy of the vL value and ignores the vR value
type IdentityGate struct{}
// ID returns "CopyGate" as an ID for CopyGate
func (c IdentityGate) ID() string { return "CopyGate" }
// Eval returns for a range of inputs
func (c IdentityGate) EvalBatch(res []fr.Element, xs ...[]fr.Element) {
copy(res, xs[0])
}
// Eval returns vL
func (c IdentityGate) Eval(res *fr.Element, xs ...*fr.Element) {
res.Set(xs[0])
}
// GnarkEval performs the copy on gnark variable
func (c IdentityGate) GnarkEval(cs frontend.API, x ...frontend.Variable) frontend.Variable {
return x[0]
}
// Degree returns the Degree of the gate on hL, hR and hPrime
func (c IdentityGate) Degree() (degHPrime int) {
return 1
}