Documentation
¶
Overview ¶
Package generator provides a wrapper around the internal field generator.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶ added in v0.20.0
Generate generates arithmetic operations for a given modulus.
Example ¶
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/consensys/gnark-crypto/field/generator"
)
func main() {
// Define the field parameters
packageName := "goldilocks"
elementName := "Element"
modulus := "0xffffffff00000001"
outputDir := filepath.Join(os.TempDir(), "gnark-crypto-field-gen")
// Ensure output directory exists
_ = os.MkdirAll(outputDir, 0755)
defer os.RemoveAll(outputDir)
// Generate the field arithmetic code
err := generator.Generate(packageName, elementName, modulus, outputDir,
generator.WithASM(filepath.Join(outputDir, "asm"), "asm"),
)
if err != nil {
fmt.Printf("failed to generate field: %v\n", err)
return
}
fmt.Println("successfully generated field arithmetic code")
}
Output:
Types ¶
type Option ¶ added in v0.15.0
type Option func(*options)
Option is a functional option for the generator.
func WithASM ¶ added in v0.15.0
WithASM enables assembly code generation. buildDir is the destination path to create output files. includeDir is the directory name to include in the generated files.
func WithAddChain ¶ added in v0.20.0
func WithAddChain() Option
WithAddChain enables the use of addition chains for inversion.
func WithExtensions ¶ added in v0.17.0
func WithExtensions() Option
WithExtensions enables field extensions code generation.
func WithFFT ¶ added in v0.15.0
func WithFFT(generatorFullMultiplicativeGroup uint64, generatorMaxTwoAdicSubgroup string, logTwoOrderMaxTwoAdicSubgroup string) Option
WithFFT enables FFT code generation.
func WithPoseidon2 ¶ added in v0.17.0
func WithPoseidon2() Option
WithPoseidon2 enables Poseidon2 code generation.
Click to show internal directories.
Click to hide internal directories.