Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion field/asm/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
element_2w/**
element_3w/**
element_7w/**
element_8w/**
element_8w/**
element_6b/**
2 changes: 1 addition & 1 deletion field/generator/asm/amd64/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func GenerateCommonASM(w io.Writer, nbWords, nbBits int, hasVector bool) error {
f.WriteLn("")

if nbWords == 1 {
if nbBits == 31 {
if nbBits <= 31 {
return GenerateF31ASM(f, hasVector)
} else {
panic("not implemented")
Expand Down
2 changes: 1 addition & 1 deletion field/generator/asm/arm64/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func GenerateCommonASM(w io.Writer, nbWords, nbBits int, hasVector bool) error {
f.WriteLn("")

if nbWords == 1 {
if nbBits == 31 {
if nbBits <= 31 {
return GenerateF31ASM(f, hasVector)
} else {
panic("not implemented")
Expand Down
6 changes: 2 additions & 4 deletions field/generator/config/field_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,8 @@ func NewFieldConfig(packageName, elementName, modulus string, useAddChain bool)
}
// pre compute field constants
F.NbBits = bModulus.BitLen()
// note: here we set F31 only for BabyBear and KoalaBear;
// we could do uint32 bit size for all fields with NbBits <= 31, but we keep it as is for now
// to avoid breaking changes
F.F31 = F.ModulusHex == "7f000001" || F.ModulusHex == "78000001" // F.NbBits <= 31

F.F31 = F.NbBits <= 31
F.NbWords = len(bModulus.Bits())
F.NbWordsLastIndex = F.NbWords - 1

Expand Down
2 changes: 1 addition & 1 deletion field/generator/internal/templates/element/ops_purego.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func MulBy{{$i}}(x *{{$.ElementName}}) {
// works for 0 <= n <= 32.
//
// N.B. n must be < 33.
func (z *Element) Mul2ExpNegN(x *Element, n uint32) *Element {
func (z *{{.ElementName}}) Mul2ExpNegN(x *{{.ElementName}}, n uint32) *{{.ElementName}} {
v := uint64(x[0]) << (32 - n)
z[0] = montReduce(v)
return z
Expand Down
2 changes: 1 addition & 1 deletion field/generator/internal/templates/element/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,7 @@ func Test{{toTitle .ElementName}}Mul2ExpNegN(t *testing.T) {
genA := gen()

properties.Property("x * 2⁻ᵏ == Mul2ExpNegN(x, k) for 0 <= k <= 32", prop.ForAll(
func(a testPairElement) bool {
func(a testPair{{.ElementName}}) bool {

var b, e, two {{.ElementName}}
var c [33]{{.ElementName}}
Expand Down