Skip to content

support XOR-based bit mixing in heavy_hash for header_version 2 and misc#16

Open
x100111010 wants to merge 19 commits into
spectre-project:mainfrom
x100111010:matrix-activated
Open

support XOR-based bit mixing in heavy_hash for header_version 2 and misc#16
x100111010 wants to merge 19 commits into
spectre-project:mainfrom
x100111010:matrix-activated

Conversation

@x100111010

Copy link
Copy Markdown
Member

supports the upcoming proposed changes in spectre-project/rusty-spectre#41

  if header_version == 2 {
       (((sum1 & 0xF) ^ ((sum1 >> 4) & 0xF) ^ ((sum1 >> 8) & 0xF)) << 4) as u8
           | ((sum2 & 0xF) ^ ((sum2 >> 4) & 0xF) ^ ((sum2 >> 8) & 0xF)) as u8
   } else {
       ((sum1 >> 10) << 4) as u8 | (sum2 >> 10) as u8
   }

In version 1 we just took the upper bits of calculated sums (using sum >> 10).

In version 2 we now use XOR operations between different parts of the sum ((sum & 0xF) ^ ((sum >> 4) & 0xF) ^ ((sum >> 8) & 0xF)) which introduces much more randomness and variation in the output.

- separate `calculate_spectrex_v1()` and `calculate_spectrex_v2()`
- add a test case for `heavy_hash_v2`
- add `header_version` in submit block log
protobuf doesn't have a native uint16 type
disable uninlined_format_args lint
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.

1 participant