Expand description
Low-level cryptography utilities for Starknet. Features include:
- ECDSA operations
- Pedersen hash
- Poseidon hash
- RFC-6979
§Warning
You’re advised to use high-level crypto utilities implemented by the starknet-core
crate if
you’re not familiar with cryptographic primitives. Using these low-level functions incorrectly
could result in catastrophic consequences like leaking your private key.
Structs§
- Extended
Signature - Stark ECDSA signature with
v
, useful for recovering the public key. - Felt
- Definition of the Field Element type.
- Pedersen
Hasher - A stateful hasher for Starknet Pedersen hash.
- Poseidon
Hasher - A stateful hasher for Starknet Poseidon hash.
- Signature
- Stark ECDSA signature.
Enums§
- Recover
Error - Errors when performing ECDSA
recover
operations. - Sign
Error - Errors when performing ECDSA
sign
operations. - Verify
Error - Errors when performing ECDSA
verify
operations.
Functions§
- get_
public_ key - Computes the public key given a Stark private key.
- pedersen_
hash - Computes the Starkware version of the Pedersen hash of x and y. All inputs are little-endian.
- poseidon_
hash - Computes the Starknet Poseidon hash of x and y.
- poseidon_
hash_ many - Computes the Starknet Poseidon hash of an arbitrary number of
Felt
s. - poseidon_
hash_ single - Computes the Starknet Poseidon hash of a single
Felt
. - poseidon_
permute_ comp - Poseidon permutation function.
- recover
- Recovers the public key from a message and (r, s, v) signature parameters
- rfc6979_
generate_ k - Deterministically generate ephemeral scalar
k
based on RFC 6979. - sign
- Computes ECDSA signature given a Stark private key and message hash.
- verify
- Verifies if a signature is valid over a message hash given a public key. Returns an error
instead of
false
if the public key is invalid.