MCPcopy Create free account
hub / github.com/PolyhedraZK/ExpanderCompilerCollection / Mul

Method Mul

ecgo/builder/api.go:111–132  ·  view source on GitHub ↗

Mul computes the product of the given variables.

(i1, i2 frontend.Variable, in ...frontend.Variable)

Source from the content-addressed store, hash-verified

109
110// Mul computes the product of the given variables.
111func (builder *builder) Mul(i1, i2 frontend.Variable, in ...frontend.Variable) frontend.Variable {
112 vars := builder.toVariableIds(append([]frontend.Variable{i1, i2}, in...)...)
113 allConst := true
114 if sum, ok := builder.constantValue(vars[0]); ok {
115 for _, x := range vars[1:] {
116 if v, ok := builder.constantValue(x); ok {
117 sum = builder.field.Mul(sum, v)
118 } else {
119 allConst = false
120 break
121 }
122 }
123 if allConst {
124 return builder.toVariable(sum)
125 }
126 }
127 builder.instructions = append(builder.instructions, irsource.Instruction{
128 Type: irsource.Mul,
129 Inputs: vars,
130 })
131 return builder.addVar()
132}
133
134// DivUnchecked returns i1 divided by i2 and returns 0 if both i1 and i2 are zero.
135func (builder *builder) DivUnchecked(i1, i2 frontend.Variable) frontend.Variable {

Callers 15

MulAccMethod · 0.95
SelectMethod · 0.95
Lookup2Method · 0.95
AssertIsCrumbMethod · 0.95
mustBeLessOrEqVarMethod · 0.95
MustBeLessOrEqCstMethod · 0.95
randomCircuitMethod · 0.45
randomEvalMethod · 0.45
applyCircuitFunction · 0.45
AddMethod · 0.45
GetColumnRandomnessFunction · 0.45
CombineColumnFunction · 0.45

Calls 4

toVariableIdsMethod · 0.95
constantValueMethod · 0.95
toVariableMethod · 0.95
addVarMethod · 0.95

Tested by

no test coverage detected