17 releases

0.1.7 Oct 4, 2024
0.1.5 Jun 29, 2024
0.0.11 Mar 27, 2024
0.0.5 Dec 22, 2023

#14 in #cairo

Download history 4284/week @ 2024-07-08 5853/week @ 2024-07-15 5775/week @ 2024-07-22 6655/week @ 2024-07-29 6692/week @ 2024-08-05 5803/week @ 2024-08-12 4996/week @ 2024-08-19 5581/week @ 2024-08-26 5312/week @ 2024-09-02 4557/week @ 2024-09-09 11555/week @ 2024-09-16 7410/week @ 2024-09-23 8870/week @ 2024-09-30 16052/week @ 2024-10-07 14049/week @ 2024-10-14 8662/week @ 2024-10-21

48,273 downloads per month
Used in 74 crates (26 directly)

MIT license

120KB
2.5K SLoC

starknet-types-core

Core types representation for Starknet.

Overview

The starknet-types-core crate provides:

  • The universal Felt (Field Element) type for Cairo and STARK proofs. It was created to reduce the fragmentation in the Starknet Rust ecosystem by providing a standardized representation of the Felt type.

Features

Always on

  • Standardized Felt type: Simplify your codebase by using our standardized Felt type. Optimized for performance: The Felt type has been optimized for high-performance applications.
  • No_std support ✅

Serde

  • Provides a Serialization and Deserialization implementations for the Felt type
  • No_std support ✅

Parity Scale Codec

  • Provides Serialization and Deserialization implementations for the Felt type within the Parity serialization framework
  • No_std support ✅

Arbitrary

  • Provides an Arbitrary implementations for the Felt type

Curve

  • Add the AffinePoint and ProjectivePoint structs, which represent points on the Stark curve for performing elliptic curve operations.
  • No_std support ✅

Hash

  • Implements Pedersen hashing for Felts and Felts array

Examples

Here are some examples of how to use the starknet-types-core types:

    let felt = Felt::from(18);
    let projective_point = ProjectivePoint::new(Felt::from(0), Felt::from(1), Felt::from(0));
    let affine_point = AffinePoint::new(Felt::from(0), Felt::from(1)).unwrap();

Usage

Include starknet-types-core in your library by adding the following to your Cargo.toml:

[dependencies]
starknet-types-core = { version = "0.0.3", git = "https://github.com/starknet-io/types-rs", default-features = false, features = [
    "alloc",
    "serde",
    "arbitrary",
    "curve",
    "hash",
] }

Build from source

Clone the repository and navigate to the starknet-types-core directory. Then run:

cargo build --release

Testing

Clone the repository and navigate to the starknet-types-core directory. Then run:

cargo test

Contributing

Contributions are welcome! Please read our contributing guidelines for more information.

License

This repository is licensed under the MIT License, see LICENSE for more information.

Dependencies

~1.3–2.3MB
~48K SLoC