| Crates.io | light-sdk-macros |
| lib.rs | light-sdk-macros |
| version | 0.13.0 |
| created_at | 2024-09-09 18:56:08.695012+00 |
| updated_at | 2025-06-15 21:02:49.356363+00 |
| description | Macros for Programs using the Light SDK for ZK Compression |
| homepage | |
| repository | https://github.com/Lightprotocol/light-protocol |
| max_upload_size | |
| id | 1369678 |
| size | 175,751 |
A collection of procedural macros for the Light Protocol SDK.
The LightHasher derive macro implements cryptographic hashing for struct types,
providing implementations of the ToByteArray and DataHasher traits.
#[hash]: Truncates field data to BN254 field size (for large types)#[skip]: Ignores field during hashing#[derive(LightHasher, Clone)]
pub struct MyNestedStruct {
pub a: i32,
pub b: u32,
#[hash]
pub c: String,
}
#[derive(LightHasher, Clone)]
pub struct MyAccount {
pub a: bool,
pub b: u64,
pub c: MyNestedStruct,
#[hash]
pub d: [u8; 32],
pub f: Option<usize>,
}
RUST_BACKTRACE=1 cargo test
Prints DataHasher::hash() inputs.
This crate includes a comprehensive test suite:
# Run all tests
cargo test
# Run fuzzing tests
cargo test --test hasher_fuzz
cargo test --test fuzz_runner
For deep, comprehensive fuzzing with cargo-fuzz:
# Install cargo-fuzz (requires nightly Rust)
cargo install cargo-fuzz
# Run the structure generator fuzzer (tests runtime behavior)
cargo +nightly fuzz run struct_generation -- -max_total_time=300
# Run the macro input fuzzer (tests parsing various struct definitions)
cargo +nightly fuzz run macro_input -- -max_total_time=300
For more details, see the fuzzing documentation.