-
Notifications
You must be signed in to change notification settings - Fork 84
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
The |
Committed. |
seed | ||
} | ||
|
||
public fun bytes_to_u64(bytes: vector<u8>): u64 { |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Summary
Add simple random number generator move module.