[PATCH] D121510: [Support] Introduce the BLAKE3 hashing function implementation

Argyrios Kyrtzidis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 17:19:18 PDT 2022


akyrtzi added inline comments.


================
Comment at: llvm/include/llvm/Support/BLAKE3.h:66-70
+  template <size_t NumBytes = BLAKE3_OUT_LEN> BLAKE3Result<NumBytes> final() {
+    BLAKE3Result<NumBytes> Result;
+    blake3_hasher_finalize(&Hasher, Result.data(), Result.size());
+    return Result;
+  }
----------------
akyrtzi wrote:
> dexonsmith wrote:
> > Other hashers (SHA1/MD5/SHA256) return a `StringRef` from the `final()` function. Generic APIs (such as llvm/Support/HashBuilder.h) rely on this being the same everywhere.
> > 
> > Is it reasonable to update this to return a StringRef, or can/should we change the other things to return a `std::array` to match this?
> > 
> > (If returning a StringRef here, we could add a `std::array<uint8_t, 32> Hash` field to BLAKE3, fill it using `blake3_hasher_finalize()`, and then call `toStringRef(makeArrayRef(Hash)).take_front(NumBytes)`.)
> I'll take a look to see if it would work well to change all the hashers to `std::array`, otherwise I think it'd be reasonable to add the field so we can return `StringRef` here.
> or can/should we change the other things to return a std::array to match this?

This was an excellent idea, I think the APIs are more ergonomic like this, see https://reviews.llvm.org/D123100


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121510/new/

https://reviews.llvm.org/D121510

STAMPS
actor(@akyrtzi) application(Differential) author(@akyrtzi) herald(H127) herald(H157) herald(H215) herald(H224) herald(H225) herald(H403) herald(H428) herald(H438) herald(H576) herald(H615) herald(H628) herald(H688) herald(H723) herald(H864) monogram(D121510) object-type(DREV) phid(PHID-DREV-2ilvuhmax5o633ygavm7) reviewer(@compnerd) reviewer(@deadalnix) reviewer(@dexonsmith) reviewer(@jdoerfert) reviewer(@lattner) reviewer(@MaskRay) reviewer(@rnk) revision-repository(rG) revision-status(published) subscriber(@dexonsmith) subscriber(@hiraditya) subscriber(@joerg) subscriber(@krytarowski) subscriber(@lebedev.ri) subscriber(@llvm-commits) subscriber(@MaskRay) subscriber(@mgorny) subscriber(@sstefan1) subscriber(@StephenFan) subscriber(@thakis) tag(#all) tag(#llvm) via(web)



More information about the llvm-commits mailing list