Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: smallfield solver #1341

Draft
wants to merge 21 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 18 additions & 3 deletions backend/witness/vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
fr_bn254 "github.com/consensys/gnark-crypto/ecc/bn254/fr"
fr_bw6633 "github.com/consensys/gnark-crypto/ecc/bw6-633/fr"
fr_bw6761 "github.com/consensys/gnark-crypto/ecc/bw6-761/fr"
"github.com/consensys/gnark/internal/tinyfield"
"github.com/consensys/gnark/internal/smallfields/babybear"
"github.com/consensys/gnark/internal/smallfields/tinyfield"
"github.com/consensys/gnark/internal/utils"
)

Expand All @@ -37,9 +38,11 @@ func newVector(field *big.Int, size int) (any, error) {
default:
if field.Cmp(tinyfield.Modulus()) == 0 {
return make(tinyfield.Vector, size), nil
} else {
return nil, errors.New("unsupported modulus")
}
if field.Cmp(babybear.Modulus()) == 0 {
return make(babybear.Vector, size), nil
}
return nil, errors.New("unsupported modulus")
}
}

Expand Down Expand Up @@ -77,6 +80,10 @@ func newFrom(from any, n int) (any, error) {
a := make(tinyfield.Vector, n)
copy(a, wt)
return a, nil
case babybear.Vector:
a := make(babybear.Vector, n)
copy(a, wt)
return a, nil
default:
return nil, errors.New("unsupported modulus")
}
Expand Down Expand Up @@ -155,6 +162,12 @@ func set(v any, index int, value any) error {
}
_, err := pv[index].SetInterface(value)
return err
case babybear.Vector:
if index >= len(pv) {
return errors.New("out of bounds")
}
_, err := pv[index].SetInterface(value)
return err
default:
panic("invalid input")
}
Expand Down Expand Up @@ -243,6 +256,8 @@ func resize(v any, n int) any {
return make(fr_bw6633.Vector, n)
case tinyfield.Vector:
return make(tinyfield.Vector, n)
case babybear.Vector:
return make(babybear.Vector, n)
default:
panic("invalid input")
}
Expand Down
2 changes: 1 addition & 1 deletion backend/witness/witness.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import (
fr_bw6761 "github.com/consensys/gnark-crypto/ecc/bw6-761/fr"
"github.com/consensys/gnark/debug"
"github.com/consensys/gnark/frontend/schema"
"github.com/consensys/gnark/internal/tinyfield"
"github.com/consensys/gnark/internal/smallfields/tinyfield"
)

var ErrInvalidWitness = errors.New("invalid witness")
Expand Down
230 changes: 230 additions & 0 deletions constraint/babybear/coeff.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

101 changes: 101 additions & 0 deletions constraint/babybear/marshal.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading