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

adding new primes #222

Open
nickz-t3 opened this issue Nov 30, 2023 · 0 comments
Open

adding new primes #222

nickz-t3 opened this issue Nov 30, 2023 · 0 comments

Comments

@nickz-t3
Copy link

nickz-t3 commented Nov 30, 2023

Hi, I tried to add a prime (PR here).

  1. Better to refactor the code and make the primes an enum types. Then we can use the match statement everywhere we use primes without the "_" in the end. Then adding new primes would feel like a breeze.
  2. Is there a generator for cpp and wasm code_elements? How to launch it? shall we add it to build.rs? it would work well with enum
  3. why is there even a choice here
@@ -850,14 +851,15 @@ pub fn generate_fr_cpp_file(c_folder: &PathBuf, prime: &String) -> std::io::Resu
    let file_name = file_path.to_str().unwrap();
    let mut c_file = BufWriter::new(File::create(file_name).unwrap());
    let mut code = "".to_string();
    let file = match prime.as_ref() {
        "bn128" => include_str!("bn128/fr.cpp"),
        "bls12381" => include_str!("bls12381/fr.cpp"),
        "goldilocks" => include_str!("goldilocks/fr.cpp"),
        "grumpkin" => include_str!("grumpkin/fr.cpp"),
        "pallas" => include_str!("pallas/fr.cpp"),
        "secq256k1" => include_str!("secq256k1/fr.cpp"),
        "vesta" => include_str!("vesta/fr.cpp"),        
        _ => unreachable!(),
    };
    for line in file.lines() {
@@ -893,15 +895,16 @@ pub fn generate_fr_asm_file(c_folder: &PathBuf, prime: &String) -> std::io::Resu
    let file_name = file_path.to_str().unwrap();
    let mut c_file = BufWriter::new(File::create(file_name).unwrap());
    let mut code = "".to_string();
    let file = match prime.as_ref() {
        "bn128" => include_str!("bn128/fr.asm"),
        "bls12381" => include_str!("bls12381/fr.asm"),
        "goldilocks" => include_str!("goldilocks/fr.asm"),
        "grumpkin" => include_str!("grumpkin/fr.asm"),
        "pallas" => include_str!("pallas/fr.asm"),
        "secq256k1" => include_str!("secq256k1/fr.asm"),
        "vesta" => include_str!("vesta/fr.asm"),
        _ => unreachable!(),
    };    

aren't these files all same?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant