1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-05-13 07:26:15 +02:00
Commit Graph

87 Commits

Author SHA1 Message Date
rsdy 0a0bb7126e Implement better target detection for NEON 2021-10-07 12:41:53 +01:00
Jack O'Connor c4582c9779 clarify that OutputReader::position is equivalent to Seek::stream_position 2021-09-10 12:59:13 -04:00
Jack O'Connor 3baa54476a link to the paper in the derive_key docs 2021-09-10 12:48:58 -04:00
Jack O'Connor 5aef6849bb update README examples 2021-07-25 12:42:09 -04:00
Jack O'Connor 037de38bfe upgrade to arrayvec 0.7.0
This version uses const generics, which bumps our minimum supported
compiler version to 1.51.
2021-05-18 12:28:29 -04:00
Jack O'Connor 7cd208afcf explicitly document the properties of short outputs
Suggested by @joshtriplett at:
https://github.com/BLAKE3-team/BLAKE3/issues/168#issuecomment-829609667
2021-05-18 11:02:05 -04:00
Jack O'Connor 4b7babbe99 more cleaup of undocumented API 2021-03-28 20:04:51 -04:00
Jack O'Connor 9ef2f4d9a8 implement Display for Hash 2021-03-21 21:14:44 -04:00
Jack O'Connor 05292a018b get rid of the standalone "*_rayon" functions
These clutter the toplevel API, and their prominence might lead callers
to prefer them as a first resort, which probably isn't a good idea.
Restricting multithreading to `Hasher::update_rayon` feels better,
similar to what we've done with `Hasher::finalize_xof`. (But I think
`update_rayon` is still an improvement over the trait-based interface
that it replaced.)
2021-03-21 21:14:13 -04:00
Jack O'Connor 07b746b1b4 gate digest and crypto-mac implementations behind "traits-preview"
This approach was suggested by @tarcieri at
https://github.com/BLAKE3-team/BLAKE3/pull/157.
2021-03-21 15:53:26 -04:00
Jack O'Connor 7155e5bb71 Rayon-related doc fixes 2021-03-20 15:25:14 -04:00
Jack O'Connor b228f46e03 add *_rayon methods 2021-03-14 00:26:18 -05:00
Jack O'Connor ea72822620 re-privatize the Join trait 2021-03-14 00:08:21 -05:00
Jack O'Connor 71d67e0810 make derive_key() return an array 2021-02-28 18:10:59 -05:00
Jack O'Connor 134bb24686 impl PartialEq<[u8]> for Hash 2021-02-28 17:50:06 -05:00
Jack O'Connor 0c26ed52a8 rename ParseError to HexError and update docs 2021-02-04 15:43:44 -05:00
Jack O'Connor cc21dd0132 implement Error for ParseError, make it opaque, and support from_hex(&[u8]) 2021-02-04 15:36:29 -05:00
Jack O'Connor 9e08f5c38d merge "Adding from_hex and implementing FromStr for Hash"
https://github.com/BLAKE3-team/BLAKE3/pull/24
2021-02-03 11:53:56 -05:00
Jack O'Connor 004b39a350 cargo fmt 2020-09-10 15:55:02 -04:00
Samuel Neves 3340e32c7f
Merge pull request #110 from mkrupcale/sse2
Add SSE2 implementations
2020-08-31 18:56:55 +01:00
Nikolai Vazquez 324090b2c3 Implement `fmt::Debug` using builders
This enables pretty printing via `{:#?}`. The normal style for `{:?}` is
kept exactly the same.
2020-08-31 12:04:40 -04:00
Matthew Krupcale d91f20dd29 Start SSE2 implementation based on SSE4.1 version
Wire up basic functions and features for SSE2 support using the SSE4.1 version
as a basis without implementing the SSE2 instructions yet.

 * Cargo.toml: add no_sse2 feature
 * benches/bench.rs: wire SSE2 benchmarks
 * build.rs: add SSE2 rust intrinsics and assembly builds
 * c/Makefile.testing: add SSE2 C and assembly targets
 * c/README.md: add SSE2 to C build instructions
 * c/blake3_c_rust_bindings/build.rs: add SSE2 C rust binding builds
 * c/blake3_c_rust_bindings/src/lib.rs: add SSE2 C rust bindings
 * c/blake3_dispatch.c: add SSE2 C dispatch
 * c/blake3_impl.h: add SSE2 C function prototypes
 * c/blake3_sse2.c: add SSE2 C intrinsic file starting with SSE4.1 version
 * c/blake3_sse2_x86-64_{unix.S,windows_gnu.S,windows_msvc.asm}: add SSE2
   assembly files starting with SSE4.1 version
 * src/ffi_sse2.rs: add rust implementation using SSE2 C rust bindings
 * src/lib.rs: add SSE2 rust intrinsics and SSE2 C rust binding rust SSE2 module
   configurations
 * src/platform.rs: add SSE2 rust platform detection and dispatch
 * src/rust_sse2.rs: add SSE2 rust intrinsic file starting with SSE4.1 version
 * tools/instruction_set_support/src/main.rs: add SSE2 feature detection
2020-08-24 00:54:46 -04:00
Jack O'Connor 09cc03614d the same hex example for rustdocs 2020-08-14 11:33:53 -04:00
Jack O'Connor c908847c3f shrink a stack array that's twice as big as it needs to be
It looks like I originally made this mistake when I was copying code
from the baokeshed prototype (a274a9b0fa),
and then it got replicated into the C implementation later.
2020-06-26 16:16:55 -04:00
Jack O'Connor ca9687e36c fix another small mistake in the docs 2020-05-23 15:16:02 -04:00
Jack O'Connor b8cdcb1f84 automatically fall back to the pure Rust build
There are two scenarios where compiling AVX-512 C or assembly code might
not work:

