diff --git a/README.md b/README.md index a63d5f2..986d73c 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ your `Cargo.toml`. Here's an example of hashing some input bytes: ```rust // Hash an input all at once. -let hash1 = blake3::hash(b"foobarbaz"); +let hash1 = iroh_blake3::hash(b"foobarbaz"); // Hash an input incrementally. let mut hasher = blake3::Hasher::new(); diff --git a/b3sum/Cargo.lock b/b3sum/Cargo.lock index 2a599a8..490af6b 100644 --- a/b3sum/Cargo.lock +++ b/b3sum/Cargo.lock @@ -75,21 +75,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "b3sum" -version = "1.4.1" -dependencies = [ - "anyhow", - "blake3", - "clap", - "duct", - "hex", - "memmap2", - "rayon", - "tempfile", - "wild", -] - [[package]] name = "bitflags" version = "1.3.2" @@ -102,28 +87,6 @@ version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" -[[package]] -name = "blake3" -version = "1.4.1" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if", - "constant_time_eq", - "digest", - "rayon", -] - -[[package]] -name = "block-buffer" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" -dependencies = [ - "generic-array", -] - [[package]] name = "cc" version = "1.0.79" @@ -233,27 +196,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crypto-common" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" -dependencies = [ - "generic-array", - "typenum", -] - -[[package]] -name = "digest" -version = "0.10.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" -dependencies = [ - "block-buffer", - "crypto-common", - "subtle", -] - [[package]] name = "duct" version = "0.13.6" @@ -302,16 +244,6 @@ dependencies = [ "instant", ] -[[package]] -name = "generic-array" -version = "0.14.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" -dependencies = [ - "typenum", - "version_check", -] - [[package]] name = "glob" version = "0.3.1" @@ -356,6 +288,33 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "iroh-b3sum" +version = "1.4.1" +dependencies = [ + "anyhow", + "clap", + "duct", + "hex", + "iroh-blake3", + "memmap2", + "rayon", + "tempfile", + "wild", +] + +[[package]] +name = "iroh-blake3" +version = "1.4.3" +dependencies = [ + "arrayref", + "arrayvec", + "cc", + "cfg-if", + "constant_time_eq", + "rayon", +] + [[package]] name = "is-terminal" version = "0.4.9" @@ -527,12 +486,6 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" -[[package]] -name = "subtle" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" - [[package]] name = "syn" version = "2.0.23" @@ -568,12 +521,6 @@ dependencies = [ "windows-sys", ] -[[package]] -name = "typenum" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" - [[package]] name = "unicode-ident" version = "1.0.10" @@ -586,12 +533,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - [[package]] name = "wild" version = "2.1.0" diff --git a/b3sum/Cargo.toml b/b3sum/Cargo.toml index 02c9405..343007c 100644 --- a/b3sum/Cargo.toml +++ b/b3sum/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "b3sum" +name = "iroh-b3sum" version = "1.4.1" authors = ["Jack O'Connor "] description = "a command line implementation of the BLAKE3 hash function" @@ -9,13 +9,13 @@ readme = "README.md" edition = "2021" [features] -neon = ["blake3/neon"] -prefer_intrinsics = ["blake3/prefer_intrinsics"] -pure = ["blake3/pure"] +neon = ["iroh-blake3/neon"] +prefer_intrinsics = ["iroh-blake3/prefer_intrinsics"] +pure = ["iroh-blake3/pure"] [dependencies] anyhow = "1.0.25" -blake3 = { version = "1", path = "..", features = ["rayon"] } +iroh-blake3 = { version = "1", path = "..", features = ["rayon"] } clap = { version = "4.0.8", features = ["derive", "wrap_help"] } hex = "0.4.0" memmap2 = "0.7.0" diff --git a/b3sum/src/main.rs b/b3sum/src/main.rs index fd35f68..c053368 100644 --- a/b3sum/src/main.rs +++ b/b3sum/src/main.rs @@ -6,6 +6,8 @@ use std::io; use std::io::prelude::*; use std::path::{Path, PathBuf}; +use iroh_blake3 as blake3; + #[cfg(test)] mod unit_tests; diff --git a/b3sum/src/unit_tests.rs b/b3sum/src/unit_tests.rs index 1fa1a17..c5d05ad 100644 --- a/b3sum/src/unit_tests.rs +++ b/b3sum/src/unit_tests.rs @@ -1,5 +1,7 @@ use std::path::Path; +use iroh_blake3 as blake3; + #[test] fn test_parse_check_line() { // ========================= diff --git a/b3sum/tests/cli_tests.rs b/b3sum/tests/cli_tests.rs index d5d4efa..6b511a2 100644 --- a/b3sum/tests/cli_tests.rs +++ b/b3sum/tests/cli_tests.rs @@ -4,8 +4,10 @@ use std::fs; use std::io::prelude::*; use std::path::PathBuf; +use iroh_blake3 as blake3; + pub fn b3sum_exe() -> PathBuf { - env!("CARGO_BIN_EXE_b3sum").into() + env!("CARGO_BIN_EXE_iroh-b3sum").into() } #[test] diff --git a/benches/bench.rs b/benches/bench.rs index 5efb9e6..49ff6ae 100644 --- a/benches/bench.rs +++ b/benches/bench.rs @@ -4,9 +4,9 @@ extern crate test; use arrayref::array_ref; use arrayvec::ArrayVec; -use blake3::guts::{BLOCK_LEN, CHUNK_LEN}; -use blake3::platform::{Platform, MAX_SIMD_DEGREE}; -use blake3::OUT_LEN; +use iroh_blake3::guts::{BLOCK_LEN, CHUNK_LEN}; +use iroh_blake3::platform::{Platform, MAX_SIMD_DEGREE}; +use iroh_blake3::OUT_LEN; use rand::prelude::*; use test::Bencher; @@ -102,7 +102,7 @@ fn bench_many_chunks_fn(b: &mut Bencher, platform: Platform) { &input_arrays[..], &[0; 8], 0, - blake3::IncrementCounter::Yes, + iroh_blake3::IncrementCounter::Yes, 0, 0, 0, @@ -169,7 +169,7 @@ fn bench_many_parents_fn(b: &mut Bencher, platform: Platform) { &input_arrays[..], &[0; 8], 0, - blake3::IncrementCounter::No, + iroh_blake3::IncrementCounter::No, 0, 0, 0, @@ -220,7 +220,7 @@ fn bench_many_parents_neon(b: &mut Bencher) { fn bench_atonce(b: &mut Bencher, len: usize) { let mut input = RandomInput::new(b, len); - b.iter(|| blake3::hash(input.get())); + b.iter(|| iroh_blake3::hash(input.get())); } #[bench] @@ -285,7 +285,7 @@ fn bench_atonce_1024_kib(b: &mut Bencher) { fn bench_incremental(b: &mut Bencher, len: usize) { let mut input = RandomInput::new(b, len); - b.iter(|| blake3::Hasher::new().update(input.get()).finalize()); + b.iter(|| iroh_blake3::Hasher::new().update(input.get()).finalize()); } #[bench] @@ -422,7 +422,11 @@ fn bench_reference_1024_kib(b: &mut Bencher) { #[cfg(feature = "rayon")] fn bench_rayon(b: &mut Bencher, len: usize) { let mut input = RandomInput::new(b, len); - b.iter(|| blake3::Hasher::new().update_rayon(input.get()).finalize()); + b.iter(|| { + iroh_blake3::Hasher::new() + .update_rayon(input.get()) + .finalize() + }); } #[bench] @@ -508,7 +512,7 @@ fn bench_two_updates(b: &mut Bencher) { let len = 65536; let mut input = RandomInput::new(b, len); b.iter(|| { - let mut hasher = blake3::Hasher::new(); + let mut hasher = iroh_blake3::Hasher::new(); let input = input.get(); hasher.update(&input[..1]); hasher.update(&input[1..]); diff --git a/c/blake3.c b/c/blake3.c index 692f4b0..9d0d151 100644 --- a/c/blake3.c +++ b/c/blake3.c @@ -81,7 +81,7 @@ INLINE output_t make_output(const uint32_t input_cv[8], INLINE void output_chaining_value(const output_t *self, uint8_t cv[32]) { uint32_t cv_words[8]; memcpy(cv_words, self->input_cv, 32); - blake3_compress_in_place(cv_words, self->block, self->block_len, + iroh_blake3_compress_in_place(cv_words, self->block, self->block_len, self->counter, self->flags); store_cv_words(cv, cv_words); } @@ -92,7 +92,7 @@ INLINE void output_root_bytes(const output_t *self, uint64_t seek, uint8_t *out, size_t offset_within_block = seek % 64; uint8_t wide_buf[64]; while (out_len > 0) { - blake3_compress_xof(self->input_cv, self->block, self->block_len, + iroh_blake3_compress_xof(self->input_cv, self->block, self->block_len, output_block_counter, self->flags | ROOT, wide_buf); size_t available_bytes = 64 - offset_within_block; size_t memcpy_len; @@ -116,7 +116,7 @@ INLINE void chunk_state_update(blake3_chunk_state *self, const uint8_t *input, input += take; input_len -= take; if (input_len > 0) { - blake3_compress_in_place( + iroh_blake3_compress_in_place( self->cv, self->buf, BLAKE3_BLOCK_LEN, self->chunk_counter, self->flags | chunk_state_maybe_start_flag(self)); self->blocks_compressed += 1; @@ -126,7 +126,7 @@ INLINE void chunk_state_update(blake3_chunk_state *self, const uint8_t *input, } while (input_len > BLAKE3_BLOCK_LEN) { - blake3_compress_in_place(self->cv, input, BLAKE3_BLOCK_LEN, + iroh_blake3_compress_in_place(self->cv, input, BLAKE3_BLOCK_LEN, self->chunk_counter, self->flags | chunk_state_maybe_start_flag(self)); self->blocks_compressed += 1; @@ -261,7 +261,7 @@ INLINE size_t compress_parents_parallel(const uint8_t *child_chaining_values, // Why not just have the caller split the input on the first update(), instead // of implementing this special rule? Because we don't want to limit SIMD or // multi-threading parallelism for that update(). -static size_t blake3_compress_subtree_wide(const uint8_t *input, +static size_t iroh_blake3_compress_subtree_wide(const uint8_t *input, size_t input_len, const uint32_t key[8], uint64_t chunk_counter, @@ -301,9 +301,9 @@ static size_t blake3_compress_subtree_wide(const uint8_t *input, // Recurse! If this implementation adds multi-threading support in the // future, this is where it will go. - size_t left_n = blake3_compress_subtree_wide(input, left_input_len, key, + size_t left_n = iroh_blake3_compress_subtree_wide(input, left_input_len, key, chunk_counter, flags, cv_array); - size_t right_n = blake3_compress_subtree_wide( + size_t right_n = iroh_blake3_compress_subtree_wide( right_input, right_input_len, key, right_chunk_counter, flags, right_cvs); // The special case again. If simd_degree=1, then we'll have left_n=1 and @@ -338,7 +338,7 @@ INLINE void compress_subtree_to_parent_node( #endif uint8_t cv_array[MAX_SIMD_DEGREE_OR_2 * BLAKE3_OUT_LEN]; - size_t num_cvs = blake3_compress_subtree_wide(input, input_len, key, + size_t num_cvs = iroh_blake3_compress_subtree_wide(input, input_len, key, chunk_counter, flags, cv_array); assert(num_cvs <= MAX_SIMD_DEGREE_OR_2); diff --git a/c/blake3_avx2.c b/c/blake3_avx2.c index 381e7c4..eb01c6b 100644 --- a/c/blake3_avx2.c +++ b/c/blake3_avx2.c @@ -287,7 +287,7 @@ void blake3_hash8_avx2(const uint8_t *const *inputs, size_t blocks, } #if !defined(BLAKE3_NO_SSE41) -void blake3_hash_many_sse41(const uint8_t *const *inputs, size_t num_inputs, +void iroh_blake3_hash_many_sse41(const uint8_t *const *inputs, size_t num_inputs, size_t blocks, const uint32_t key[8], uint64_t counter, bool increment_counter, uint8_t flags, uint8_t flags_start, @@ -300,7 +300,7 @@ void blake3_hash_many_portable(const uint8_t *const *inputs, size_t num_inputs, uint8_t flags_end, uint8_t *out); #endif -void blake3_hash_many_avx2(const uint8_t *const *inputs, size_t num_inputs, +void iroh_blake3_hash_many_avx2(const uint8_t *const *inputs, size_t num_inputs, size_t blocks, const uint32_t key[8], uint64_t counter, bool increment_counter, uint8_t flags, uint8_t flags_start, @@ -316,7 +316,7 @@ void blake3_hash_many_avx2(const uint8_t *const *inputs, size_t num_inputs, out = &out[DEGREE * BLAKE3_OUT_LEN]; } #if !defined(BLAKE3_NO_SSE41) - blake3_hash_many_sse41(inputs, num_inputs, blocks, key, counter, + iroh_blake3_hash_many_sse41(inputs, num_inputs, blocks, key, counter, increment_counter, flags, flags_start, flags_end, out); #else blake3_hash_many_portable(inputs, num_inputs, blocks, key, counter, diff --git a/c/blake3_avx2_x86-64_unix.S b/c/blake3_avx2_x86-64_unix.S index 812bb85..cec520e 100644 --- a/c/blake3_avx2_x86-64_unix.S +++ b/c/blake3_avx2_x86-64_unix.S @@ -13,16 +13,16 @@ #endif .intel_syntax noprefix -.global _blake3_hash_many_avx2 -.global blake3_hash_many_avx2 +.global _iroh_blake3_hash_many_avx2 +.global iroh_blake3_hash_many_avx2 #ifdef __APPLE__ .text #else .section .text #endif .p2align 6 -_blake3_hash_many_avx2: -blake3_hash_many_avx2: +_iroh_blake3_hash_many_avx2: +iroh_blake3_hash_many_avx2: _CET_ENDBR push r15 push r14 diff --git a/c/blake3_avx2_x86-64_windows_gnu.S b/c/blake3_avx2_x86-64_windows_gnu.S index 3d4be4a..4ad7fe1 100644 --- a/c/blake3_avx2_x86-64_windows_gnu.S +++ b/c/blake3_avx2_x86-64_windows_gnu.S @@ -1,10 +1,10 @@ .intel_syntax noprefix -.global _blake3_hash_many_avx2 -.global blake3_hash_many_avx2 +.global _iroh_blake3_hash_many_avx2 +.global iroh_blake3_hash_many_avx2 .section .text .p2align 6 -_blake3_hash_many_avx2: -blake3_hash_many_avx2: +_iroh_blake3_hash_many_avx2: +iroh_blake3_hash_many_avx2: push r15 push r14 push r13 diff --git a/c/blake3_avx2_x86-64_windows_msvc.asm b/c/blake3_avx2_x86-64_windows_msvc.asm index 352298e..7c27157 100644 --- a/c/blake3_avx2_x86-64_windows_msvc.asm +++ b/c/blake3_avx2_x86-64_windows_msvc.asm @@ -1,11 +1,11 @@ -public _blake3_hash_many_avx2 -public blake3_hash_many_avx2 +public _iroh_blake3_hash_many_avx2 +public iroh_blake3_hash_many_avx2 _TEXT SEGMENT ALIGN(16) 'CODE' ALIGN 16 -blake3_hash_many_avx2 PROC -_blake3_hash_many_avx2 PROC +iroh_blake3_hash_many_avx2 PROC +_iroh_blake3_hash_many_avx2 PROC push r15 push r14 push r13 @@ -1785,8 +1785,8 @@ endroundloop1: vmovdqu xmmword ptr [rbx+10H], xmm1 jmp unwind -_blake3_hash_many_avx2 ENDP -blake3_hash_many_avx2 ENDP +_iroh_blake3_hash_many_avx2 ENDP +iroh_blake3_hash_many_avx2 ENDP _TEXT ENDS _RDATA SEGMENT READONLY PAGE ALIAS(".rdata") 'CONST' diff --git a/c/blake3_avx512.c b/c/blake3_avx512.c index d6b1ae9..cb8c2a3 100644 --- a/c/blake3_avx512.c +++ b/c/blake3_avx512.c @@ -284,7 +284,7 @@ INLINE void compress_pre(__m128i rows[4], const uint32_t cv[8], undiagonalize(&rows[0], &rows[2], &rows[3]); } -void blake3_compress_xof_avx512(const uint32_t cv[8], +void iroh_blake3_compress_xof_avx512(const uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]) { @@ -296,7 +296,7 @@ void blake3_compress_xof_avx512(const uint32_t cv[8], storeu_128(xor_128(rows[3], loadu_128((uint8_t *)&cv[4])), &out[48]); } -void blake3_compress_in_place_avx512(uint32_t cv[8], +void iroh_blake3_compress_in_place_avx512(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags) { @@ -1163,7 +1163,7 @@ INLINE void hash_one_avx512(const uint8_t *input, size_t blocks, if (blocks == 1) { block_flags |= flags_end; } - blake3_compress_in_place_avx512(cv, input, BLAKE3_BLOCK_LEN, counter, + iroh_blake3_compress_in_place_avx512(cv, input, BLAKE3_BLOCK_LEN, counter, block_flags); input = &input[BLAKE3_BLOCK_LEN]; blocks -= 1; @@ -1172,7 +1172,7 @@ INLINE void hash_one_avx512(const uint8_t *input, size_t blocks, memcpy(out, cv, BLAKE3_OUT_LEN); } -void blake3_hash_many_avx512(const uint8_t *const *inputs, size_t num_inputs, +void iroh_blake3_hash_many_avx512(const uint8_t *const *inputs, size_t num_inputs, size_t blocks, const uint32_t key[8], uint64_t counter, bool increment_counter, uint8_t flags, uint8_t flags_start, diff --git a/c/blake3_avx512_x86-64_unix.S b/c/blake3_avx512_x86-64_unix.S index a06aede..8a0158a 100644 --- a/c/blake3_avx512_x86-64_unix.S +++ b/c/blake3_avx512_x86-64_unix.S @@ -13,12 +13,12 @@ #endif .intel_syntax noprefix -.global _blake3_hash_many_avx512 -.global blake3_hash_many_avx512 -.global blake3_compress_in_place_avx512 -.global _blake3_compress_in_place_avx512 -.global blake3_compress_xof_avx512 -.global _blake3_compress_xof_avx512 +.global _iroh_blake3_hash_many_avx512 +.global iroh_blake3_hash_many_avx512 +.global iroh_blake3_compress_in_place_avx512 +.global _iroh_blake3_compress_in_place_avx512 +.global iroh_blake3_compress_xof_avx512 +.global _iroh_blake3_compress_xof_avx512 #ifdef __APPLE__ .text @@ -26,8 +26,8 @@ .section .text #endif .p2align 6 -_blake3_hash_many_avx512: -blake3_hash_many_avx512: +_iroh_blake3_hash_many_avx512: +iroh_blake3_hash_many_avx512: _CET_ENDBR push r15 push r14 @@ -2384,8 +2384,8 @@ blake3_hash_many_avx512: vmovdqu xmmword ptr [rbx+0x10], xmm1 jmp 4b .p2align 6 -_blake3_compress_in_place_avx512: -blake3_compress_in_place_avx512: +_iroh_blake3_compress_in_place_avx512: +iroh_blake3_compress_in_place_avx512: _CET_ENDBR vmovdqu xmm0, xmmword ptr [rdi] vmovdqu xmm1, xmmword ptr [rdi+0x10] @@ -2467,8 +2467,8 @@ blake3_compress_in_place_avx512: ret .p2align 6 -_blake3_compress_xof_avx512: -blake3_compress_xof_avx512: +_iroh_blake3_compress_xof_avx512: +iroh_blake3_compress_xof_avx512: _CET_ENDBR vmovdqu xmm0, xmmword ptr [rdi] vmovdqu xmm1, xmmword ptr [rdi+0x10] diff --git a/c/blake3_avx512_x86-64_windows_gnu.S b/c/blake3_avx512_x86-64_windows_gnu.S index ba4fc5f..99821d8 100644 --- a/c/blake3_avx512_x86-64_windows_gnu.S +++ b/c/blake3_avx512_x86-64_windows_gnu.S @@ -1,16 +1,16 @@ .intel_syntax noprefix -.global _blake3_hash_many_avx512 -.global blake3_hash_many_avx512 -.global blake3_compress_in_place_avx512 -.global _blake3_compress_in_place_avx512 -.global blake3_compress_xof_avx512 -.global _blake3_compress_xof_avx512 +.global _iroh_blake3_hash_many_avx512 +.global iroh_blake3_hash_many_avx512 +.global iroh_blake3_compress_in_place_avx512 +.global _iroh_blake3_compress_in_place_avx512 +.global iroh_blake3_compress_xof_avx512 +.global _iroh_blake3_compress_xof_avx512 .section .text .p2align 6 -_blake3_hash_many_avx512: -blake3_hash_many_avx512: +_iroh_blake3_hash_many_avx512: +iroh_blake3_hash_many_avx512: push r15 push r14 push r13 @@ -2398,8 +2398,8 @@ blake3_hash_many_avx512: .p2align 6 -_blake3_compress_in_place_avx512: -blake3_compress_in_place_avx512: +_iroh_blake3_compress_in_place_avx512: +iroh_blake3_compress_in_place_avx512: sub rsp, 72 vmovdqa xmmword ptr [rsp], xmm6 vmovdqa xmmword ptr [rsp+0x10], xmm7 @@ -2491,8 +2491,8 @@ blake3_compress_in_place_avx512: .p2align 6 -_blake3_compress_xof_avx512: -blake3_compress_xof_avx512: +_iroh_blake3_compress_xof_avx512: +iroh_blake3_compress_xof_avx512: sub rsp, 72 vmovdqa xmmword ptr [rsp], xmm6 vmovdqa xmmword ptr [rsp+0x10], xmm7 diff --git a/c/blake3_avx512_x86-64_windows_msvc.asm b/c/blake3_avx512_x86-64_windows_msvc.asm index b19efba..aa2351d 100644 --- a/c/blake3_avx512_x86-64_windows_msvc.asm +++ b/c/blake3_avx512_x86-64_windows_msvc.asm @@ -1,15 +1,15 @@ -public _blake3_hash_many_avx512 -public blake3_hash_many_avx512 -public blake3_compress_in_place_avx512 -public _blake3_compress_in_place_avx512 -public blake3_compress_xof_avx512 -public _blake3_compress_xof_avx512 +public _iroh_blake3_hash_many_avx512 +public iroh_blake3_hash_many_avx512 +public iroh_blake3_compress_in_place_avx512 +public _iroh_blake3_compress_in_place_avx512 +public iroh_blake3_compress_xof_avx512 +public _iroh_blake3_compress_xof_avx512 _TEXT SEGMENT ALIGN(16) 'CODE' ALIGN 16 -blake3_hash_many_avx512 PROC -_blake3_hash_many_avx512 PROC +iroh_blake3_hash_many_avx512 PROC +_iroh_blake3_hash_many_avx512 PROC push r15 push r14 push r13 @@ -2404,12 +2404,12 @@ endroundloop1: vmovdqu xmmword ptr [rbx+10H], xmm1 jmp unwind -_blake3_hash_many_avx512 ENDP -blake3_hash_many_avx512 ENDP +_iroh_blake3_hash_many_avx512 ENDP +iroh_blake3_hash_many_avx512 ENDP ALIGN 16 -blake3_compress_in_place_avx512 PROC -_blake3_compress_in_place_avx512 PROC +iroh_blake3_compress_in_place_avx512 PROC +_iroh_blake3_compress_in_place_avx512 PROC sub rsp, 72 vmovdqa xmmword ptr [rsp], xmm6 vmovdqa xmmword ptr [rsp+10H], xmm7 @@ -2498,12 +2498,12 @@ _blake3_compress_in_place_avx512 PROC vmovdqa xmm9, xmmword ptr [rsp+30H] add rsp, 72 ret -_blake3_compress_in_place_avx512 ENDP -blake3_compress_in_place_avx512 ENDP +_iroh_blake3_compress_in_place_avx512 ENDP +iroh_blake3_compress_in_place_avx512 ENDP ALIGN 16 -blake3_compress_xof_avx512 PROC -_blake3_compress_xof_avx512 PROC +iroh_blake3_compress_xof_avx512 PROC +_iroh_blake3_compress_xof_avx512 PROC sub rsp, 72 vmovdqa xmmword ptr [rsp], xmm6 vmovdqa xmmword ptr [rsp+10H], xmm7 @@ -2597,8 +2597,8 @@ _blake3_compress_xof_avx512 PROC vmovdqa xmm9, xmmword ptr [rsp+30H] add rsp, 72 ret -_blake3_compress_xof_avx512 ENDP -blake3_compress_xof_avx512 ENDP +_iroh_blake3_compress_xof_avx512 ENDP +iroh_blake3_compress_xof_avx512 ENDP _TEXT ENDS diff --git a/c/blake3_c_rust_bindings/benches/bench.rs b/c/blake3_c_rust_bindings/benches/bench.rs index 6e75351..b115d84 100644 --- a/c/blake3_c_rust_bindings/benches/bench.rs +++ b/c/blake3_c_rust_bindings/benches/bench.rs @@ -65,7 +65,7 @@ fn bench_single_compression_fn(b: &mut Bencher, f: CompressInPlaceFn) { fn bench_single_compression_portable(b: &mut Bencher) { bench_single_compression_fn( b, - blake3_c_rust_bindings::ffi::blake3_compress_in_place_portable, + blake3_c_rust_bindings::ffi::iroh_blake3_compress_in_place_portable, ); } @@ -77,7 +77,7 @@ fn bench_single_compression_sse2(b: &mut Bencher) { } bench_single_compression_fn( b, - blake3_c_rust_bindings::ffi::x86::blake3_compress_in_place_sse2, + blake3_c_rust_bindings::ffi::x86::iroh_blake3_compress_in_place_sse2, ); } @@ -89,7 +89,7 @@ fn bench_single_compression_sse41(b: &mut Bencher) { } bench_single_compression_fn( b, - blake3_c_rust_bindings::ffi::x86::blake3_compress_in_place_sse41, + blake3_c_rust_bindings::ffi::x86::iroh_blake3_compress_in_place_sse41, ); } @@ -100,7 +100,7 @@ fn bench_single_compression_avx512(b: &mut Bencher) { } bench_single_compression_fn( b, - blake3_c_rust_bindings::ffi::x86::blake3_compress_in_place_avx512, + blake3_c_rust_bindings::ffi::x86::iroh_blake3_compress_in_place_avx512, ); } @@ -154,7 +154,7 @@ fn bench_many_chunks_sse2(b: &mut Bencher) { } bench_many_chunks_fn( b, - blake3_c_rust_bindings::ffi::x86::blake3_hash_many_sse2, + blake3_c_rust_bindings::ffi::x86::iroh_blake3_hash_many_sse2, 4, ); } @@ -167,7 +167,7 @@ fn bench_many_chunks_sse41(b: &mut Bencher) { } bench_many_chunks_fn( b, - blake3_c_rust_bindings::ffi::x86::blake3_hash_many_sse41, + blake3_c_rust_bindings::ffi::x86::iroh_blake3_hash_many_sse41, 4, ); } @@ -180,7 +180,7 @@ fn bench_many_chunks_avx2(b: &mut Bencher) { } bench_many_chunks_fn( b, - blake3_c_rust_bindings::ffi::x86::blake3_hash_many_avx2, + blake3_c_rust_bindings::ffi::x86::iroh_blake3_hash_many_avx2, 8, ); } @@ -192,7 +192,7 @@ fn bench_many_chunks_avx512(b: &mut Bencher) { } bench_many_chunks_fn( b, - blake3_c_rust_bindings::ffi::x86::blake3_hash_many_avx512, + blake3_c_rust_bindings::ffi::x86::iroh_blake3_hash_many_avx512, 16, ); } @@ -246,7 +246,7 @@ fn bench_many_parents_sse2(b: &mut Bencher) { } bench_many_parents_fn( b, - blake3_c_rust_bindings::ffi::x86::blake3_hash_many_sse2, + blake3_c_rust_bindings::ffi::x86::iroh_blake3_hash_many_sse2, 4, ); } @@ -259,7 +259,7 @@ fn bench_many_parents_sse41(b: &mut Bencher) { } bench_many_parents_fn( b, - blake3_c_rust_bindings::ffi::x86::blake3_hash_many_sse41, + blake3_c_rust_bindings::ffi::x86::iroh_blake3_hash_many_sse41, 4, ); } @@ -272,7 +272,7 @@ fn bench_many_parents_avx2(b: &mut Bencher) { } bench_many_parents_fn( b, - blake3_c_rust_bindings::ffi::x86::blake3_hash_many_avx2, + blake3_c_rust_bindings::ffi::x86::iroh_blake3_hash_many_avx2, 8, ); } @@ -284,7 +284,7 @@ fn bench_many_parents_avx512(b: &mut Bencher) { } bench_many_parents_fn( b, - blake3_c_rust_bindings::ffi::x86::blake3_hash_many_avx512, + blake3_c_rust_bindings::ffi::x86::iroh_blake3_hash_many_avx512, 16, ); } diff --git a/c/blake3_c_rust_bindings/src/lib.rs b/c/blake3_c_rust_bindings/src/lib.rs index 41e4938..a8489f0 100644 --- a/c/blake3_c_rust_bindings/src/lib.rs +++ b/c/blake3_c_rust_bindings/src/lib.rs @@ -150,14 +150,14 @@ pub mod ffi { pub fn blake3_hasher_reset(self_: *mut blake3_hasher); // portable low-level functions - pub fn blake3_compress_in_place_portable( + pub fn iroh_blake3_compress_in_place_portable( cv: *mut u32, block: *const u8, block_len: u8, counter: u64, flags: u8, ); - pub fn blake3_compress_xof_portable( + pub fn iroh_blake3_compress_xof_portable( cv: *const u32, block: *const u8, block_len: u8, @@ -183,14 +183,14 @@ pub mod ffi { pub mod x86 { extern "C" { // SSE2 low level functions - pub fn blake3_compress_in_place_sse2( + pub fn iroh_blake3_compress_in_place_sse2( cv: *mut u32, block: *const u8, block_len: u8, counter: u64, flags: u8, ); - pub fn blake3_compress_xof_sse2( + pub fn iroh_blake3_compress_xof_sse2( cv: *const u32, block: *const u8, block_len: u8, @@ -198,7 +198,7 @@ pub mod ffi { flags: u8, out: *mut u8, ); - pub fn blake3_hash_many_sse2( + pub fn iroh_blake3_hash_many_sse2( inputs: *const *const u8, num_inputs: usize, blocks: usize, @@ -212,14 +212,14 @@ pub mod ffi { ); // SSE4.1 low level functions - pub fn blake3_compress_in_place_sse41( + pub fn iroh_blake3_compress_in_place_sse41( cv: *mut u32, block: *const u8, block_len: u8, counter: u64, flags: u8, ); - pub fn blake3_compress_xof_sse41( + pub fn iroh_blake3_compress_xof_sse41( cv: *const u32, block: *const u8, block_len: u8, @@ -227,7 +227,7 @@ pub mod ffi { flags: u8, out: *mut u8, ); - pub fn blake3_hash_many_sse41( + pub fn iroh_blake3_hash_many_sse41( inputs: *const *const u8, num_inputs: usize, blocks: usize, @@ -241,7 +241,7 @@ pub mod ffi { ); // AVX2 low level functions - pub fn blake3_hash_many_avx2( + pub fn iroh_blake3_hash_many_avx2( inputs: *const *const u8, num_inputs: usize, blocks: usize, @@ -255,7 +255,7 @@ pub mod ffi { ); // AVX-512 low level functions - pub fn blake3_compress_xof_avx512( + pub fn iroh_blake3_compress_xof_avx512( cv: *const u32, block: *const u8, block_len: u8, @@ -263,14 +263,14 @@ pub mod ffi { flags: u8, out: *mut u8, ); - pub fn blake3_compress_in_place_avx512( + pub fn iroh_blake3_compress_in_place_avx512( cv: *mut u32, block: *const u8, block_len: u8, counter: u64, flags: u8, ); - pub fn blake3_hash_many_avx512( + pub fn iroh_blake3_hash_many_avx512( inputs: *const *const u8, num_inputs: usize, blocks: usize, diff --git a/c/blake3_c_rust_bindings/src/test.rs b/c/blake3_c_rust_bindings/src/test.rs index 1fc077c..5de22af 100644 --- a/c/blake3_c_rust_bindings/src/test.rs +++ b/c/blake3_c_rust_bindings/src/test.rs @@ -110,7 +110,7 @@ pub fn test_compress_fn(compress_in_place_fn: CompressInPlaceFn, compress_xof_fn let mut portable_out = [0; 64]; unsafe { - crate::ffi::blake3_compress_xof_portable( + crate::ffi::iroh_blake3_compress_xof_portable( initial_state.as_ptr(), block.as_ptr(), block_len, @@ -151,8 +151,8 @@ pub fn test_compress_fn(compress_in_place_fn: CompressInPlaceFn, compress_xof_fn #[test] fn test_compress_portable() { test_compress_fn( - crate::ffi::blake3_compress_in_place_portable, - crate::ffi::blake3_compress_xof_portable, + crate::ffi::iroh_blake3_compress_in_place_portable, + crate::ffi::iroh_blake3_compress_xof_portable, ); } @@ -163,8 +163,8 @@ fn test_compress_sse2() { return; } test_compress_fn( - crate::ffi::x86::blake3_compress_in_place_sse2, - crate::ffi::x86::blake3_compress_xof_sse2, + crate::ffi::x86::iroh_blake3_compress_in_place_sse2, + crate::ffi::x86::iroh_blake3_compress_xof_sse2, ); } @@ -175,8 +175,8 @@ fn test_compress_sse41() { return; } test_compress_fn( - crate::ffi::x86::blake3_compress_in_place_sse41, - crate::ffi::x86::blake3_compress_xof_sse41, + crate::ffi::x86::iroh_blake3_compress_in_place_sse41, + crate::ffi::x86::iroh_blake3_compress_xof_sse41, ); } @@ -187,8 +187,8 @@ fn test_compress_avx512() { return; } test_compress_fn( - crate::ffi::x86::blake3_compress_in_place_avx512, - crate::ffi::x86::blake3_compress_xof_avx512, + crate::ffi::x86::iroh_blake3_compress_in_place_avx512, + crate::ffi::x86::iroh_blake3_compress_xof_avx512, ); } @@ -323,7 +323,7 @@ fn test_hash_many_sse2() { if !crate::sse2_detected() { return; } - test_hash_many_fn(crate::ffi::x86::blake3_hash_many_sse2); + test_hash_many_fn(crate::ffi::x86::iroh_blake3_hash_many_sse2); } #[test] @@ -332,7 +332,7 @@ fn test_hash_many_sse41() { if !crate::sse41_detected() { return; } - test_hash_many_fn(crate::ffi::x86::blake3_hash_many_sse41); + test_hash_many_fn(crate::ffi::x86::iroh_blake3_hash_many_sse41); } #[test] @@ -341,7 +341,7 @@ fn test_hash_many_avx2() { if !crate::avx2_detected() { return; } - test_hash_many_fn(crate::ffi::x86::blake3_hash_many_avx2); + test_hash_many_fn(crate::ffi::x86::iroh_blake3_hash_many_avx2); } #[test] @@ -350,7 +350,7 @@ fn test_hash_many_avx512() { if !crate::avx512_detected() { return; } - test_hash_many_fn(crate::ffi::x86::blake3_hash_many_avx512); + test_hash_many_fn(crate::ffi::x86::iroh_blake3_hash_many_avx512); } #[test] diff --git a/c/blake3_dispatch.c b/c/blake3_dispatch.c index af6c3da..db182aa 100644 --- a/c/blake3_dispatch.c +++ b/c/blake3_dispatch.c @@ -162,7 +162,7 @@ static } } -void blake3_compress_in_place(uint32_t cv[8], +void iroh_blake3_compress_in_place(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags) { @@ -171,27 +171,27 @@ void blake3_compress_in_place(uint32_t cv[8], MAYBE_UNUSED(features); #if !defined(BLAKE3_NO_AVX512) if (features & AVX512VL) { - blake3_compress_in_place_avx512(cv, block, block_len, counter, flags); + iroh_blake3_compress_in_place_avx512(cv, block, block_len, counter, flags); return; } #endif #if !defined(BLAKE3_NO_SSE41) if (features & SSE41) { - blake3_compress_in_place_sse41(cv, block, block_len, counter, flags); + iroh_blake3_compress_in_place_sse41(cv, block, block_len, counter, flags); return; } #endif #if !defined(BLAKE3_NO_SSE2) if (features & SSE2) { - blake3_compress_in_place_sse2(cv, block, block_len, counter, flags); + iroh_blake3_compress_in_place_sse2(cv, block, block_len, counter, flags); return; } #endif #endif - blake3_compress_in_place_portable(cv, block, block_len, counter, flags); + iroh_blake3_compress_in_place_portable(cv, block, block_len, counter, flags); } -void blake3_compress_xof(const uint32_t cv[8], +void iroh_blake3_compress_xof(const uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]) { @@ -200,24 +200,24 @@ void blake3_compress_xof(const uint32_t cv[8], MAYBE_UNUSED(features); #if !defined(BLAKE3_NO_AVX512) if (features & AVX512VL) { - blake3_compress_xof_avx512(cv, block, block_len, counter, flags, out); + iroh_blake3_compress_xof_avx512(cv, block, block_len, counter, flags, out); return; } #endif #if !defined(BLAKE3_NO_SSE41) if (features & SSE41) { - blake3_compress_xof_sse41(cv, block, block_len, counter, flags, out); + iroh_blake3_compress_xof_sse41(cv, block, block_len, counter, flags, out); return; } #endif #if !defined(BLAKE3_NO_SSE2) if (features & SSE2) { - blake3_compress_xof_sse2(cv, block, block_len, counter, flags, out); + iroh_blake3_compress_xof_sse2(cv, block, block_len, counter, flags, out); return; } #endif #endif - blake3_compress_xof_portable(cv, block, block_len, counter, flags, out); + iroh_blake3_compress_xof_portable(cv, block, block_len, counter, flags, out); } void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs, @@ -229,7 +229,7 @@ void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs, MAYBE_UNUSED(features); #if !defined(BLAKE3_NO_AVX512) if ((features & (AVX512F|AVX512VL)) == (AVX512F|AVX512VL)) { - blake3_hash_many_avx512(inputs, num_inputs, blocks, key, counter, + iroh_blake3_hash_many_avx512(inputs, num_inputs, blocks, key, counter, increment_counter, flags, flags_start, flags_end, out); return; @@ -237,7 +237,7 @@ void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs, #endif #if !defined(BLAKE3_NO_AVX2) if (features & AVX2) { - blake3_hash_many_avx2(inputs, num_inputs, blocks, key, counter, + iroh_blake3_hash_many_avx2(inputs, num_inputs, blocks, key, counter, increment_counter, flags, flags_start, flags_end, out); return; @@ -245,7 +245,7 @@ void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs, #endif #if !defined(BLAKE3_NO_SSE41) if (features & SSE41) { - blake3_hash_many_sse41(inputs, num_inputs, blocks, key, counter, + iroh_blake3_hash_many_sse41(inputs, num_inputs, blocks, key, counter, increment_counter, flags, flags_start, flags_end, out); return; @@ -253,7 +253,7 @@ void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs, #endif #if !defined(BLAKE3_NO_SSE2) if (features & SSE2) { - blake3_hash_many_sse2(inputs, num_inputs, blocks, key, counter, + iroh_blake3_hash_many_sse2(inputs, num_inputs, blocks, key, counter, increment_counter, flags, flags_start, flags_end, out); return; diff --git a/c/blake3_impl.h b/c/blake3_impl.h index 3ba9ceb..23504b4 100644 --- a/c/blake3_impl.h +++ b/c/blake3_impl.h @@ -177,12 +177,12 @@ INLINE void store_cv_words(uint8_t bytes_out[32], uint32_t cv_words[8]) { store32(&bytes_out[7 * 4], cv_words[7]); } -void blake3_compress_in_place(uint32_t cv[8], +void iroh_blake3_compress_in_place(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags); -void blake3_compress_xof(const uint32_t cv[8], +void iroh_blake3_compress_xof(const uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]); @@ -196,12 +196,12 @@ size_t blake3_simd_degree(void); // Declarations for implementation-specific functions. -void blake3_compress_in_place_portable(uint32_t cv[8], +void iroh_blake3_compress_in_place_portable(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags); -void blake3_compress_xof_portable(const uint32_t cv[8], +void iroh_blake3_compress_xof_portable(const uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]); @@ -214,54 +214,54 @@ void blake3_hash_many_portable(const uint8_t *const *inputs, size_t num_inputs, #if defined(IS_X86) #if !defined(BLAKE3_NO_SSE2) -void blake3_compress_in_place_sse2(uint32_t cv[8], +void iroh_blake3_compress_in_place_sse2(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags); -void blake3_compress_xof_sse2(const uint32_t cv[8], +void iroh_blake3_compress_xof_sse2(const uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]); -void blake3_hash_many_sse2(const uint8_t *const *inputs, size_t num_inputs, +void iroh_blake3_hash_many_sse2(const uint8_t *const *inputs, size_t num_inputs, size_t blocks, const uint32_t key[8], uint64_t counter, bool increment_counter, uint8_t flags, uint8_t flags_start, uint8_t flags_end, uint8_t *out); #endif #if !defined(BLAKE3_NO_SSE41) -void blake3_compress_in_place_sse41(uint32_t cv[8], +void iroh_blake3_compress_in_place_sse41(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags); -void blake3_compress_xof_sse41(const uint32_t cv[8], +void iroh_blake3_compress_xof_sse41(const uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]); -void blake3_hash_many_sse41(const uint8_t *const *inputs, size_t num_inputs, +void iroh_blake3_hash_many_sse41(const uint8_t *const *inputs, size_t num_inputs, size_t blocks, const uint32_t key[8], uint64_t counter, bool increment_counter, uint8_t flags, uint8_t flags_start, uint8_t flags_end, uint8_t *out); #endif #if !defined(BLAKE3_NO_AVX2) -void blake3_hash_many_avx2(const uint8_t *const *inputs, size_t num_inputs, +void iroh_blake3_hash_many_avx2(const uint8_t *const *inputs, size_t num_inputs, size_t blocks, const uint32_t key[8], uint64_t counter, bool increment_counter, uint8_t flags, uint8_t flags_start, uint8_t flags_end, uint8_t *out); #endif #if !defined(BLAKE3_NO_AVX512) -void blake3_compress_in_place_avx512(uint32_t cv[8], +void iroh_blake3_compress_in_place_avx512(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags); -void blake3_compress_xof_avx512(const uint32_t cv[8], +void iroh_blake3_compress_xof_avx512(const uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]); -void blake3_hash_many_avx512(const uint8_t *const *inputs, size_t num_inputs, +void iroh_blake3_hash_many_avx512(const uint8_t *const *inputs, size_t num_inputs, size_t blocks, const uint32_t key[8], uint64_t counter, bool increment_counter, uint8_t flags, uint8_t flags_start, diff --git a/c/blake3_neon.c b/c/blake3_neon.c index 8a818fc..2ddf75c 100644 --- a/c/blake3_neon.c +++ b/c/blake3_neon.c @@ -312,7 +312,7 @@ void blake3_hash4_neon(const uint8_t *const *inputs, size_t blocks, * ---------------------------------------------------------------------------- */ -void blake3_compress_in_place_portable(uint32_t cv[8], +void iroh_blake3_compress_in_place_portable(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags); @@ -331,7 +331,7 @@ INLINE void hash_one_neon(const uint8_t *input, size_t blocks, // TODO: Implement compress_neon. However note that according to // https://github.com/BLAKE2/BLAKE2/commit/7965d3e6e1b4193438b8d3a656787587d2579227, // compress_neon might not be any faster than compress_portable. - blake3_compress_in_place_portable(cv, input, BLAKE3_BLOCK_LEN, counter, + iroh_blake3_compress_in_place_portable(cv, input, BLAKE3_BLOCK_LEN, counter, block_flags); input = &input[BLAKE3_BLOCK_LEN]; blocks -= 1; diff --git a/c/blake3_portable.c b/c/blake3_portable.c index 062dd1b..8cfcd72 100644 --- a/c/blake3_portable.c +++ b/c/blake3_portable.c @@ -81,7 +81,7 @@ INLINE void compress_pre(uint32_t state[16], const uint32_t cv[8], round_fn(state, &block_words[0], 6); } -void blake3_compress_in_place_portable(uint32_t cv[8], +void iroh_blake3_compress_in_place_portable(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags) { @@ -97,7 +97,7 @@ void blake3_compress_in_place_portable(uint32_t cv[8], cv[7] = state[7] ^ state[15]; } -void blake3_compress_xof_portable(const uint32_t cv[8], +void iroh_blake3_compress_xof_portable(const uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]) { @@ -133,7 +133,7 @@ INLINE void hash_one_portable(const uint8_t *input, size_t blocks, if (blocks == 1) { block_flags |= flags_end; } - blake3_compress_in_place_portable(cv, input, BLAKE3_BLOCK_LEN, counter, + iroh_blake3_compress_in_place_portable(cv, input, BLAKE3_BLOCK_LEN, counter, block_flags); input = &input[BLAKE3_BLOCK_LEN]; blocks -= 1; diff --git a/c/blake3_sse2.c b/c/blake3_sse2.c index 691e1c6..60d2f88 100644 --- a/c/blake3_sse2.c +++ b/c/blake3_sse2.c @@ -257,7 +257,7 @@ INLINE void compress_pre(__m128i rows[4], const uint32_t cv[8], undiagonalize(&rows[0], &rows[2], &rows[3]); } -void blake3_compress_in_place_sse2(uint32_t cv[8], +void iroh_blake3_compress_in_place_sse2(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags) { @@ -267,7 +267,7 @@ void blake3_compress_in_place_sse2(uint32_t cv[8], storeu(xorv(rows[1], rows[3]), (uint8_t *)&cv[4]); } -void blake3_compress_xof_sse2(const uint32_t cv[8], +void iroh_blake3_compress_xof_sse2(const uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]) { @@ -529,7 +529,7 @@ INLINE void hash_one_sse2(const uint8_t *input, size_t blocks, if (blocks == 1) { block_flags |= flags_end; } - blake3_compress_in_place_sse2(cv, input, BLAKE3_BLOCK_LEN, counter, + iroh_blake3_compress_in_place_sse2(cv, input, BLAKE3_BLOCK_LEN, counter, block_flags); input = &input[BLAKE3_BLOCK_LEN]; blocks -= 1; @@ -538,7 +538,7 @@ INLINE void hash_one_sse2(const uint8_t *input, size_t blocks, memcpy(out, cv, BLAKE3_OUT_LEN); } -void blake3_hash_many_sse2(const uint8_t *const *inputs, size_t num_inputs, +void iroh_blake3_hash_many_sse2(const uint8_t *const *inputs, size_t num_inputs, size_t blocks, const uint32_t key[8], uint64_t counter, bool increment_counter, uint8_t flags, uint8_t flags_start, diff --git a/c/blake3_sse2_x86-64_unix.S b/c/blake3_sse2_x86-64_unix.S index 99f033f..fe763eb 100644 --- a/c/blake3_sse2_x86-64_unix.S +++ b/c/blake3_sse2_x86-64_unix.S @@ -13,20 +13,20 @@ #endif .intel_syntax noprefix -.global blake3_hash_many_sse2 -.global _blake3_hash_many_sse2 -.global blake3_compress_in_place_sse2 -.global _blake3_compress_in_place_sse2 -.global blake3_compress_xof_sse2 -.global _blake3_compress_xof_sse2 +.global iroh_blake3_hash_many_sse2 +.global _iroh_blake3_hash_many_sse2 +.global iroh_blake3_compress_in_place_sse2 +.global _iroh_blake3_compress_in_place_sse2 +.global iroh_blake3_compress_xof_sse2 +.global _iroh_blake3_compress_xof_sse2 #ifdef __APPLE__ .text #else .section .text #endif .p2align 6 -_blake3_hash_many_sse2: -blake3_hash_many_sse2: +_iroh_blake3_hash_many_sse2: +iroh_blake3_hash_many_sse2: _CET_ENDBR push r15 push r14 @@ -2024,8 +2024,8 @@ blake3_hash_many_sse2: jmp 4b .p2align 6 -blake3_compress_in_place_sse2: -_blake3_compress_in_place_sse2: +iroh_blake3_compress_in_place_sse2: +_iroh_blake3_compress_in_place_sse2: _CET_ENDBR movups xmm0, xmmword ptr [rdi] movups xmm1, xmmword ptr [rdi+0x10] @@ -2136,8 +2136,8 @@ _blake3_compress_in_place_sse2: ret .p2align 6 -blake3_compress_xof_sse2: -_blake3_compress_xof_sse2: +iroh_blake3_compress_xof_sse2: +_iroh_blake3_compress_xof_sse2: _CET_ENDBR movups xmm0, xmmword ptr [rdi] movups xmm1, xmmword ptr [rdi+0x10] diff --git a/c/blake3_sse2_x86-64_windows_gnu.S b/c/blake3_sse2_x86-64_windows_gnu.S index 4facb50..e5ba8c4 100644 --- a/c/blake3_sse2_x86-64_windows_gnu.S +++ b/c/blake3_sse2_x86-64_windows_gnu.S @@ -1,14 +1,14 @@ .intel_syntax noprefix -.global blake3_hash_many_sse2 -.global _blake3_hash_many_sse2 -.global blake3_compress_in_place_sse2 -.global _blake3_compress_in_place_sse2 -.global blake3_compress_xof_sse2 -.global _blake3_compress_xof_sse2 +.global iroh_blake3_hash_many_sse2 +.global _iroh_blake3_hash_many_sse2 +.global iroh_blake3_compress_in_place_sse2 +.global _iroh_blake3_compress_in_place_sse2 +.global iroh_blake3_compress_xof_sse2 +.global _iroh_blake3_compress_xof_sse2 .section .text .p2align 6 -_blake3_hash_many_sse2: -blake3_hash_many_sse2: +_iroh_blake3_hash_many_sse2: +iroh_blake3_hash_many_sse2: push r15 push r14 push r13 @@ -2035,8 +2035,8 @@ blake3_hash_many_sse2: jmp 4b .p2align 6 -blake3_compress_in_place_sse2: -_blake3_compress_in_place_sse2: +iroh_blake3_compress_in_place_sse2: +_iroh_blake3_compress_in_place_sse2: sub rsp, 120 movdqa xmmword ptr [rsp], xmm6 movdqa xmmword ptr [rsp+0x10], xmm7 @@ -2165,8 +2165,8 @@ _blake3_compress_in_place_sse2: .p2align 6 -_blake3_compress_xof_sse2: -blake3_compress_xof_sse2: +_iroh_blake3_compress_xof_sse2: +iroh_blake3_compress_xof_sse2: sub rsp, 120 movdqa xmmword ptr [rsp], xmm6 movdqa xmmword ptr [rsp+0x10], xmm7 diff --git a/c/blake3_sse2_x86-64_windows_msvc.asm b/c/blake3_sse2_x86-64_windows_msvc.asm index 507502f..1047261 100644 --- a/c/blake3_sse2_x86-64_windows_msvc.asm +++ b/c/blake3_sse2_x86-64_windows_msvc.asm @@ -1,15 +1,15 @@ -public _blake3_hash_many_sse2 -public blake3_hash_many_sse2 -public blake3_compress_in_place_sse2 -public _blake3_compress_in_place_sse2 -public blake3_compress_xof_sse2 -public _blake3_compress_xof_sse2 +public _iroh_blake3_hash_many_sse2 +public iroh_blake3_hash_many_sse2 +public iroh_blake3_compress_in_place_sse2 +public _iroh_blake3_compress_in_place_sse2 +public iroh_blake3_compress_xof_sse2 +public _iroh_blake3_compress_xof_sse2 _TEXT SEGMENT ALIGN(16) 'CODE' ALIGN 16 -blake3_hash_many_sse2 PROC -_blake3_hash_many_sse2 PROC +iroh_blake3_hash_many_sse2 PROC +_iroh_blake3_hash_many_sse2 PROC push r15 push r14 push r13 @@ -2034,11 +2034,11 @@ endroundloop1: movups xmmword ptr [rbx], xmm0 movups xmmword ptr [rbx+10H], xmm1 jmp unwind -_blake3_hash_many_sse2 ENDP -blake3_hash_many_sse2 ENDP +_iroh_blake3_hash_many_sse2 ENDP +iroh_blake3_hash_many_sse2 ENDP -blake3_compress_in_place_sse2 PROC -_blake3_compress_in_place_sse2 PROC +iroh_blake3_compress_in_place_sse2 PROC +_iroh_blake3_compress_in_place_sse2 PROC sub rsp, 120 movdqa xmmword ptr [rsp], xmm6 movdqa xmmword ptr [rsp+10H], xmm7 @@ -2164,12 +2164,12 @@ _blake3_compress_in_place_sse2 PROC movdqa xmm15, xmmword ptr [rsp+60H] add rsp, 120 ret -_blake3_compress_in_place_sse2 ENDP -blake3_compress_in_place_sse2 ENDP +_iroh_blake3_compress_in_place_sse2 ENDP +iroh_blake3_compress_in_place_sse2 ENDP ALIGN 16 -blake3_compress_xof_sse2 PROC -_blake3_compress_xof_sse2 PROC +iroh_blake3_compress_xof_sse2 PROC +_iroh_blake3_compress_xof_sse2 PROC sub rsp, 120 movdqa xmmword ptr [rsp], xmm6 movdqa xmmword ptr [rsp+10H], xmm7 @@ -2302,8 +2302,8 @@ _blake3_compress_xof_sse2 PROC movdqa xmm15, xmmword ptr [rsp+60H] add rsp, 120 ret -_blake3_compress_xof_sse2 ENDP -blake3_compress_xof_sse2 ENDP +_iroh_blake3_compress_xof_sse2 ENDP +iroh_blake3_compress_xof_sse2 ENDP _TEXT ENDS diff --git a/c/blake3_sse41.c b/c/blake3_sse41.c index 4653a85..2e303f5 100644 --- a/c/blake3_sse41.c +++ b/c/blake3_sse41.c @@ -251,7 +251,7 @@ INLINE void compress_pre(__m128i rows[4], const uint32_t cv[8], undiagonalize(&rows[0], &rows[2], &rows[3]); } -void blake3_compress_in_place_sse41(uint32_t cv[8], +void iroh_blake3_compress_in_place_sse41(uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags) { @@ -261,7 +261,7 @@ void blake3_compress_in_place_sse41(uint32_t cv[8], storeu(xorv(rows[1], rows[3]), (uint8_t *)&cv[4]); } -void blake3_compress_xof_sse41(const uint32_t cv[8], +void iroh_blake3_compress_xof_sse41(const uint32_t cv[8], const uint8_t block[BLAKE3_BLOCK_LEN], uint8_t block_len, uint64_t counter, uint8_t flags, uint8_t out[64]) { @@ -523,7 +523,7 @@ INLINE void hash_one_sse41(const uint8_t *input, size_t blocks, if (blocks == 1) { block_flags |= flags_end; } - blake3_compress_in_place_sse41(cv, input, BLAKE3_BLOCK_LEN, counter, + iroh_blake3_compress_in_place_sse41(cv, input, BLAKE3_BLOCK_LEN, counter, block_flags); input = &input[BLAKE3_BLOCK_LEN]; blocks -= 1; @@ -532,7 +532,7 @@ INLINE void hash_one_sse41(const uint8_t *input, size_t blocks, memcpy(out, cv, BLAKE3_OUT_LEN); } -void blake3_hash_many_sse41(const uint8_t *const *inputs, size_t num_inputs, +void iroh_blake3_hash_many_sse41(const uint8_t *const *inputs, size_t num_inputs, size_t blocks, const uint32_t key[8], uint64_t counter, bool increment_counter, uint8_t flags, uint8_t flags_start, diff --git a/c/blake3_sse41_x86-64_unix.S b/c/blake3_sse41_x86-64_unix.S index a3ff642..819fd48 100644 --- a/c/blake3_sse41_x86-64_unix.S +++ b/c/blake3_sse41_x86-64_unix.S @@ -13,20 +13,20 @@ #endif .intel_syntax noprefix -.global blake3_hash_many_sse41 -.global _blake3_hash_many_sse41 -.global blake3_compress_in_place_sse41 -.global _blake3_compress_in_place_sse41 -.global blake3_compress_xof_sse41 -.global _blake3_compress_xof_sse41 +.global iroh_blake3_hash_many_sse41 +.global _iroh_blake3_hash_many_sse41 +.global iroh_blake3_compress_in_place_sse41 +.global _iroh_blake3_compress_in_place_sse41 +.global iroh_blake3_compress_xof_sse41 +.global _iroh_blake3_compress_xof_sse41 #ifdef __APPLE__ .text #else .section .text #endif .p2align 6 -_blake3_hash_many_sse41: -blake3_hash_many_sse41: +_iroh_blake3_hash_many_sse41: +iroh_blake3_hash_many_sse41: _CET_ENDBR push r15 push r14 @@ -1787,8 +1787,8 @@ blake3_hash_many_sse41: jmp 4b .p2align 6 -blake3_compress_in_place_sse41: -_blake3_compress_in_place_sse41: +iroh_blake3_compress_in_place_sse41: +_iroh_blake3_compress_in_place_sse41: _CET_ENDBR movups xmm0, xmmword ptr [rdi] movups xmm1, xmmword ptr [rdi+0x10] @@ -1888,8 +1888,8 @@ _blake3_compress_in_place_sse41: ret .p2align 6 -blake3_compress_xof_sse41: -_blake3_compress_xof_sse41: +iroh_blake3_compress_xof_sse41: +_iroh_blake3_compress_xof_sse41: _CET_ENDBR movups xmm0, xmmword ptr [rdi] movups xmm1, xmmword ptr [rdi+0x10] diff --git a/c/blake3_sse41_x86-64_windows_gnu.S b/c/blake3_sse41_x86-64_windows_gnu.S index 02083f9..83c3b92 100644 --- a/c/blake3_sse41_x86-64_windows_gnu.S +++ b/c/blake3_sse41_x86-64_windows_gnu.S @@ -1,14 +1,14 @@ .intel_syntax noprefix -.global blake3_hash_many_sse41 -.global _blake3_hash_many_sse41 -.global blake3_compress_in_place_sse41 -.global _blake3_compress_in_place_sse41 -.global blake3_compress_xof_sse41 -.global _blake3_compress_xof_sse41 +.global iroh_blake3_hash_many_sse41 +.global _iroh_blake3_hash_many_sse41 +.global iroh_blake3_compress_in_place_sse41 +.global _iroh_blake3_compress_in_place_sse41 +.global iroh_blake3_compress_xof_sse41 +.global _iroh_blake3_compress_xof_sse41 .section .text .p2align 6 -_blake3_hash_many_sse41: -blake3_hash_many_sse41: +_iroh_blake3_hash_many_sse41: +iroh_blake3_hash_many_sse41: push r15 push r14 push r13 @@ -1798,8 +1798,8 @@ blake3_hash_many_sse41: jmp 4b .p2align 6 -blake3_compress_in_place_sse41: -_blake3_compress_in_place_sse41: +iroh_blake3_compress_in_place_sse41: +_iroh_blake3_compress_in_place_sse41: sub rsp, 120 movdqa xmmword ptr [rsp], xmm6 movdqa xmmword ptr [rsp+0x10], xmm7 @@ -1917,8 +1917,8 @@ _blake3_compress_in_place_sse41: .p2align 6 -_blake3_compress_xof_sse41: -blake3_compress_xof_sse41: +_iroh_blake3_compress_xof_sse41: +iroh_blake3_compress_xof_sse41: sub rsp, 120 movdqa xmmword ptr [rsp], xmm6 movdqa xmmword ptr [rsp+0x10], xmm7 diff --git a/c/blake3_sse41_x86-64_windows_msvc.asm b/c/blake3_sse41_x86-64_windows_msvc.asm index 8966c7b..f8f6336 100644 --- a/c/blake3_sse41_x86-64_windows_msvc.asm +++ b/c/blake3_sse41_x86-64_windows_msvc.asm @@ -1,15 +1,15 @@ -public _blake3_hash_many_sse41 -public blake3_hash_many_sse41 -public blake3_compress_in_place_sse41 -public _blake3_compress_in_place_sse41 -public blake3_compress_xof_sse41 -public _blake3_compress_xof_sse41 +public _iroh_blake3_hash_many_sse41 +public iroh_blake3_hash_many_sse41 +public iroh_blake3_compress_in_place_sse41 +public _iroh_blake3_compress_in_place_sse41 +public iroh_blake3_compress_xof_sse41 +public _iroh_blake3_compress_xof_sse41 _TEXT SEGMENT ALIGN(16) 'CODE' ALIGN 16 -blake3_hash_many_sse41 PROC -_blake3_hash_many_sse41 PROC +iroh_blake3_hash_many_sse41 PROC +_iroh_blake3_hash_many_sse41 PROC push r15 push r14 push r13 @@ -1797,11 +1797,11 @@ endroundloop1: movups xmmword ptr [rbx], xmm0 movups xmmword ptr [rbx+10H], xmm1 jmp unwind -_blake3_hash_many_sse41 ENDP -blake3_hash_many_sse41 ENDP +_iroh_blake3_hash_many_sse41 ENDP +iroh_blake3_hash_many_sse41 ENDP -blake3_compress_in_place_sse41 PROC -_blake3_compress_in_place_sse41 PROC +iroh_blake3_compress_in_place_sse41 PROC +_iroh_blake3_compress_in_place_sse41 PROC sub rsp, 120 movdqa xmmword ptr [rsp], xmm6 movdqa xmmword ptr [rsp+10H], xmm7 @@ -1916,12 +1916,12 @@ _blake3_compress_in_place_sse41 PROC movdqa xmm15, xmmword ptr [rsp+60H] add rsp, 120 ret -_blake3_compress_in_place_sse41 ENDP -blake3_compress_in_place_sse41 ENDP +_iroh_blake3_compress_in_place_sse41 ENDP +iroh_blake3_compress_in_place_sse41 ENDP ALIGN 16 -blake3_compress_xof_sse41 PROC -_blake3_compress_xof_sse41 PROC +iroh_blake3_compress_xof_sse41 PROC +_iroh_blake3_compress_xof_sse41 PROC sub rsp, 120 movdqa xmmword ptr [rsp], xmm6 movdqa xmmword ptr [rsp+10H], xmm7 @@ -2043,8 +2043,8 @@ _blake3_compress_xof_sse41 PROC movdqa xmm15, xmmword ptr [rsp+60H] add rsp, 120 ret -_blake3_compress_xof_sse41 ENDP -blake3_compress_xof_sse41 ENDP +_iroh_blake3_compress_xof_sse41 ENDP +iroh_blake3_compress_xof_sse41 ENDP _TEXT ENDS diff --git a/src/ffi_avx2.rs b/src/ffi_avx2.rs index 33961e9..ba1b22c 100644 --- a/src/ffi_avx2.rs +++ b/src/ffi_avx2.rs @@ -18,7 +18,7 @@ pub unsafe fn hash_many( // array, but the C implementations don't. Even though this is an unsafe // function, assert the bounds here. assert!(out.len() >= inputs.len() * OUT_LEN); - ffi::blake3_hash_many_avx2( + ffi::iroh_blake3_hash_many_avx2( inputs.as_ptr() as *const *const u8, inputs.len(), N / BLOCK_LEN, @@ -34,7 +34,7 @@ pub unsafe fn hash_many( pub mod ffi { extern "C" { - pub fn blake3_hash_many_avx2( + pub fn iroh_blake3_hash_many_avx2( inputs: *const *const u8, num_inputs: usize, blocks: usize, diff --git a/src/ffi_avx512.rs b/src/ffi_avx512.rs index 884f481..d9fc981 100644 --- a/src/ffi_avx512.rs +++ b/src/ffi_avx512.rs @@ -8,7 +8,13 @@ pub unsafe fn compress_in_place( counter: u64, flags: u8, ) { - ffi::blake3_compress_in_place_avx512(cv.as_mut_ptr(), block.as_ptr(), block_len, counter, flags) + ffi::iroh_blake3_compress_in_place_avx512( + cv.as_mut_ptr(), + block.as_ptr(), + block_len, + counter, + flags, + ) } // Unsafe because this may only be called on platforms supporting AVX-512. @@ -20,7 +26,7 @@ pub unsafe fn compress_xof( flags: u8, ) -> [u8; 64] { let mut out = [0u8; 64]; - ffi::blake3_compress_xof_avx512( + ffi::iroh_blake3_compress_xof_avx512( cv.as_ptr(), block.as_ptr(), block_len, @@ -46,7 +52,7 @@ pub unsafe fn hash_many( // array, but the C implementations don't. Even though this is an unsafe // function, assert the bounds here. assert!(out.len() >= inputs.len() * OUT_LEN); - ffi::blake3_hash_many_avx512( + ffi::iroh_blake3_hash_many_avx512( inputs.as_ptr() as *const *const u8, inputs.len(), N / BLOCK_LEN, @@ -62,14 +68,14 @@ pub unsafe fn hash_many( pub mod ffi { extern "C" { - pub fn blake3_compress_in_place_avx512( + pub fn iroh_blake3_compress_in_place_avx512( cv: *mut u32, block: *const u8, block_len: u8, counter: u64, flags: u8, ); - pub fn blake3_compress_xof_avx512( + pub fn iroh_blake3_compress_xof_avx512( cv: *const u32, block: *const u8, block_len: u8, @@ -77,7 +83,7 @@ pub mod ffi { flags: u8, out: *mut u8, ); - pub fn blake3_hash_many_avx512( + pub fn iroh_blake3_hash_many_avx512( inputs: *const *const u8, num_inputs: usize, blocks: usize, diff --git a/src/ffi_neon.rs b/src/ffi_neon.rs index 54d07a4..29b836f 100644 --- a/src/ffi_neon.rs +++ b/src/ffi_neon.rs @@ -34,7 +34,7 @@ pub unsafe fn hash_many( // implementation for 1x compression. However, we expose the portable Rust // implementation here instead, to avoid linking in unnecessary code. #[no_mangle] -pub extern "C" fn blake3_compress_in_place_portable( +pub extern "C" fn iroh_blake3_compress_in_place_portable( cv: *mut u32, block: *const u8, block_len: u8, diff --git a/src/ffi_sse2.rs b/src/ffi_sse2.rs index 1c5da81..9dc0356 100644 --- a/src/ffi_sse2.rs +++ b/src/ffi_sse2.rs @@ -8,7 +8,13 @@ pub unsafe fn compress_in_place( counter: u64, flags: u8, ) { - ffi::blake3_compress_in_place_sse2(cv.as_mut_ptr(), block.as_ptr(), block_len, counter, flags) + ffi::iroh_blake3_compress_in_place_sse2( + cv.as_mut_ptr(), + block.as_ptr(), + block_len, + counter, + flags, + ) } // Unsafe because this may only be called on platforms supporting SSE2. @@ -20,7 +26,7 @@ pub unsafe fn compress_xof( flags: u8, ) -> [u8; 64] { let mut out = [0u8; 64]; - ffi::blake3_compress_xof_sse2( + ffi::iroh_blake3_compress_xof_sse2( cv.as_ptr(), block.as_ptr(), block_len, @@ -46,7 +52,7 @@ pub unsafe fn hash_many( // array, but the C implementations don't. Even though this is an unsafe // function, assert the bounds here. assert!(out.len() >= inputs.len() * OUT_LEN); - ffi::blake3_hash_many_sse2( + ffi::iroh_blake3_hash_many_sse2( inputs.as_ptr() as *const *const u8, inputs.len(), N / BLOCK_LEN, @@ -62,14 +68,14 @@ pub unsafe fn hash_many( pub mod ffi { extern "C" { - pub fn blake3_compress_in_place_sse2( + pub fn iroh_blake3_compress_in_place_sse2( cv: *mut u32, block: *const u8, block_len: u8, counter: u64, flags: u8, ); - pub fn blake3_compress_xof_sse2( + pub fn iroh_blake3_compress_xof_sse2( cv: *const u32, block: *const u8, block_len: u8, @@ -77,7 +83,7 @@ pub mod ffi { flags: u8, out: *mut u8, ); - pub fn blake3_hash_many_sse2( + pub fn iroh_blake3_hash_many_sse2( inputs: *const *const u8, num_inputs: usize, blocks: usize, diff --git a/src/ffi_sse41.rs b/src/ffi_sse41.rs index 62989c5..2da54ee 100644 --- a/src/ffi_sse41.rs +++ b/src/ffi_sse41.rs @@ -8,7 +8,13 @@ pub unsafe fn compress_in_place( counter: u64, flags: u8, ) { - ffi::blake3_compress_in_place_sse41(cv.as_mut_ptr(), block.as_ptr(), block_len, counter, flags) + ffi::iroh_blake3_compress_in_place_sse41( + cv.as_mut_ptr(), + block.as_ptr(), + block_len, + counter, + flags, + ) } // Unsafe because this may only be called on platforms supporting SSE4.1. @@ -20,7 +26,7 @@ pub unsafe fn compress_xof( flags: u8, ) -> [u8; 64] { let mut out = [0u8; 64]; - ffi::blake3_compress_xof_sse41( + ffi::iroh_blake3_compress_xof_sse41( cv.as_ptr(), block.as_ptr(), block_len, @@ -46,7 +52,7 @@ pub unsafe fn hash_many( // array, but the C implementations don't. Even though this is an unsafe // function, assert the bounds here. assert!(out.len() >= inputs.len() * OUT_LEN); - ffi::blake3_hash_many_sse41( + ffi::iroh_blake3_hash_many_sse41( inputs.as_ptr() as *const *const u8, inputs.len(), N / BLOCK_LEN, @@ -62,14 +68,14 @@ pub unsafe fn hash_many( pub mod ffi { extern "C" { - pub fn blake3_compress_in_place_sse41( + pub fn iroh_blake3_compress_in_place_sse41( cv: *mut u32, block: *const u8, block_len: u8, counter: u64, flags: u8, ); - pub fn blake3_compress_xof_sse41( + pub fn iroh_blake3_compress_xof_sse41( cv: *const u32, block: *const u8, block_len: u8, @@ -77,7 +83,7 @@ pub mod ffi { flags: u8, out: *mut u8, ); - pub fn blake3_hash_many_sse41( + pub fn iroh_blake3_hash_many_sse41( inputs: *const *const u8, num_inputs: usize, blocks: usize, diff --git a/src/guts.rs b/src/guts.rs index c4bafcf..f87cc74 100644 --- a/src/guts.rs +++ b/src/guts.rs @@ -156,7 +156,11 @@ mod test { } } - let data = (0..1024 << 4).map(|i| i as u8).collect::>(); + let mut data = [0u8; 1024 << 4]; + for (i, d) in data.iter_mut().enumerate() { + *d = i as u8; + } + let data = data; for block_log in 0..4 { let block_size = 1usize << block_log; let block_size_u64 = block_size as u64; diff --git a/src/lib.rs b/src/lib.rs index d3b0a33..5f25ec2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,10 +6,10 @@ //! ``` //! # fn main() -> Result<(), Box> { //! // Hash an input all at once. -//! let hash1 = blake3::hash(b"foobarbaz"); +//! let hash1 = iroh_blake3::hash(b"foobarbaz"); //! //! // Hash an input incrementally. -//! let mut hasher = blake3::Hasher::new(); +//! let mut hasher = iroh_blake3::Hasher::new(); //! hasher.update(b"foo"); //! hasher.update(b"bar"); //! hasher.update(b"baz"); @@ -933,18 +933,18 @@ fn parent_node_output( /// ``` /// # fn main() -> Result<(), Box> { /// // Hash an input incrementally. -/// let mut hasher = blake3::Hasher::new(); +/// let mut hasher = iroh_blake3::Hasher::new(); /// hasher.update(b"foo"); /// hasher.update(b"bar"); /// hasher.update(b"baz"); -/// assert_eq!(hasher.finalize(), blake3::hash(b"foobarbaz")); +/// assert_eq!(hasher.finalize(), iroh_blake3::hash(b"foobarbaz")); /// /// // Extended output. OutputReader also implements Read and Seek. /// # #[cfg(feature = "std")] { /// let mut output = [0; 1000]; /// let mut output_reader = hasher.finalize_xof(); /// output_reader.fill(&mut output); -/// assert_eq!(&output[..32], blake3::hash(b"foobarbaz").as_bytes()); +/// assert_eq!(&output[..32], iroh_blake3::hash(b"foobarbaz").as_bytes()); /// # } /// # Ok(()) /// # } diff --git a/test_vectors/Cargo.toml b/test_vectors/Cargo.toml index 87a9eba..3711169 100644 --- a/test_vectors/Cargo.toml +++ b/test_vectors/Cargo.toml @@ -4,14 +4,14 @@ version = "0.0.0" edition = "2021" [features] -neon = ["blake3/neon"] -prefer_intrinsics = ["blake3/prefer_intrinsics"] -pure = ["blake3/pure"] +neon = ["iroh-blake3/neon"] +prefer_intrinsics = ["iroh-blake3/prefer_intrinsics"] +pure = ["iroh-blake3/pure"] [dependencies] # If you ever change these path dependencies, you'll probably need to update # cross_test.sh, or CI will break. I'm sorry >.< -blake3 = { path = "../" } +iroh-blake3 = { path = "../" } hex = "0.4.0" reference_impl = { path = "../reference_impl" } serde = { version = "1.0", features = ["derive"] } diff --git a/test_vectors/cross_test.sh b/test_vectors/cross_test.sh index c4d280c..81c7c58 100755 --- a/test_vectors/cross_test.sh +++ b/test_vectors/cross_test.sh @@ -19,7 +19,7 @@ mv blake3/test_vectors . mv blake3/reference_impl test_vectors mv blake3 test_vectors cd test_vectors -sed -i 's|blake3 = { path = "../" }|blake3 = { path = "./blake3" }|' Cargo.toml +sed -i 's|iroh-blake3 = { path = "../" }|iroh-blake3 = { path = "./blake3" }|' Cargo.toml sed -i 's|reference_impl = { path = "../reference_impl" }|reference_impl = { path = "reference_impl" }|' Cargo.toml cross test "$@" diff --git a/test_vectors/src/lib.rs b/test_vectors/src/lib.rs index 6a4c798..b48ec53 100644 --- a/test_vectors/src/lib.rs +++ b/test_vectors/src/lib.rs @@ -1,4 +1,5 @@ -use blake3::guts::{BLOCK_LEN, CHUNK_LEN}; +use iroh_blake3 as blake3; +use iroh_blake3::guts::{BLOCK_LEN, CHUNK_LEN}; use serde::{Deserialize, Serialize}; // A non-multiple of 4 is important, since one possible bug is to fail to emit