Light Protocol ZK Compression

repository·main·Indexed 43 days ago

https://github.com/lightprotocol/light-protocol

A ZK Compression protocol for Solana that enables the creation of rent-free tokens and PDAs using zero-knowledge proofs. It includes the @lightprotocol/zk-compression-cli (v0.28.3) for managing compressed mints and SOL, an Anchor wrapper for the Light System Program, and Forester, a service for processing queued Merkle tree updates.

Tokens
127.5K
Snippets
265
Records
521
Agent score
53%

What's inside Light Protocol

  1. Overview of Light Compressed Token SDK

    main

    The Light Compressed Token SDK is a low-level SDK designed for performing compressed token operations on Light Protocol. It provides the fundamental building blocks for managing compressed token accounts, including instruction builders for minting, transferring, and compressing/decompressing accounts.

    Compressed Token Accounts

    • Location: Reside on Solana mainnet.
    • Nature: They are compressed accounts.
    • Supported Tokens: Can hold both Light Mint and SPL Mint tokens.
    • Cost: Creation costs 5,000 lamports.
    • Best Use Case: Highly efficient for airdrops and large-scale reward distributions due to their low cost.

    When to use Compressed Tokens vs. Light-Tokens

    • Use Compressed Tokens when you need rent-free storage or high-volume distribution (e.g., airdrops). Light Token uses compressed accounts under the hood for rent-free storage of inactive tokens.
    • Use Light-Tokens for standard token use cases like launchpads, DeFi, and payments. Light-Tokens are standard Solana accounts with sponsored rent-exemption and support Light Mint, SPL, or Token 22 mints.
  2. Overview of light-token-interface modules

    main

    The light-token-interface crate provides the core instruction data types required to interact with the light-token program. It is organized into several functional modules:

    • instructions: Contains instruction structs for core operations: mint, transfer, wrap, and unwrap.
    • state: Defines the structs for token account and mint state.
    • discriminator: Provides instruction discriminator constants used to identify instruction types.
    • hash_cache: Contains precomputed hashes for token account fields.
    • pool_derivation: Handles SPL/T22 pool account PDA (Program Derived Address) derivation.
    • token_2022_extensions: Defines data types for Token-2022 extensions.
    • error: Contains the TokenInterfaceError enum variants for error handling.
  3. Overview of light-concurrent-merkle-tree

    main
    The light-concurrent-merkle-tree library provides a Concurrent Merkle tree implementation designed to handle multiple leaf updates simultaneously. Its primary advantage is the ability to accept multiple leaf updates without invalidating other in-flight proofs, making it suitable for high-concurrency environments where proof generation and tree updates happen in parallel.
  4. Overview of light-merkle-tree-metadata modules

    main

    The light-merkle-tree-metadata library provides metadata structures designed for concurrent, indexed, and batched Merkle trees. It is organized into several functional modules:

    • merkle_tree: Manages core tree metadata including height, the next available index, owner, and delegate information.
    • queue: Handles queue metadata such as type, capacity, and sequence numbers.
    • access: Provides logic for owner and delegate access control checks.
    • fee: Manages fee parameters for both tree and queue operations.
    • rollover: Tracks rollover thresholds and status.
    • events: Defines changelog events emitted during tree updates.
    • errors: Contains MerkleTreeMetadataError variants for error handling.
  5. Overview of light-hash-set

    main
    The light-hash-set library provides a hash set implementation designed to be stored on a Solana account. It utilizes quadratic probing for collision resolution and implements sequence-number-based expiry to handle element invalidation. This makes it suitable for high-performance, on-chain data structures where space and invalidation logic are critical.
  6. Overview of Light Protocol

    main
    Light Protocol is a ZK Compression Protocol for Solana. It allows developers to create rent-free tokens and Program Derived Addresses (PDAs) on Solana without sacrificing performance, security, or composability. The protocol uses Zero-Knowledge (ZK) proofs under the hood, meaning developers can use it with any regular on-chain Solana program without needing to understand ZK implementation details. For custom ZK-based applications, developers can also compose with compressed state inside their own circuits.
  7. Overview of light-instruction-decoder

    main

    The light-instruction-decoder crate is designed for decoding instructions and logging transactions for Light Protocol programs. It is primarily an off-chain tool and is not intended for use on Solana targets.

    Key capabilities include:

    • Instruction Decoding: Provides core types like DecodedField and DecodedInstruction, along with the InstructionDecoder trait for implementing custom decoding logic.
    • Decoder Management: Uses a DecoderRegistry to manage and coordinate multiple program decoders.
    • Built-in Support: Includes pre-built decoders for Light Protocol programs such as the System program and Compressed Token program.
    • Transaction Logging: Offers EnhancedLoggingConfig for configuring logs and TransactionFormatter for outputting formatted, ANSI-colored transaction logs.
  8. Overview of light-token-client actions

    main

    The light-token-client is a Rust client for light-token. It provides high-level abstractions where each action handles the complete lifecycle of a transaction: building the instruction, signing it, and sending it to the network.

    Available actions include:

    • CreateMint: Create a light-token mint with metadata.
    • CreateAta: Create an associated light-token account.
    • MintTo: Mint tokens to a light-token account.
    • Transfer: Transfer light-tokens between accounts.
    • TransferChecked: Transfer with decimal validation.
    • TransferInterface: Transfer between light-token, T22, and SPL accounts.
    • Approve: Approve a delegate.
    • Revoke: Revoke a delegate.
    • Wrap: Wrap SPL/T22 to light-token.
    • Unwrap: Unwrap light-token to SPL/T22.
  9. Overview of the Compressed Token Program

    main
    The Compressed Token Program is a Solana blockchain program that utilizes ZK Compression to enable the creation and management of compressed tokens. It provides a standardized interface and implementation that third-party developers can integrate to leverage compressed token functionality on Solana. For more detailed documentation, visit https://zkcompression.com.