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

Add RandomGenerator to Sui Framework #15019

Merged
merged 17 commits into from
Mar 21, 2024
Merged

Add RandomGenerator to Sui Framework #15019

merged 17 commits into from
Mar 21, 2024

Conversation

benr-ml
Copy link
Contributor

@benr-ml benr-ml commented Nov 23, 2023

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)

  • protocol change
  • user-visible impact
  • breaking change for a client SDKs
  • breaking change for FNs (FN binary must upgrade)
  • 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. 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).

Copy link

vercel bot commented Nov 23, 2023

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

Name Status Preview Comments Updated (UTC)
explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2024 2:37pm
multisig-toolkit ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2024 2:37pm
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2024 2:37pm
sui-core ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2024 2:37pm
sui-kiosk ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2024 2:37pm
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 21, 2024 2:37pm

@benr-ml
Copy link
Contributor Author

benr-ml commented Nov 24, 2023

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.
@jonas-lj , please review the different crypto "conversions".

@kchalkias , @aschran - CCed in case you have comments as well.

Copy link
Contributor

@aschran aschran left a 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

Copy link
Contributor

@dariorussi dariorussi left a 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)

@benr-ml benr-ml merged commit d401430 into main Mar 21, 2024
41 checks passed
@benr-ml benr-ml deleted the ben/randomness branch March 21, 2024 19:54
leecchh pushed a commit that referenced this pull request Mar 27, 2024
## 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.
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.

8 participants