Skip to content

Optimize Poseidon Hash Implementation in CosmWasm Contracts #2575

@99Kies

Description

@99Kies

Problem Description

The Poseidon hash function is a zero-knowledge (ZK) ecosystem-friendly cryptographic hash. Currently in our contracts, we can directly create Poseidon instances, but each message processing requires re-instantiating the Poseidon instance. This process involves loading substantial constant data, resulting in unnecessarily high gas costs.

Key Issues

  1. Current Limitation: Is it possible to instantiate the Poseidon instance during contract initialization (loading all constant data once) and share it across subsequent contract calls? (This approach appears unfeasible with current architecture)

  2. Proposed Solution: If the above approach is not viable, we should implement native Poseidon hash support in the CosmWasm framework. This would allow the Poseidon instance data to be pre-loaded in the chain's runtime environment, eliminating redundant loading and reducing gas costs.

Technical Context

  • Poseidon hash is particularly important for ZK-related applications and privacy-preserving smart contracts
  • The constant data loading during each instantiation creates significant overhead
  • Native runtime support could provide both performance benefits and cost reductions

Desired Outcome

More efficient Poseidon hash implementation in CosmWasm contracts with reduced gas consumption for ZK-related operations.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions