Skip to content

Conversation

@LLFourn
Copy link
Owner

@LLFourn LLFourn commented Sep 5, 2025

Adds that fails when the input is zero, with a proper error type.

- Add ZeroScalar error type for when converting zero to NonZero
- Implement TryFrom<integer> for Scalar<S, NonZero> that fails on zero
- Keep existing infallible From<integer> for Scalar<S, Zero>
- Add comprehensive test coverage for the new conversions
let scalar = Scalar::<S, Zero>::from_bytes(bytes).unwrap();

// Check if value is zero
if value == 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could check this first for an early return before doing the computation. Maybe negligible, and maybe the compiler would optimize this

@LLFourn LLFourn merged commit db463d8 into master Nov 19, 2025
16 checks passed
@LLFourn LLFourn deleted the more-try-from branch November 19, 2025 04:07
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

Successfully merging this pull request may close these issues.

3 participants