Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(collator): add seqno to rand seed #306

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

serejkaaa512
Copy link
Contributor

No description provided.

collator/src/collator/do_collate.rs Outdated Show resolved Hide resolved
@@ -76,7 +76,12 @@ impl CollatorStdImpl {
// TODO: need to generate unique for each block
// generate seed from the chain_time from the anchor
let hash_bytes = sha2::Sha256::digest(next_chain_time.to_be_bytes());
let rand_seed = HashBytes::from_slice(hash_bytes.as_slice());
let seqno = working_state.next_block_id_short.seqno.to_be_bytes();
Copy link
Member

@Rexagon Rexagon Sep 12, 2024

Choose a reason for hiding this comment

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

Compute a hash from (next_chain_time, seqno, ...other_things) instead of combining values with hash. It must not lose any entropy! Here the last bytes are just a number => less entropy than hash

Copy link
Member

Choose a reason for hiding this comment

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

You can define a new struct with TlWrite derive and use it as a source for hasher

@serejkaaa512 serejkaaa512 force-pushed the feature/rand-seed branch 2 times, most recently from fc2c1d6 to 77c830c Compare September 12, 2024 13:51
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants