Skip to content

Custom aos module adding secp256k1 library support for ECDSA signature verification

License

Notifications You must be signed in to change notification settings

vleipnik/aos-secp256k1

Repository files navigation

AOS-secp256k1

AOS-secp256k1 combines the ao operating system module and secp256k1 to create an ao custom module that enables ECDSA verifications. It leverages a battle-tested and highly optimized secp256k1 library. Some of this work is inspired by the AOS-SQLite module by @elliotsayes.

AOS-secp256k1 Module - IlqppmLdIBssZtmY5TlPwTzFUZLkDEhT7aaqoyCrw3A

Run a secp256k1 module with AOS(WASM64)

Spawn a process via aos CLI

aos my-secp256k1 --module=IlqppmLdIBssZtmY5TlPwTzFUZLkDEhT7aaqoyCrw3A

OR spawn a process via aos console

Spawn('IlqppmLdIBssZtmY5TlPwTzFUZLkDEhT7aaqoyCrw3A', { Data = "Hello secp256k1 Wasm64" })

Sample Usage

With the local sample.lua file, add event-handling logic to your process via aos console:

.load sample.lua

Now you can send sample inputs via messages.

A valid signature example:

Send({ Target='<your process ID>', Action='VerifySig', Data={ message='hello', signature='3045022100a71d86190354d64e5b3eb2bd656313422cdf7def69bf3669cdbfd09a9162c96e0220713b81f3440bff0b639d2f29b2c48494b812fa89b754b7b6cdc9eaa8027cf369', public_key='02477ce3b986ab14d123d6c4167b085f4d08c1569963a0201b2ffc7d9d6086d2f3' } })

An invalid signature example:

Send({ Target='<your process ID>', Action='VerifySig', Data={ message='bai', signature='3045022100a71d86190354d64e5b3eb2bd656313422cdf7def69bf3669cdbfd09a9162c96e0220713b81f3440bff0b639d2f29b2c48494b812fa89b754b7b6cdc9eaa8027cf369', public_key='02477ce3b986ab14d123d6c4167b085f4d08c1569963a0201b2ffc7d9d6086d2f3' } }

Valid JWT examples:

Send({ Target='<your process ID>', Action='VerifyJwt', Data='eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIl0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7InlvdSI6IlJvY2sifX0sInN1YiI6ImRpZDp3ZWI6ZXhhbXBsZS5jb20iLCJuYmYiOjE3MzQwMjgzMjIsImlzcyI6ImRpZDpldGhyOnNlcG9saWE6MHgwMmM2M2VmZTNkYzcwN2Y2ZTNkMzIzZjExZTQwY2YwNzU3OGIyYWI5YWVlMTYzNWU2ZWU2NzZmNmRhMDlmMTU5OGQifQ.VEHlsQ7rF5Z5lDuQPZjSp2Tsd-QM0tSB5SWBmE_jZpobbzDaKg1GPoAtZLBeoWwdNfjTxiyhyY08iYw3mCV4rg' })
Send({ Target='<your process ID>', Action='VerifyJwt', Data='eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIl0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7InlvdSI6IlJvY2sifX0sInN1YiI6ImRpZDp3ZWI6ZXhhbXBsZS5jb20iLCJuYmYiOjE3MzQwMjg3ODAsImlzcyI6ImRpZDpldGhyOnNlcG9saWE6MHgwMmM2M2VmZTNkYzcwN2Y2ZTNkMzIzZjExZTQwY2YwNzU3OGIyYWI5YWVlMTYzNWU2ZWU2NzZmNmRhMDlmMTU5OGQifQ.VEHlsQ7rF5Z5lDuQPZjSp2Tsd-QM0tSB5SWBmE_jZppghPpee_pZyzigqsUCeWV9J0rt8SI2oS7uhjm1JaLrww' })

An invalid JWT example:

Send({ Target='<your process ID>', Action='VerifyJwt', Data='eyJhbGciOiJFUzI1NksiLCJ0eXAiOiJKV1QifQ.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJ0eXBlIjpbIlZlcmlmaWFibGVDcmVkZW50aWFsIl0sImNyZWRlbnRpYWxTdWJqZWN0Ijp7InlvdSI6IlJvY2tzb3JzIn19LCJzdWIiOiJkaWQ6d2ViOmV4YW1wbGUuY29tIiwibmJmIjoxNzM0MDI4MzIyLCJpc3MiOiJkaWQ6ZXRocjpzZXBvbGlhOjB4MDJjNjNlZmUzZGM3MDdmNmUzZDMyM2YxMWU0MGNmMDc1NzhiMmFiOWFlZTE2MzVlNmVlNjc2ZjZkYTA5ZjE1OThkIn0=.VEHlsQ7rF5Z5lDuQPZjSp2Tsd-QM0tSB5SWBmE_jZpobbzDaKg1GPoAtZLBeoWwdNfjTxiyhyY08iYw3mCV4rg' })

AO Resources


This project builds the AOS-secp256k1 WASM Binary and Publishes it to Arweave.

Build Process

  1. Fetch the submodules
git submodule init
git submodule update --remote
cd ao-secp256k1/dev-cli/container
git submodule init
git submodule update --remote
cd ../../..
  1. Build docker image
cd ao-secp256k1/dev-cli/container
docker build --progress=plain . -t p3rmaw3b/ao --platform linux/arm64
cd ../../..
  1. Use docker image to compile process.wasm
cd aos/process
docker run --platform linux/arm64 -v .:/src p3rmaw3b/ao ao-build-module
cd ../..
  1. Publish Module with tags via Turbo

You will need a funded wallet for this step. You can add Winc tokens for the Turbo app to do this.

npm install
export WALLET=~/.wallet.json
npm run deploy

About

Custom aos module adding secp256k1 library support for ECDSA signature verification

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published