Files
lattice/circuits/common/polynomial/polynomial_evaluator_sim.go
zeekay eaf864890e feat: release v7.0.0 with GPU acceleration and module update
- Update module path to github.com/luxfi/lattice/v7
- Add GPU acceleration with Metal (macOS) and CUDA backends
- Enhance threshold FHE operations
- Revert to vanilla Apache 2.0 license (remove tfhe)
- Update Go version to 1.25.5
- Merge upstream lattigo improvements
2025-12-30 15:37:37 -08:00

39 lines
1.0 KiB
Go

package polynomial
import "github.com/luxfi/lattice/v7/core/rlwe"
// SimOperand is a dummy operand that
// only stores its level and scale.
type SimOperand struct {
Level int
Scale rlwe.Scale
}
// SimEvaluator defines a set of method on SimOperands.
type SimEvaluator interface {
MulNew(op0, op1 *SimOperand) *SimOperand
Rescale(op0 *SimOperand)
PolynomialDepth(degree int) int
UpdateLevelAndScaleGiantStep(lead bool, tLevelOld int, tScaleOld, xPowScale rlwe.Scale) (tLevelNew int, tScaleNew rlwe.Scale)
UpdateLevelAndScaleBabyStep(lead bool, tLevelOld int, tScaleOld rlwe.Scale) (tLevelNew int, tScaleNew rlwe.Scale)
}
// SimPowerBasis is a map storing powers of SimOperands indexed by their power.
type SimPowerBasis map[int]*SimOperand
// GenPower populates the target SimPowerBasis with the nth power.
func (d SimPowerBasis) GenPower(params rlwe.ParameterProvider, n int, eval SimEvaluator) {
if n < 2 {
return
}
a, b := SplitDegree(n)
d.GenPower(params, a, eval)
d.GenPower(params, b, eval)
d[n] = eval.MulNew(d[a], d[b])
eval.Rescale(d[n])
}