Skip to content

Conversation

@Sc00bz
Copy link
Contributor

@Sc00bz Sc00bz commented Nov 16, 2021

When the modulo is 2^(8*n) (or just above) the probability of success for each attempt is 1/256. This makes the worst case 50%.

@Sc00bz
Copy link
Contributor Author

Sc00bz commented Nov 16, 2021

I don't know why I thought this project preferred a = a & b over the short hand. Also I just realized that doing Limb::random_mod on highest limb is better than the standard way. So the only real fix is for Limb::random_mod and n_limbs = (n_bits + Limb::BIT_SIZE - 1) / Limb::BIT_SIZE. Oh n_limbs.saturating_sub(1) can be n_limbs - 1 since n_limbs > 0 because modulus is NonZero.

Should I do a new pull request but minus all the stupid commits or fix it here?

@tarcieri
Copy link
Member

tarcieri commented Nov 16, 2021

@Sc00bz fixing it here is fine. We use squash and merge anyway.

I don't know why I thought this project preferred a = a & b over the short hand.

Might be because of the code in various *Assign impls, but those can't use the shorthand because it recurses infinitely

@fjarri
Copy link
Contributor

fjarri commented Dec 11, 2022

So, what's the status of this PR? I'd like to see this merged, can I help somehow?

@tarcieri
Copy link
Member

@fjarri looks like it needs a rebase at least

@fjarri fjarri mentioned this pull request Dec 11, 2022
@tarcieri
Copy link
Member

Merged in #146

@tarcieri tarcieri closed this Dec 12, 2022
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