Wasm Builders 🧱


Posted on

Meal Price Calculator with Python and WASM

One of the primary ideas of the ernax project is the security of the applications, as Mike pointed in one of his posts:

“channels secured with appropriate measures to protect against the risks associated with the security being compromised” .

Many of us have information that we want to communicate that we would prefer others not to see, for all sorts of reasons. Be it payment information, personal information, or work data.

Imagine that you have a chain of restaurants that is growing very fast, to speed up service and improve the performance of your business, you request an application that makes calculations regarding customer expenses. In this application there will be an algorithm with the fee to be charged, the price of each dish, service fees, among other functions.

These functions are set by you, you decide the discount or charge rate, your profit depends on it. But imagine that someone decides to invade your restaurant's system and change the codes, harming your business, this is one of the risks in not having a safe environment to run your application.
Image description

When I was thinking about it, I immediately thought about how the application of wasm and confidential computing can help in many ways, a tool that can be used in many environments, business, research, data consumption, among others.

So I made a small example using python and wasm:
First install the necessary dependencies, the complete tutorial to install the environment can be found in this

link: [https://enarx.dev/docs/WebAssembly/Python]

The code used is:

Image description

Running the python code on wasmtime

-Change directory to the root python-wasi source directory.
-Save the file code source at $HOME/file.py
-Run the python file code in wasmtime using the command

wasmtime run --mapdir=$(pwd)/opt::opt \
-- opt/wasi-python/bin/python3.wasm -c "$(cat $(pwd)/file.py)"

Image description


Top comments (0)