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

dev: remove custom integer classes #47

Merged
merged 10 commits into from
Apr 25, 2024

Conversation

zmalatrax
Copy link
Collaborator

The use of custom classes to enforce signed and unsigned integers of a certain size reduces the readability of the code.
Plus it doesn't make much sense in TypeScript, it feels like trying to add C/Rust fixed-size integers to Typescript

  • Converting a Felt to number and bigint must be doable:

    • Number(felt) works as expected because toString() is overridden (see javascript object coercition)
    • BigInt(value: string | number | bigint | boolean): bigint has a fixed signature, we must define a method to return the bigint value from Felt, which is done by Felt.toBigInt(): bigint
  • Encoded instructions are defined on 64 bits. We can check that the instruction is indeed a number < $2^{64} - 1$, as in the python VM , or simply ignore the bits > 64. The encoded instruction is decoded with masks, solely working on the 64 LSBs.

  • Values from the encoded instructions are truncated with masks of the expected size, there is no need to check that the offsets etc. are of the right size

  • fromBiased should be a method of Instruction

@ClementWalter ClementWalter merged commit 30563d6 into main Apr 25, 2024
1 check passed
@ClementWalter ClementWalter deleted the feat/remove-custom-integer-types branch April 25, 2024 08:48
@zmalatrax zmalatrax self-assigned this Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants