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

feat: add is-prime example #420

Merged
merged 1 commit into from
Mar 4, 2025

Conversation

partylikeits1983
Copy link
Contributor

Adding a basic example of computing wether or not an integer is prime or not. I tested the function with values from this website: https://www.math.utah.edu/~pa/MDS/primes.html

For comparison, I tried running SP1's example for proving if the number $$29$$ is prime or not. top said my CPU usage was 1000%. After a few minutes of the program running and the fans turning on my MBP M2, I decided to kill the program.

Using the Miden compiler, proving that the number $$2147482583$$ is prime is near instant on the same computer.

Comment on lines +11 to +13
```bash
midenc run target/miden/release/is_prime.masp --inputs inputs.toml
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just executes the program (rather than execute & prove), right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, midenc run only executes the program and does not generate a proof. Since comparing our performance to other VMs would be a frequent case, should we add a command to midenc to execute and generate a proof?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do this, but I wonder if it may be better to just add support for working with .masp files in miden-vm. It should be simple enough and wouldn't require re-implementing a bunch of other functionality here (e.g., analyze, debug, etc. commands).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, my preference would be to support Miden packages in the VM proper, the need for midenc run is basically one of temporary necessity.

Copy link
Contributor

@greenhat greenhat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! Thank you very much! Just a minor nit.

@bitwalker bitwalker dismissed greenhat’s stale review March 4, 2025 15:58

The requested change has been resolved

@bitwalker bitwalker merged commit 79f0fb7 into 0xPolygonMiden:next Mar 4, 2025
6 checks passed
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.

4 participants