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

feat: add siphash24 implementation #11

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

TropicalDog17
Copy link
Contributor

@TropicalDog17 TropicalDog17 commented Sep 6, 2024

Description

Closes #2

\cc @StringNick

Comment on lines 65 to 69
if (T == u128) {
self.v2 ^= 0xee;
} else {
self.v2 ^= 0xff;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (T == u128) {
self.v2 ^= 0xee;
} else {
self.v2 ^= 0xff;
}
self.v2 ^= if (T == u128) 0xee else 0xff;


/// Initialize a state for a SipHash function
pub fn init(key: *const [key_length]u8) Self {
return Self{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return Self{
return .{

}

fn SipHash24(comptime T: type) type {
assert(T == u64 or T == u128);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not sure, maybe better compileError? wdyt @tcoratger @TropicalDog17

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah probably better here

pub const block_length = 8;
pub const c_rounds = 2;
pub const d_rounds = 4;
const State = SipHashStateless(T, c_rounds, d_rounds);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we support u64 / u128 and SipHashStateless same (as in std), maybe we can use

const State = if (T == u64) SipHash64(c_rounds, d_rounds) else SipHash128(c_round, d_rounds);

and we dont need copy full SipHashStateless

@StringNick StringNick merged commit 06bcf81 into zig-bitcoin:main Sep 12, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat/Hashers: Implement siphash24
3 participants