Crate starknet_crypto

Source
Expand description

Low-level cryptography utilities for Starknet. Features include:

§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§

ExtendedSignature
Stark ECDSA signature with v, useful for recovering the public key.
Felt
Definition of the Field Element type.
PedersenHasher
A stateful hasher for Starknet Pedersen hash.
PoseidonHasher
A stateful hasher for Starknet Poseidon hash.
Signature
Stark ECDSA signature.

Enums§

RecoverError
Errors when performing ECDSA recover operations.
SignError
Errors when performing ECDSA sign operations.
VerifyError
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 Felts.
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.