1. There might not be a C compiler installed at all. Most commonly this
   is either in cross-compiling situations, or with the Windows GNU
   target.
2. The installed C compiler might not support e.g. -mavx512f, because
   it's too old.

In both of these cases, print a relevant warning, and then automatically
fall back to using the pure Rust intrinsics build.

Note that this only affects x86 targets. Other targets always use pure
Rust, unless the "neon" feature is enabled.
2020-04-01 19:13:15 -04:00
Jack O'Connor e06a0f255a refactor the Cargo feature set
The biggest change here is that assembly implementations are enabled by
default.

Added features:
- "pure" (Pure Rust, with no C or assembly implementations.)

Removed features:
- "c" (Now basically the default.)

Renamed features;
- "c_prefer_intrinsics" -> "prefer_intrinsics"
- "c_neon" -> "neon"

Unchanged:
- "rayon"
- "std" (Still the only feature on by default.)
2020-03-29 18:02:03 -04:00
Jack O'Connor 1f529a841c add an example of parsing a Hash from a hex string
Suggested by @zaynetro:
https://github.com/BLAKE3-team/BLAKE3/pull/24#issuecomment-594369061
2020-03-05 10:54:22 -05:00
Jack O'Connor 0432f9c7a3 some comment typos 2020-02-27 09:52:46 -05:00
Jack O'Connor 8d84cfc0af remove a mis-optimization that hurt performance for uneven updates
If the total number of chunks hashed so far is e.g. 1, and update() is
called with e.g. 8 more chunks, we can't compress all 8 together. We
have to break the input up, to make sure that that 1 lone chunk CV gets
merged with its proper sibling, and that in general the correct layout
of the tree is preserved. What we should do is hash 1-2-4-1 chunks of
input, using increasing powers of 2 (with some cleanup at the end). What
we were doing was 2-2-2-2 chunks. This was the result of a mistaken
optimization that got us stuck with an always-odd number of chunks so
far.

Fixes https://github.com/BLAKE3-team/BLAKE3/issues/69.
2020-02-25 11:40:37 -05:00
Jack O'Connor 5dea889834 add a performance note and a usage example for Hasher 2020-02-12 14:38:35 -05:00
Jack O'Connor 38a46ba8ae document optional Cargo features on docs.rs 2020-02-12 14:20:11 -05:00
Jack O'Connor efbfa0463c integrate assembly implementations into the blake3 crate 2020-02-12 10:23:17 -05:00
Jack O'Connor fc219f4f8d Hasher::update_with_join
This is a new interface that allows the caller to provide a
multi-threading implementation. It's defined in terms of a new `Join`
trait, for which we provide two implementations, `SerialJoin` and
`RayonJoin`. This lets the caller control when multi-threading is used,
rather than the previous all-or-nothing design of the "rayon" feature.

Although existing callers should keep working, this is a compatibility
break, because callers who were relying on automatic multi-threading
before will now be single-threaded. Thus the next release of this crate
will need to be version 0.2.

See https://github.com/BLAKE3-team/BLAKE3/issues/25 and
https://github.com/BLAKE3-team/BLAKE3/issues/54.
2020-02-06 15:07:15 -05:00
Jack O'Connor 24071db346 re-export digest and crypto_mac 2020-02-04 10:02:46 -05:00
Cesar Eduardo Barros a3d42f724d Inline wrapper methods 2020-02-03 17:29:25 -05:00
Jack O'Connor 0651736ff4 make the inherent reset() method return &mut self 2020-02-03 10:21:27 -05:00
Jack O'Connor 9ffe377d45 implement crypto_mac::Mac 2020-02-03 10:18:02 -05:00
Jack O'Connor bcd424cab6 mention the digest traits in the docs 2020-02-02 17:40:30 -05:00
Jack O'Connor 9bab77d2cf implement traits from the digest crate 2020-02-02 17:28:22 -05:00
Jack O'Connor e603983647 add Hasher::reset
Closes https://github.com/BLAKE3-team/BLAKE3/issues/41.
2020-02-02 16:38:29 -05:00
Jack O'Connor 78e858d050 expand comments about lazy merging 2020-01-21 12:09:42 -05:00
Jack O'Connor ccadbad244 stack size in the optimized impl should be MAX_DEPTH + 1 2020-01-21 11:41:20 -05:00
Jack O'Connor 67262dff31 double the maximum incremental subtree size
Because compress_subtree_to_parent_node effectively cuts its input in
half, we can give it an input that's twice as big, without violating the
CV stack invariant.
2020-01-20 19:25:55 -05:00
Jack O'Connor a3147eb909 comment about parallelism 2020-01-18 14:32:52 -05:00
phayes c2f90dfdb0
Adding tests for error conditions 2020-01-15 10:06:40 -08:00
phayes 3353f0e5a1
Updating from_hex to accept a &str instead of an ArrayString 2020-01-15 09:59:36 -08:00
phayes cfa310a497
Using enum for error type 2020-01-14 12:37:42 -08:00
phayes b0841629f1
Using static strings as errors for parsing hex 2020-01-14 12:07:46 -08:00
phayes 71e98f1d3f
Adding from_hex and implementing FromStr for Hash 2020-01-14 11:50:28 -08:00