cartridge-gg / cairo-webauthn

Cairo verification of webauthn authentication credentials

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cairo-webauthn

A library for webauthn credential authentication. The library is under development.

Project structure

The project consists of several subfolders located in the crates directory:

  • account_sdk - a rust project to export and test functions for interacting with the custom account contract.
  • cartidge_account - a cairo project with a custom account contract.
  • test_gen_scripts - a python library to programatically generate cryptographic cairo tests.
  • webauthn - cairo components to use in contracts.

The project has a global rust workspace.

account_sdk

This is a rust project, that will eventually be compiled to wasm. It's purpose is to export and test functions for interacting with the custom account contract. The testing framework implemented within uses dojo/katana underneath. Each test starts its own katana network, deploys a contract and performs operations on it. Naturally, you must have katana installed to run the tests. You can specify the path to the katana executable in the account_sdk/KatanaConfig.toml file. Note that if you have dojo installed and in PATH the path can remain simply as katana.

Running the tests

To run the tests you first have to compile (to sierra and casm) the contract in the cartidge_account folder:

make

StarkNet Foundry tests:

snforge test -p cartridge_account

Scarb tests:

scarb test -p webauthn_*

After the contract is compiled run the tests using cargo:

cargo test

The scarb builds the contract and saves the compiled code in the cartridge_account/target folder. The tests then fetch (at compile time) the comipled code and deploy it to the local network. Note that obviously the contract needs to be recompiled for any changes to be applied in the compiled code.

src

This is a cairo project with backend methods that will allow for various authentication methods in the custom contact. Written based on this specification.

Running the tests

Some of the tests are auto-generated using python scripts. See the test_gen_scripts for details. The tests in src/tests/ which end in _gen_test.cairo are auto-generated and might be changed by the python script. You can write your tests manually, but make sure the name of the test file doesn't end in _gen_test.cairo, and you place the import "use ...;" below the auto-generated imports in src/tests.cairo.

To run the tests:

scarb test

To again generate the tests:

python test_gen_scripts/main.py

test_gen_scripts

This is a python library to programatically generate cryptographic cairo tests.

Python Enviroment

Use pyenv to have specific version of python easily. We use python3.9

pip install -r requirements.txt
python test_gen_scripts/main.py

About

Cairo verification of webauthn authentication credentials

License:GNU General Public License v3.0


Languages

Language:Cairo 71.3%Language:Rust 18.8%Language:Python 9.8%Language:Makefile 0.2%