Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[gh-771] support simple on-chain random number. #1052

Merged
merged 7 commits into from
Jul 23, 2024

Conversation

feliciss
Copy link
Collaborator

@feliciss feliciss commented Oct 27, 2023

Summary

Add simple random number generator move module.

@vercel
Copy link

vercel bot commented Oct 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rooch-portal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2024 7:09am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
rooch ⬜️ Ignored (Inspect) Visit Preview Jul 23, 2024 7:09am

@jolestar
Copy link
Contributor

cc @mx819812523 @jojoo-eth

@jolestar
Copy link
Contributor

The frameworks/rooch-framework/doc/simple_rng.md file needs to be committed.

@feliciss
Copy link
Collaborator Author

The frameworks/rooch-framework/doc/simple_rng.md file needs to be committed.

Committed.

seed
}

public fun bytes_to_u64(bytes: vector<u8>): u64 {
Copy link
Collaborator

Choose a reason for hiding this comment

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

From seed to the final random number, is an additional algorithm required to generate it?

vector::append(&mut seed_bytes, tx_hash_bytes);
};

vector::append(&mut seed_bytes, timestamp_ms_bytes);
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the user does not initiate a new transaction, considering that the global timestamp is synchronized from the BTC Block, the interval period is about 10 minutes. During this period, are the seed and random numbers obtained the same every time?

Copy link
Collaborator Author

@feliciss feliciss Jul 23, 2024

Choose a reason for hiding this comment

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

I referred to the description of #771 and have been doing so according to that. If the timestamp and tx hash or tx accumulator root are the same during the interval period, it would be the same random number (if the user does not initiate tx to increase the sequence number). Without additional algorithm, there is no randomness guaranteed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Generating a random number needs a new transaction. That transaction will include the sequencer time and update the timestamp.

@jolestar jolestar merged commit c0a5839 into rooch-network:main Jul 23, 2024
7 checks passed
@feliciss feliciss deleted the #771 branch July 23, 2024 08:51
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.

Simple on-chain Random Number
4 participants