mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fixing Keccak256 conversion warning
Co-authored-by: Kamil Śliwak <kamil.sliwak@codepoets.it>
This commit is contained in:
parent
c8759b8031
commit
18a196c21d
@ -69,25 +69,25 @@ static uint64_t const RC[24] = \
|
|||||||
#define REPEAT6(e) e e e e e e
|
#define REPEAT6(e) e e e e e e
|
||||||
#define REPEAT24(e) REPEAT6(e e e e)
|
#define REPEAT24(e) REPEAT6(e e e e)
|
||||||
#define REPEAT5(e) e e e e e
|
#define REPEAT5(e) e e e e e
|
||||||
#define FOR5(v, s, e) \
|
#define FOR5(type, v, s, e) \
|
||||||
v = 0; \
|
v = 0; \
|
||||||
REPEAT5(e; v += s;)
|
REPEAT5(e; v = static_cast<type>(v + s);)
|
||||||
|
|
||||||
/*** Keccak-f[1600] ***/
|
/*** Keccak-f[1600] ***/
|
||||||
static inline void keccakf(void* state) {
|
static inline void keccakf(void* state) {
|
||||||
uint64_t* a = (uint64_t*)state;
|
auto* a = static_cast<uint64_t*>(state);
|
||||||
uint64_t b[5] = {0};
|
uint64_t b[5] = {0};
|
||||||
|
|
||||||
for (int i = 0; i < 24; i++)
|
for (int i = 0; i < 24; i++)
|
||||||
{
|
{
|
||||||
uint8_t x, y;
|
uint8_t x, y;
|
||||||
// Theta
|
// Theta
|
||||||
FOR5(x, 1,
|
FOR5(uint8_t, x, 1,
|
||||||
b[x] = 0;
|
b[x] = 0;
|
||||||
FOR5(y, 5,
|
FOR5(uint8_t, y, 5,
|
||||||
b[x] ^= a[x + y]; ))
|
b[x] ^= a[x + y]; ))
|
||||||
FOR5(x, 1,
|
FOR5(uint8_t, x, 1,
|
||||||
FOR5(y, 5,
|
FOR5(uint8_t, y, 5,
|
||||||
a[y + x] ^= b[(x + 4) % 5] ^ rol(b[(x + 1) % 5], 1); ))
|
a[y + x] ^= b[(x + 4) % 5] ^ rol(b[(x + 1) % 5], 1); ))
|
||||||
// Rho and pi
|
// Rho and pi
|
||||||
uint64_t t = a[1];
|
uint64_t t = a[1];
|
||||||
@ -97,11 +97,12 @@ static inline void keccakf(void* state) {
|
|||||||
t = b[0];
|
t = b[0];
|
||||||
x++; )
|
x++; )
|
||||||
// Chi
|
// Chi
|
||||||
FOR5(y,
|
FOR5(uint8_t,
|
||||||
|
y,
|
||||||
5,
|
5,
|
||||||
FOR5(x, 1,
|
FOR5(uint8_t, x, 1,
|
||||||
b[x] = a[y + x];)
|
b[x] = a[y + x];)
|
||||||
FOR5(x, 1,
|
FOR5(uint8_t, x, 1,
|
||||||
a[y + x] = b[x] ^ ((~b[(x + 1) % 5]) & b[(x + 2) % 5]); ))
|
a[y + x] = b[x] ^ ((~b[(x + 1) % 5]) & b[(x + 2) % 5]); ))
|
||||||
// Iota
|
// Iota
|
||||||
a[0] ^= RC[i];
|
a[0] ^= RC[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user