ECDSA, Schnorr & EdDSA Signatures
All three signature schemes follow a similar pattern with a Cairo struct containing the signature data and hints for efficient verification. Garaga provides tooling in Python/Rust/JavaScript to generate the full expected Cairo struct given signature information.
All signature verification schemes work with all Supported Elliptic Curves in Garaga (except EdDSA which is specific to Ed25519), using the corresponding curve identifier.
Cairo Verification Functions
Verification functions take the public key as a separate parameter:
is_valid_ecdsa_signature_assuming_hash(signature, public_key, curve_id) -> boolis_valid_schnorr_signature_assuming_hash(signature, public_key, curve_id) -> boolis_valid_eddsa_signature(signature, Py_twisted) -> bool
Important: The ECDSA and Schnorr verification functions assume that the message hash has been correctly computed by the caller. They verify the signature equation but do not hash the message themselves.
Public Key Handling
The public key is always passed as a separate parameter to the verification function. This allows you to:
Hardcode the public key in your contract if it's known at compile time
Provide the public key dynamically at runtime
When generating calldata with the SDK, use the prepend_public_key parameter:
prepend_public_key=True(default): The public key is included in the serialized calldata, allowing you to deserialize both the signature and public key from the same arrayprepend_public_key=False: Only the signature is serialized; you must provide the public key separately (useful when the public key is hardcoded in your contract)
ECDSA Signature Verification
Cairo Structs
Usage Example
Calldata Generation
Schnorr Signature Verification
Cairo Structs
Usage Example
Calldata Generation
EdDSA Signature Verification (Ed25519)
EdDSA signatures use the Ed25519 curve following RFC 8032. The implementation explicitly rejects small-order points to prevent key-compromise and signature-malleability attacks.
Cairo Structs
Usage Example
Calldata Generation
Curve Identifiers
BN254
0
-
BLS12_381
1
-
SECP256K1
2
Bitcoin/Ethereum
SECP256R1
3
P-256/NIST
ED25519
4
Only for EdDSA
GRUMPKIN
5
-
Last updated
Was this helpful?