Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose SHA256 low-level API #1689

Merged
merged 9 commits into from
Jun 18, 2024

Conversation

Shigoto-dev19
Copy link
Contributor

@Shigoto-dev19 Shigoto-dev19 commented Jun 17, 2024

Description

  • This PR exposes the low-level API of the SHA-256 hash function in o1js.
  • It supports the development of partialSHA and dynamicSHA as external packages while leveraging the efficiencies of the low-level API.
  • Closes Add partial SHA256 hash gadget #1668.

Changes

  • Separated the low-level SHA-256 functions and exported them as part of the SHA-256 gadgets in o1js.
  • Added 2 importable functions and 1 constant:
    • SHA-256 Compression Function
      • Enables flexible block hashing with better control of initial and intermediate hashes.
    • Message Schedule Computation Function
      • Computes the message schedule from message blocks to prepare it as input to the compression function.
    • SHA256 Initial State Constant
      • The initial hash values, also known as the SHA256 nothing-up-my-sleeve constants, are now exposed for enhanced flexibility in constructing SHA256 hashes.

Copy link
Collaborator

@mitschabaude mitschabaude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for visibility - some feedback given via DM

image

Copy link
Member

@Trivo25 Trivo25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good so far, no major concerns except cleaning up and moving around the otherwise unused constants in the original method

src/lib/provable/gadgets/sha256.ts Outdated Show resolved Hide resolved
src/lib/provable/gadgets/sha256.ts Outdated Show resolved Hide resolved
src/lib/provable/gadgets/sha256.ts Outdated Show resolved Hide resolved
@Trivo25
Copy link
Member

Trivo25 commented Jun 18, 2024

And, feel free to take the honor of adding your changes to the changelog!

Copy link
Collaborator

@mitschabaude mitschabaude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work!

@Trivo25 Trivo25 merged commit 1588ee5 into o1-labs:main Jun 18, 2024
12 of 14 checks passed
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.

3 participants