Skip to content

Expose no-RNG functions#97

Merged
rozbb merged 12 commits intomainfrom
trycryptorng
Feb 25, 2026
Merged

Expose no-RNG functions#97
rozbb merged 12 commits intomainfrom
trycryptorng

Conversation

@rozbb
Copy link
Owner

@rozbb rozbb commented Feb 19, 2026

Per the discussion in #94, this replaces all functions that take &mut impl CryptoRng with &mut impl TryCryptoRng.
Reverted this. Not confident we need to do this rn.

Also, for ergonomics sake, we rename all the RNG-taking functions to *_with_rng, and make the base function not take any RNG at all, instead using getrandom::SysRng. This required a new getrandom feature.

cc @josh-brown-anchor @tarcieri thoughts?

@tarcieri
Copy link

The pattern of impl'ing APIs that take TryCryptoRng and having a getrandom wrapper is pretty close to what we do in RustCrypto. See also: the Generate trait.

Are you going to want kem to switch to TryCryptoRng too?

@rozbb
Copy link
Owner Author

rozbb commented Feb 19, 2026

Are you going to want kem to switch to TryCryptoRng too?

Ugh I really hate it all, but the pitch for this crate was somewhat convincing.

  1. Everything (except gen_keypair) returns a Result anyway
  2. SysRng is fallible, and people might be using it a lot.

Contradicting (2): the thing most people reach for, I would think, is rand::rng(), which is infallible!

So I'm not so sure anymore. Wdyt @tarcieri

@josh-brown-anchor
Copy link
Contributor

I could go either way on this one. I'll think about it some more this weekend.

@rozbb rozbb changed the title CryptoRng -> TryCryptoRng. Also expose no-RNG functions Expose no-RNG functions Feb 24, 2026
@rozbb
Copy link
Owner Author

rozbb commented Feb 24, 2026

Reverted the Try* traits for now. @josh-brown-anchor good to go? I'll cut a prerelease version today

@josh-brown-anchor
Copy link
Contributor

josh-brown-anchor commented Feb 24, 2026

Apologies for forgetting to respond. Yeah this is probably fine for now. Thank you!

@rozbb rozbb merged commit c39388b into main Feb 25, 2026
29 checks passed
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