The SHA3_512 library takes an input uint64[8] and outputs uint32[16]. To convert the input from 64 bytes and the output back to bytes, I wrote this, but it gives the wrong result. What are some examples that work?
function 64bytesToSHA3_512(bytes _message) returns (bytes) {
uint64[8] memory input;
for(uint i = 0; i < 8; i++) {
bytes8 oneEigth;
// Load 8 byte from _message at position 32 + i * 8
assembly {
oneEigth := mload(add(_message, add(32, mul(i, 8))))
}
input[i] = uint64(oneEigth);
}
uint32[16] memory output = hash(input); // hash() is in contract SHA3_512
bytes memory messageHash = new bytes(64);
for(i = 0; i < 16; i++) {
bytes4 oneSixteenth = bytes4(output[i]);
// Store 4 byte in messageHash at position 32 + i * 4
assembly { mstore(add(messageHash, add(32, mul(i, 4))), oneSixteenth) }
}
return messageHash;
}