Files
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

34 lines
647 B
Go

package rlwe
import (
"math"
"github.com/luxfi/lattice/v7/ring"
)
type Distribution struct {
ring.DistributionParameters
Std float64
AbsBound float64
}
func NewDistribution(params ring.DistributionParameters, logN int) (d Distribution) {
d.DistributionParameters = params
switch params := params.(type) {
case ring.DiscreteGaussian:
d.Std = params.Sigma
d.AbsBound = params.Bound
case ring.Ternary:
if params.P != 0 {
d.Std = math.Sqrt(1 - params.P)
} else {
d.Std = math.Sqrt(float64(params.H) / (math.Exp2(float64(logN)) - 1))
}
d.AbsBound = 1
default:
// Sanity check
panic("invalid dist")
}
return
}