seahash issueshttps://gitlab.redox-os.org/redox-os/seahash/-/issues2020-12-18T04:24:54Zhttps://gitlab.redox-os.org/redox-os/seahash/-/issues/6128 bit version2020-12-18T04:24:54ZKai Ren128 bit versionHi, is the one planned at some point?Hi, is the one planned at some point?https://gitlab.redox-os.org/redox-os/seahash/-/issues/9unaligned u64 reads2020-12-03T10:27:33ZJoonas Koivunenunaligned u64 readsNot sure if this could be related to the ARM performance #7 but I was just thinking of the unsafe code, for example [in `buffer.rs`](https://gitlab.redox-os.org/redox-os/seahash/-/blob/master/src/buffer.rs#L50-53) or [in `stream.rs`](htt...Not sure if this could be related to the ARM performance #7 but I was just thinking of the unsafe code, for example [in `buffer.rs`](https://gitlab.redox-os.org/redox-os/seahash/-/blob/master/src/buffer.rs#L50-53) or [in `stream.rs`](https://gitlab.redox-os.org/redox-os/seahash/-/blob/master/src/stream.rs#L73-81). I think there's no guarantee that a pointer to `&[u8]` is good for reading u64.
Might be that we'd need to do a loop of smaller to align to `align_of::<u64>()` and read the non-aligned suffix in similar slower way.
Apologies if this has already been discussed to death or if I am misreading and missing some alignment enforcing part.https://gitlab.redox-os.org/redox-os/seahash/-/issues/8Implement the Write trait ?2020-08-01T08:09:49ZjRimbaultImplement the Write trait ?Hi,
I've used seahash in the past, and yesterday I was reading [this](https://github.com/RustCrypto/hashes#hashing-readable-objects) and I thought it would be "neat" to also have the [Write](https://doc.rust-lang.org/std/io/trait.Write....Hi,
I've used seahash in the past, and yesterday I was reading [this](https://github.com/RustCrypto/hashes#hashing-readable-objects) and I thought it would be "neat" to also have the [Write](https://doc.rust-lang.org/std/io/trait.Write.html) trait implemented for the `SeaHasher`.
I'm copying the example I linked:
```rust
use seahash::SeaHasher;
use std::{fs, io};
let mut file = fs::File::open(&path)?;
let mut hasher = SeaHasher::new();
let n = io::copy(&mut file, &mut hasher)?;
let hash = hasher.finish();
```
I think it would require very little additional code to do:
```rust
use core::hash::Hasher;
#[cfg(feature = "std")]
impl std::io::Write for SeaHasher {
fn write(&mut self, buf: &[u8]) -> st::io::Result<usize> {
Hasher::write(self, buf);
Ok(buf.len())
}
fn flush(&mut self) -> std::io::Result<()> {
Ok(())
}
}
```
Just an idea. But when I wanted to hash a whole file I ended writing almost the [same code](https://github.com/jRimbault/ddh/blob/3b9550d08a128ecf2a2c62e3bec5d03b8e8210ba/src/fs/hash.rs#L33) as the canonical [`io::copy`](https://doc.rust-lang.org/src/std/io/util.rs.html#43-69). It can be placed behind an "std" feature flag.https://gitlab.redox-os.org/redox-os/seahash/-/issues/5is chunking really fixed?2020-06-27T11:08:23Zshribeis chunking really fixed?I was under the impression that with the changes in 4.0, the following should work:
```rust
#[test]
fn hash_chunking() {
let c1: &[u8] = b"This hashing algorithm was extracted from the Rustc compiler.";
let c2: &[u8] = b" This i...I was under the impression that with the changes in 4.0, the following should work:
```rust
#[test]
fn hash_chunking() {
let c1: &[u8] = b"This hashing algorithm was extracted from the Rustc compiler.";
let c2: &[u8] = b" This is the same hashing algoirthm used for some internal operations in FireFox.";
let c3: &[u8] = b" The strength of this algorithm is in hashing 8 bytes at a time on 64-bit platforms, where the FNV algorithm works on one byte at a time.";
let mut h1 = H::with_seeds(HASH_SEED_1, HASH_SEED_2, HASH_SEED_3, HASH_SEED_4);
h1.write(c1);
h1.write(c2);
h1.write(c3);
let hash1 = h1.finish();
let mut c4 = Vec::<u8>::new();
c4.extend_from_slice(c1);
c4.extend_from_slice(c2);
c4.extend_from_slice(c3);
let mut h2 = H::with_seeds(HASH_SEED_1, HASH_SEED_2, HASH_SEED_3, HASH_SEED_4);
h2.write(&c4);
let hash2 = h2.finish();
println!("hash1: {}, hash2: {}", hash1, hash2);
assert!(hash1 == hash2);
}
```
But it fails on that last line. Is chunking still broken?https://gitlab.redox-os.org/redox-os/seahash/-/issues/1Stream implementation sensitive to chunking2020-01-31T06:07:37ZPhilip WoolfordStream implementation sensitive to chunkingThe `StreamHasher` struct in `stream.rs` is sensitive to to the chunking of data.
E.g. Hashing `[u64::MAX, 0]` is different to hashing `[u64::MAX]` then `[0]`.
I have added a test to demonstrate in my fork at https://gitlab.redox-os.or...The `StreamHasher` struct in `stream.rs` is sensitive to to the chunking of data.
E.g. Hashing `[u64::MAX, 0]` is different to hashing `[u64::MAX]` then `[0]`.
I have added a test to demonstrate in my fork at https://gitlab.redox-os.org/pantsman0/seahash/blob/stream-tests/src/stream.rs#L132
The output is:
```bash
---- stream::tests::chunked_equiv stdout ----
thread 'stream::tests::chunked_equiv' panicked at 'assertion failed: `(left == right)`
left: `7214075340457006594`,
right: `13128668274129567273`', src/stream.rs:141:9
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
failures:
stream::tests::chunked_equiv
```https://gitlab.redox-os.org/redox-os/seahash/-/issues/4Consider adding #[derive(Clone)] to SeaHasher2020-01-29T04:15:20ZlarsfillmoreConsider adding #[derive(Clone)] to SeaHasherA use case for `Clone` in `SeaHasher` is [Rendezvous hashing](https://en.wikipedia.org/wiki/Rendezvous_hashing), which includes computing a lot of `h(k, s)` for the same key `k` and different `s`. With `Clone`, it will be possible to com...A use case for `Clone` in `SeaHasher` is [Rendezvous hashing](https://en.wikipedia.org/wiki/Rendezvous_hashing), which includes computing a lot of `h(k, s)` for the same key `k` and different `s`. With `Clone`, it will be possible to compute `hasher(k)` once and then reuse it with each `s`.https://gitlab.redox-os.org/redox-os/seahash/-/issues/2Hashing as const fn2020-01-28T02:15:07ZDenis GolovanHashing as const fnHi
Looks like recent Rust nightly implemented if/loops expressions for const fn.
It seems that now it is possible to make hashing functions const fn.
Are there any plans to adapt them for seahash?
BR,
DenisHi
Looks like recent Rust nightly implemented if/loops expressions for const fn.
It seems that now it is possible to make hashing functions const fn.
Are there any plans to adapt them for seahash?
BR,
Denishttps://gitlab.redox-os.org/redox-os/seahash/-/issues/3Published seahash 3.0.6 fails test buffer::tests::pop2020-01-28T02:01:47ZKent FredricPublished seahash 3.0.6 fails test buffer::tests::popIts unclear how serious this failure is, or what the cause is, but generally hashes not matching in tests seems like a bad thing.
Trying with git master doesn't exhibit this, so it looks like https://gitlab.redox-os.org/redox-os/seahash...Its unclear how serious this failure is, or what the cause is, but generally hashes not matching in tests seems like a bad thing.
Trying with git master doesn't exhibit this, so it looks like https://gitlab.redox-os.org/redox-os/seahash/merge_requests/1 fixes this.
If so, please consider this bug to be:
1. For visibility reasons
2. A vote for a release of seahash with the fix.
```
seahash-3.0.6 $ cargo test
warning: unused doc comment
--> src/buffer.rs:43:13
|
43 | / /// The end of the "main segment", i.e. the biggest buffer s.t. the length is divisible
44 | | /// by 32.
| |______________________^
45 | let end_ptr = buf.as_ptr().offset(buf.len() as isize & !0x1F);
| -------------------------------------------------------------- rustdoc does not generate documentation for statements
|
= note: `#[warn(unused_doc_comments)]` on by default
warning: `...` range patterns are deprecated
--> src/buffer.rs:72:18
|
72 | 1...7 => {
| ^^^ help: use `..=` for an inclusive range
|
= note: `#[warn(ellipsis_inclusive_range_patterns)]` on by default
warning: `...` range patterns are deprecated
--> src/buffer.rs:90:18
|
90 | 9...15 => {
| ^^^ help: use `..=` for an inclusive range
warning: `...` range patterns are deprecated
--> src/buffer.rs:116:19
|
116 | 17...23 => {
| ^^^ help: use `..=` for an inclusive range
warning: variable does not need to be mutable
--> src/buffer.rs:205:13
|
205 | let mut a = self.a;
| ----^
| |
| help: remove this `mut`
|
= note: `#[warn(unused_mut)]` on by default
warning: unused doc comment
--> src/buffer.rs:43:13
|
43 | / /// The end of the "main segment", i.e. the biggest buffer s.t. the length is divisible
44 | | /// by 32.
| |______________________^
45 | let end_ptr = buf.as_ptr().offset(buf.len() as isize & !0x1F);
| -------------------------------------------------------------- rustdoc does not generate documentation for statements
|
= note: `#[warn(unused_doc_comments)]` on by default
warning: `...` range patterns are deprecated
--> src/buffer.rs:72:18
|
72 | 1...7 => {
| ^^^ help: use `..=` for an inclusive range
|
= note: `#[warn(ellipsis_inclusive_range_patterns)]` on by default
warning: `...` range patterns are deprecated
--> src/buffer.rs:90:18
|
90 | 9...15 => {
| ^^^ help: use `..=` for an inclusive range
warning: `...` range patterns are deprecated
--> src/buffer.rs:116:19
|
116 | 17...23 => {
| ^^^ help: use `..=` for an inclusive range
warning: variable does not need to be mutable
--> src/buffer.rs:205:13
|
205 | let mut a = self.a;
| ----^
| |
| help: remove this `mut`
|
= note: `#[warn(unused_mut)]` on by default
Finished test [unoptimized + debuginfo] target(s) in 0.01s
Running target/debug/deps/seahash-d50b68ff7b5b2e86
running 12 tests
test buffer::tests::not_equal ... ok
test buffer::tests::pop ... FAILED
test buffer::tests::shakespear ... ok
test buffer::tests::position_depedent ... ok
test buffer::tests::push ... ok
test buffer::tests::zero_senitive ... ok
test helper::tests::read_int_ ... ok
test helper::tests::diffuse_test_vectors ... ok
test helper::tests::read_u64_ ... ok
test reference::tests::shakespear ... ok
test buffer::tests::seq ... ok
test buffer::tests::zero ... ok
failures:
---- buffer::tests::pop stdout ----
thread 'buffer::tests::pop' panicked at 'assertion failed: `(left == right)`
left: `11308796940792507029`,
right: `5634333896585159103`', src/buffer.rs:373:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
failures:
buffer::tests::pop
test result: FAILED. 11 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out
error: test failed, to rerun pass '--lib'
```