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

Be stricter about ways to create UInt64/32 #1286

Closed
mitschabaude opened this issue Dec 4, 2023 · 3 comments
Closed

Be stricter about ways to create UInt64/32 #1286

mitschabaude opened this issue Dec 4, 2023 · 3 comments
Assignees
Labels
good first issue Good for newcomers zkDSL Issues to improve the core experience of writing circuits

Comments

@mitschabaude
Copy link
Collaborator

mitschabaude commented Dec 4, 2023

Why: Currently, it's very easy to create UInt64 or UInt32 from a Field without range-checking it, without given any hint that this is unsafe. For Bool we do a much better job: the only way to create it from a Field is with Bool.Unsafe.ofField()

How:

  • Remove Field as input type from UInt64.from(). Replace with something like UInt64.Unsafe.fromField()
  • Remove Field as possible constructor input. The tricky thing is that UInt64 really consists of 1 Field, so we need a way to construct it from field at least in internal methods. There are two ways around this:
    • make the constructor take a FieldVar instead of a Field, so that creating it from a Field becomes a less visible and more low-level operation. This is how Bool does it.
    • or make the constructor private externally. This makes the breaking change more breaking though.
@barriebyron
Copy link
Contributor

Please advise @mitschabaude can you help identify the required doc updates?

@mitschabaude
Copy link
Collaborator Author

@barriebyron the UInt64 API changed, so this is about fixing type errors that turn up when switching to the latest o1js version in doc examples

@barriebyron
Copy link
Contributor

Can you help me identify the examples that need updating?

@ymekuria ymekuria self-assigned this Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers zkDSL Issues to improve the core experience of writing circuits
Projects
None yet
Development

No branches or pull requests

3 participants