Skip to content

Conversation

@sumitvekariya
Copy link

Description

This PR implements a preimage proof circuit that allows proving knowledge of a hash preimage without revealing it. This circuit is a fundamental building block for many zero-knowledge proof applications, enabling users to prove they know a value that hashes to a specific result without disclosing the original value.

Key features of this implementation:

  • Simple and easy-to-use API with just two main functions:
    • prove_field for proving knowledge of Field element preimages
    • prove_bytes32 for proving knowledge of 32-byte array preimages
  • Flexible design that works with any hash function that matches the required signature
  • Comprehensive documentation with usage examples
  • Test suite covering both Field elements (with mock Poseidon hash) and byte arrays (with mock SHA-256 hash)

This implementation avoids using complex generic trait bounds which were causing compilation errors with Noir's current capabilities, opting instead for a simpler and more reliable approach with specific function implementations.

Related Issue(s)

Fixes #45

Checklist

  • I have read and understand the contributor guidelines and code of conduct.
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have run bun check without getting any errors (Note: Will run locally before final PR submission)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

…circuit

implement preimage proof circuit" -m "Implements a preimage proof circuit that allows proving
knowledge of a hash preimage without revealing it. Supports both Field elements and 32-byte arrays

re zk-kit#45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create preimage-proof circuit

1 participant