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

Support random API from the Anoma stdlib #3129

Merged
merged 11 commits into from
Oct 29, 2024
Merged

Support random API from the Anoma stdlib #3129

merged 11 commits into from
Oct 29, 2024

Conversation

paulcadman
Copy link
Collaborator

@paulcadman paulcadman commented Oct 28, 2024

This PR adds frontend support for the Anoma Random API:

The frontend builtin APIs are:

builtin anoma-random-generator
axiom RandomGenerator : Type;

builtin anoma-random-generator-init
axiom randomGeneratorInit : Nat -> RandomGenerator;

builtin anoma-random-generator-split
axiom randomGeneratorSplit : RandomGenerator
  -> Pair RandomGenerator RandomGenerator;

builtin anoma-random-next-bytes
axiom randomNextBytes : Nat
  -> RandomGenerator
  -> Pair ByteArray RandomGenerator;

Nockma Evaluator

The Nockma evaluator intercepts the corresponding Anoma random stdlib calls using the System.Random API. The implementation uses the splitmix generator directly because it has an API to destructure the generator into a pair of integers. We can use this to serialise the generator.

@paulcadman paulcadman self-assigned this Oct 28, 2024
@paulcadman paulcadman marked this pull request as ready for review October 29, 2024 11:32
@paulcadman paulcadman added this to the 0.6.7 milestone Oct 29, 2024
@paulcadman paulcadman merged commit 3b34f6e into main Oct 29, 2024
4 checks passed
@paulcadman paulcadman deleted the nock-random branch October 29, 2024 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a randomBytes builtin to generate cryptographically secure bytes
2 participants