Various Cryptographic Primitives in Sway for the Fuel VM
Testing for the different libraries is done in /testing
. There are instructions in the separate testing folders.
For testing we use fuels
, read about it here.
To run tests for bls folder:
cd testing/tests_bls12_381
forc test
You can use scripts locally to do intermediate tests. To run a script a local Fuel node must be spun up.
From here. In a separate tab in your terminal, spin up a local Fuel node:
fuel-core --db-type in-memory
This starts a Fuel node with a volatile database that will be cleared when shut down (good for testing purposes).
Make sure fuel-core
is up to date. This can be done with fuelup. Also, make sure there's only 1 fuel-core
installed (check this with which -a fuel-core
).
For example in bls12_381/src
create main.sw
. Change in bls12_381/Forc.toml
entry
to main.sw
.
Start the file with script;
and whatever code is in fn main () { .. }
will be executed with the following command:
forc run --unsigned --pretty-print
The --unsigned
part is to avoid signing with a contract. The --pretty-print
is for if you do some logging; it will get printed nicely.
Find all assembly instructions that can be used here.