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

feat(api): Generate a blake2b hash of a given binary buffer. #120

Merged
merged 43 commits into from
Feb 15, 2024

Conversation

bkioshn
Copy link
Contributor

@bkioshn bkioshn commented Feb 8, 2024

Description

Generate a blake2b hash of a given binary buffer.
Related function include

  • blake2b
  • blake2bmac

Related Issue(s)

Closes #98

Description of Changes

Reference to blake2b can be found rfc and doc

Fix how blake2 is implemented, since when blake2 is keyed it changes to MAC (Message Authentication Code) mode.

  • Divide blake2 into 2 functions
    • blake2b: blake2b and blake2bmac
    • blake2s: blake2s and blake2smac
  • blake2 without key will only accept bytes of buf and optional outlen which is the output length of the hash (eg. if outlen = 32 the hash function is equal to blake2b-256)
  • blake2mac accepts bytes of buf, optional outlen, key, optional salt, and optional personal
    If outlen is not specified, set to 64 which is blake2b-512
  • Handle all possible errors
  • Create rust unit test for blake2b and blake2bmac

Please confirm the following checks

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • 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
  • Any dependent changes have been merged and published in downstream module

@bkioshn bkioshn added enhancement New feature or request do not review yet Do not review yet draft Draft labels Feb 8, 2024
@bkioshn bkioshn self-assigned this Feb 8, 2024
@bkioshn bkioshn marked this pull request as draft February 8, 2024 07:57
@bkioshn bkioshn changed the title [WIP] feat(api): Generate a blake2b-256 hash of a given binary buffer. [WIP] feat(util): Generate a blake2b-256 hash of a given binary buffer. Feb 8, 2024
hermes/bin/Cargo.toml Outdated Show resolved Hide resolved
hermes/bin/Cargo.toml Outdated Show resolved Hide resolved
hermes/bin/src/runtime/host/hermes/hash/mod.rs Outdated Show resolved Hide resolved
@bkioshn bkioshn marked this pull request as ready for review February 14, 2024 08:57
@bkioshn bkioshn added the review me PR is ready for review label Feb 14, 2024
hermes/bin/src/runtime/host/hermes/hash/blake2b.rs Outdated Show resolved Hide resolved
hermes/bin/src/runtime/host/hermes/hash/blake2b.rs Outdated Show resolved Hide resolved
hermes/bin/src/runtime/host/hermes/hash/blake2b.rs Outdated Show resolved Hide resolved
hermes/bin/src/runtime/host/hermes/hash/blake2b.rs Outdated Show resolved Hide resolved
hermes/bin/src/runtime/host/hermes/hash/blake2b.rs Outdated Show resolved Hide resolved
hermes/bin/src/runtime/host/hermes/hash/blake2b.rs Outdated Show resolved Hide resolved
hermes/bin/src/runtime/host/hermes/hash/mod.rs Outdated Show resolved Hide resolved
hermes/bin/src/runtime/host/hermes/hash/mod.rs Outdated Show resolved Hide resolved
Mr-Leshiy
Mr-Leshiy previously approved these changes Feb 14, 2024
Copy link
Contributor

@Mr-Leshiy Mr-Leshiy left a comment

Choose a reason for hiding this comment

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

Besides few comments LGTM

hermes/bin/src/runtime/host/hermes/hash/blake2b.rs Outdated Show resolved Hide resolved
hermes/bin/src/runtime/host/hermes/hash/blake2b.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@stevenj stevenj left a comment

Choose a reason for hiding this comment

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

Looks great.

@bkioshn bkioshn changed the title feat(util): Generate a blake2b hash of a given binary buffer. feat(api): Generate a blake2b hash of a given binary buffer. Feb 15, 2024
@bkioshn bkioshn removed the review me PR is ready for review label Feb 15, 2024
@minikin minikin added the review me PR is ready for review label Feb 15, 2024
@bkioshn bkioshn removed do not merge yet PR is not ready to be merged yet review me PR is ready for review labels Feb 15, 2024
@bkioshn bkioshn merged commit c9b23b1 into main Feb 15, 2024
22 checks passed
@bkioshn bkioshn deleted the feat/blake2b-util branch February 15, 2024 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

🛠️ [TASK] : Hashing utility API: Hermes Implementation (Rust Module)
5 participants