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

to_bytes unimplemented for pasta field types #181

Open
srinathsetty opened this issue Dec 18, 2024 · 3 comments
Open

to_bytes unimplemented for pasta field types #181

srinathsetty opened this issue Dec 18, 2024 · 3 comments
Assignees

Comments

@srinathsetty
Copy link

srinathsetty commented Dec 18, 2024

Fp types in secp256k1 and pasta are implemented similarly using the same macro:

However, to_bytes is implemented for secp256k1's Fp but not for pasta's Fp. Is there a reason for this? To illustrate this consider the following example that fails to build.

use halo2curves::{
  pasta::Fp as PallasScalar,
  secp256k1::Fp as SecpScalar,
};

fn main() {
  let pallas_scalar = PallasScalar::from(42);
  let secp_scalar = SecpScalar::from(42);

  println!("pallas scalar: {:?}", pallas_scalar);
  println!("secp scalar: {:?}", secp_scalar);

  println!("pallas scalar: {:?}", pallas_scalar.to_bytes());
  println!("secp scalar: {:?}", secp_scalar.to_bytes());
}

To avoid this discrepancy, a pending PR on Nova uses a hack:

We would like to avoid this hack and use a uniform implementation. Can you help?

@davidnevadoc davidnevadoc self-assigned this Dec 18, 2024
@davidnevadoc
Copy link
Contributor

Removing the pasta re-export and implementing it directly seems to have solved the issue (#180) .

Upgrading the halo2curves dependency to v0.7.1 should be enough to get rid of the hack 👍
Let me know if that works @srinathsetty

@srinathsetty
Copy link
Author

Thanks @davidnevadoc for the quick response! I could point my Cargo.toml to the halo2curves github repo and I was able to get rid of the hack.

However, on crates.io and in the halo2curves repo, I only see version 0.7.0. Do you plan to publish 0.7.1 soon?

Also, there's a typo here:

PastaAffine,
(it should be PallasAffine rather than PastaAffine to keep the naming consistent).

@davidnevadoc
Copy link
Contributor

You're right!
I'll get that fixed and publish the release in crates.io before EOW.

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

2 participants