Giter VIP home page Giter VIP logo

examples's Introduction

Miden Assembly Playground

Playground for example programs for the Miden VM in Miden assembly.

Use the playground!

The goal of this playground is for developers to see how easy it is to write and execute code in Miden assembly. The examples come from the community and the team. If you come up with an example of your own, we are happy to include it in the list below. You can simply open a PR with your example adding the .masm and .inputs files.

Examples are written in Miden assembly, see Miden assembly documentation. External inputs can be provided to the examples and the Miden VM in two ways as public inputs and via the advice provider, see here. Currently, in the playground you can use operand_stack as public input and the advice_stack as secret input.

In addition to running existing examples you can also write your own program and execute it. The examples can then serve as inspiration.


Available examples

There are several examples in our repo and we hope we get more in the future. The examples range from simple to complex and aim to show how Miden assembly can be used.

Simple examples - to see how the code works

  • Comparison: A program which checks if the value provided as secret input via the advice tape is less than 9; if it is, the value is multiplied by 9, otherwise, 9 is added to the value; then we check if the value is odd.

  • Conditional: A program which either adds or multiplies two numbers - 3 and 5 - based on the value provided via the advice tape as secret input.

Math examples - see more complex numerical calculations

  • Collatz: A program which executes an unbounded loop to compute a Collatz sequence which starts with the provided value; the output of the program is the number of steps needed to reach 1 - the end of the sequence.

  • Fibonnacci: Elegant way to calculate the 1001st fibonacci number.

  • nPrime: Program to calculate the n-th prime number. It will return all prime numbers up to the n-th prime number which is on top of the stack.

Complex examples - larger complex nested operations

  • Game-of-Life: Implementation of Conway's Game of Life. But we can prove it. The static example runs on a 4x4 cell universe and 1000 generations.

Running the playground locally

You can also run the playground locally on your machine.

Starting site

If you want to run it locally, then make sure you have the wasm-pack installed.

To run the playground locally in development mode, navigate to the project directory playground and run:

npm run build:miden && npm install && npm run start

Open http://localhost:3000 to view it in the browser.

Test rust code:

cd miden-wasm && wasm-pack test --node

Acknowledgement

We use a fork of https://github.com/timgestson/miden-assembly-playground

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.