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

jacobi should return Option<isize> instead of isize #34

Open
survived opened this issue May 11, 2023 · 1 comment
Open

jacobi should return Option<isize> instead of isize #34

survived opened this issue May 11, 2023 · 1 comment

Comments

@survived
Copy link
Contributor

jacobi validates input arguments, and if they are invalid, it returns 0 in release build, or panics in debug build. We should rather have jacobi that returns None when provided arguments are invalid. It will help to catch unexpected behavior if it happens.

https://github.com/dfns-labs/paillier-zk/blob/5db04c4a6e36b52656c2ccd9bb9b5dc0fbd66289/src/common/sqrt.rs#L63-L72

@survived
Copy link
Contributor Author

Actually, we may want jacobi to return Result. It would return:

  • Err(Error::InvalidInput) when args are invalid
  • Err(Error::Unreachable) when unreachable! branch is reached.

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