-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Add RandomGenerator to Sui Framework #15019
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
All the interfaces are in. I didn't complete the tests yet but wanted to receive the first round of feedbacks before I add snapshots, etc. @dariorussi , please let me know if the design makes sense, and whether any of the functions better be implemented as native ones. @kchalkias , @aschran - CCed in case you have comments as well. |
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.
interface looks great overall! Just one thought on naming
crates/sui-framework/packages/sui-framework/sources/random.move
Outdated
Show resolved
Hide resolved
crates/sui-framework/packages/sui-framework/sources/random.move
Outdated
Show resolved
Hide resolved
crates/sui-framework/packages/sui-framework/sources/random.move
Outdated
Show resolved
Hide resolved
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.
it looks pretty good to me and let's see what others have to say.
I will come back after we gave more people a chance to review and considering it does not have high pri (having to wait for the PR from @aschran if I got it right)
crates/sui-framework/packages/sui-framework/sources/random.move
Outdated
Show resolved
Hide resolved
crates/sui-framework/packages/sui-framework/sources/random.move
Outdated
Show resolved
Hide resolved
## Description Add interfaces for fetching randomness: `RandomGenerator` is a PRG with a seed that is derived from the global randomness (which is the same between randomness rounds) and a fresh UID (which is guaranteed to be unique by the framework). In other words, the seed is unpredictable without knowing the global randomness, and different for each created generator (thus not predictable even by different functions invoked for the same tx). `RandomGenerator` manages an internal state with a buffer of random bytes derived using the PRG, and provides high level functions for deriving integers from those random bytes. ## Test Plan Unit tests --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [x] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [x] breaking change for FNs (FN binary must upgrade) - [x] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes Add Move interfaces for generating secure random values.
Description
Add interfaces for fetching randomness:
RandomGenerator
is a PRG with a seed that is derived from the global randomness (which is the same between randomness rounds) and a fresh UID (which is guaranteed to be unique by the framework). In other words, the seed is unpredictable without knowing the global randomness, and different for each created generator (thus not predictable even by different functions invoked for the same tx).RandomGenerator
manages an internal state with a buffer of random bytes derived using the PRG, and provides high level functions for deriving integers from those random bytes.Test Plan
Unit tests
If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.
Type of Change (Check all that apply)
Release notes
Add Move interfaces for generating secure random values.
RandomGenerator
is a PRG with a seed that is derived from the global randomness (which is the same between randomness rounds) and a fresh UID (which is guaranteed to be unique by the framework).