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

Add Blake3 support #394

Open
httpjamesm opened this issue Jun 18, 2024 · 3 comments
Open

Add Blake3 support #394

httpjamesm opened this issue Jun 18, 2024 · 3 comments
Labels
new feature New feature or request

Comments

@httpjamesm
Copy link

Summary
Brief explanation of the feature.

Orion currently supports Blake2b hashing through

    let digest = orion::hash::digest(data).unwrap();

which uses Blake2b-256. However, Blake3 is 7x faster wazuh/wazuh#15632.

Basic example
If the proposal involves a new or changed API, include a basic code example. Omit this section if it's not applicable.

I propose adding Blake3 through another function to prevent breaking old code. Maybe orion::hash::digest_blake3?


**Motivation**
Why are we doing this? What use cases does it support? Will it be used anywhere?

It would greatly increase performance of the digest function and allow for variable output sizes, such as 16 bytes and up.
@httpjamesm httpjamesm added the new feature New feature or request label Jun 18, 2024
@brycx
Copy link
Member

brycx commented Jun 18, 2024

Hi @httpjamesm

Thanks for bringing up this suggestion! I'm definitely not opposed to supporting BLAKE3.

Whether or not it should be the default in the high-level API can be discussed, once we get closer to providing an actual implementation. I'm not a big fan of adding orion::hash::digest_blake3 specifically, as anything in the higher-level modules is intended to incur the least amount of decision making from the user, so I'm tending strongly towards keeping it at a single primitive there.

In either case, we need to provide it in the hazardous module as well.

Is a BLAKE3 implementation something you're interested in working on?

@httpjamesm
Copy link
Author

Possibly. Just taking a quick look at the code and I had a few questions:

  1. Is it acceptable to simply include the blake3 package and essentially "remap" the existing hazardous hash functions to blake3 functions?
  2. I see blake2b_core here. Is that a public crate?

@brycx
Copy link
Member

brycx commented Jun 18, 2024

  1. We normally try to avoid this. Orion is intended as an alternative to other crates, with a focus on a trimmed-down dependency tree. So we normally provide concrete implementations from Orion directly.

  2. No, that's part of the mod.rs file here:

    pub(crate) mod blake2b_core {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants