crysol
is a collection of pure Solidity libraries providing elliptic curve cryptography for on- and offchain operations.
src
├─ onchain
│ ├─ common
│ │ ├─ Message - "Functionality for constructing Ethereum Signed Message Hashes"
│ │ ├─ Nonce - "Deterministic nonce derivation"
│ │ └─ ModularArithmetic - "Provides modular arithmetic functionality"
│ ├─ secp256k1
│ │ ├─ Secp256k1 - "Cryptography-related functionality for the secp256k1 elliptic curve"
│ │ ├─ Secp256k1Arithmetic — "Arithmetic-related functionality for the secp256k1 elliptic curve"
│ │ └─ signatures
│ │ ├─ ECDSA — "ECDSA signature functionality for secp256k1"
│ │ └─ Schnorr — "Schnorr signature functionality for secp256k1"
│ └─ secp256r1
│ ├─ Secp256r1 - "Cryptography-related functionality for the secp256r1 elliptic curve"
│ └─ Secp256r1Arithmetic — "Arithmetic-related functionality for the secp256r1 elliptic curve"
├─ offchain
│ ├─ common
│ │ └─ RandomOffchain - "Access to cryptographically secure randomness"
│ └─ secp256k1
│ ├─ Secp256k1Offchain - "Cryptography-related functionality for the secp256k1 elliptic curve"
│ └─ signatures
│ ├─ ECDSAOffchain — "ECDSA signature functionality for secp256k1"
│ └─ SchnorrOffchain — "Schnorr signature functionality for secp256k1"
└─ unsafe
└─ secp256k1
└─ signatures
└─ ECDSAUnsafe — "Unsafe ECDSA signature functionality for secp256k1"
Install with Foundry:
$ forge install verklegarden/crysol
Several examples are provided in examples/
, such as:
- secure key pair and Ethereum address generation
- secp256k1 point arithmetic
- Schnorr and ECDSA signature creation and verification
The project uses the Foundry toolchain. You can find installation instructions here.
Setup:
$ git clone https://github.com/verklegarden/crysol
$ cd crysol/
$ forge install
Run tests:
$ forge test
$ forge test -vvvv # Run with full stack traces
$ FOUNDRY_PROFILE=intense forge test # Run in intense mode
Lint:
$ forge fmt [--check]
This is experimental software and is provided on an "as is" and "as available" basis.
We do not give any warranties and will not be liable for any loss incurred through any use of this codebase.