Skip to content

Conversation

@nstilt1
Copy link
Contributor

@nstilt1 nstilt1 commented Jan 12, 2026

It does not build because it requires one change to rand_core#44, and the Cargo.toml needs to be updated.

Changes

fn set_stream(stream_id: S) {
  self.stream = S.into();
  if self.index != 64 {
    // generate_and_set is called, resulting in
    self.block_pos += 4;
    self.index = self.index; // no change to the index, but change to the block_pos
  }
}
    • I had a test that had repeated set_stream() calls and the only way to replicate it was to manually find the word_pos that resulted from each call. We can remove this test or at the very least reduce the test, since I had to add more assertions to figure out what was going on in the previous implementation.
  • Update get_block_pos() to return the current block_pos instead of returning block_pos + 4 due to generate() calls incrementing the pos by 4.
    • This is not a breaking change since get_block_pos() was not implemented for rand_chacha, but it is a breaking change for anyone who was using get_block_pos() from the prerelease versions.
  • Update docs to explain that set_stream() nullifies any calls made to set_word_pos() or set_block_pos().

Regarding #438

@nstilt1 nstilt1 marked this pull request as draft January 12, 2026 18:57
@baloo
Copy link
Member

baloo commented Jan 19, 2026

rand_core 0.10.0-rc-4 released this morning, any chance to get this out of draft status?

@tarcieri
Copy link
Member

I can look shortly

@dhardy
Copy link
Contributor

dhardy commented Jan 19, 2026

@baloo you mean this evening!

See rust-random/rand#1712. I'll try to resolve the rand_chacha test failure in the morning, though I think you already did for chacha20.

@baloo
Copy link
Member

baloo commented Jan 19, 2026

That was more directed towards @nstilt1

I'd be happy to take over to adjust the rand_core pin, otherwise I think this is ready to go.
I'd prefer to preserve @nstilt1 authorship and I can't do that easily. You can probably push over to his branch as a collaborator and then merge.

@baloo
Copy link
Member

baloo commented Jan 19, 2026

If you take the last commit from #502, and push it over their branch, I think it's ready to merge (and that could probably use an rc-release after that)

@nstilt1
Copy link
Contributor Author

nstilt1 commented Jan 19, 2026

I am here. But I see there were some changes involving a TryRngCore trait

@tarcieri
Copy link
Member

@nstilt1 I believe you just need to impl TryRngCore<Error = Infallible>, but maybe @dhardy can inform better

@nstilt1
Copy link
Contributor Author

nstilt1 commented Jan 19, 2026

I still want to clean up that test where I did a bunch of manual debugging when troubleshooting set_stream. It looks gross and should be able to have a lot of assertions to be safely removed

@baloo
Copy link
Member

baloo commented Jan 19, 2026

@nstilt1 nstilt1#9 should have everything you need for the trait update.

@nstilt1
Copy link
Contributor Author

nstilt1 commented Jan 19, 2026

Thanks. I was working on it but found that one of the tests had a (very minor) breaking change. I've never used trait objects in that manner and it has an easy fix, but I'm also pretty sure that the trait objects test is pretty new anyway

chore(deps): bump `rand_core` to `0.10.0-rc-4`
@tarcieri
Copy link
Member

It'd be great if we can get something out quickly as this blocks updating everything else.

(I also have a green branch locally as it were, based on @nstilt1's, but I feel like I'm duplicating effort here)

@tarcieri tarcieri changed the title chacha20 - rng - rand_core preview, minor set_stream() change and get_block_pos() change chacha20: rand_core v0.10.0-rc.4 + set_stream()/get_block_pos() change Jan 19, 2026
@tarcieri tarcieri marked this pull request as ready for review January 19, 2026 20:13
Copy link
Member

@tarcieri tarcieri left a comment

Choose a reason for hiding this comment

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

Gonna release this since we use chacha20 as a dependency in several places

@tarcieri tarcieri merged commit 00dc865 into RustCrypto:master Jan 19, 2026
55 checks passed
@nstilt1
Copy link
Contributor Author

nstilt1 commented Jan 19, 2026

Okay. Gonna get started on #476

@tarcieri
Copy link
Member

@nstilt1 sweet, thanks!

@tarcieri
Copy link
Member

It's released: https://crates.io/crates/chacha20/0.10.0-rc.7

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.

4 participants