starknet_crypto/
lib.rs

1//! Low-level cryptography utilities for Starknet. Features include:
2//!
3//! - ECDSA operations
4//!   - [Signing hashes](fn.sign)
5//!   - [Verifying signatures](fn.verify)
6//!   - [Recovering public keys from signatures](fn.recover)
7//! - [Pedersen hash](fn.pedersen_hash)
8//! - Poseidon hash
9//! - [RFC-6979](fn.rfc6979_generate_k)
10//!
11//! # Warning
12//!
13//! You're advised to use high-level crypto utilities implemented by the `starknet-core` crate if
14//! you're not familiar with cryptographic primitives. Using these low-level functions incorrectly
15//! could result in catastrophic consequences like leaking your private key.
16
17#![deny(missing_docs)]
18#![cfg_attr(not(feature = "std"), no_std)]
19
20#[allow(unused_extern_crates)]
21#[cfg(all(not(feature = "std"), any(test, feature = "alloc")))]
22extern crate alloc;
23
24mod ecdsa;
25mod error;
26mod fe_utils;
27mod pedersen_hash;
28mod poseidon_hash;
29mod rfc6979;
30
31#[cfg(test)]
32mod test_utils;
33
34pub use starknet_types_core::felt::Felt;
35
36pub use pedersen_hash::{pedersen_hash, PedersenHasher};
37
38pub use poseidon_hash::{
39    poseidon_hash, poseidon_hash_many, poseidon_hash_single, poseidon_permute_comp, PoseidonHasher,
40};
41
42pub use ecdsa::{get_public_key, recover, sign, verify, ExtendedSignature, Signature};
43
44pub use crate::rfc6979::generate_k as rfc6979_generate_k;
45
46pub use error::{RecoverError, SignError, VerifyError};