starknet_rust_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-rust-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 blake2s_hash;
25mod ecdsa;
26mod error;
27mod fe_utils;
28mod pedersen_hash;
29mod poseidon_hash;
30mod rfc6979;
31
32#[cfg(test)]
33mod test_utils;
34
35pub use starknet_types_core::felt::Felt;
36
37pub use pedersen_hash::{pedersen_hash, PedersenHasher};
38
39pub use poseidon_hash::{
40    poseidon_hash, poseidon_hash_many, poseidon_hash_single, poseidon_permute_comp, PoseidonHasher,
41};
42
43pub use blake2s_hash::{blake2s_hash, blake2s_hash_many, blake2s_hash_single, Blake2Hasher};
44
45pub use ecdsa::{get_public_key, recover, sign, verify, ExtendedSignature, Signature};
46
47pub use crate::rfc6979::generate_k as rfc6979_generate_k;
48
49pub use error::{RecoverError, SignError, VerifyError};