Last active
February 9, 2024 14:17
-
-
Save Mc01/ee6ec6cccf374e7fb22a821b03df99db to your computer and use it in GitHub Desktop.
Naming convention
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity 0.8.21; | |
library InputOutput { | |
function _finalize( | |
Context memory _context, // - input argument | |
uint64[4] memory _output_ // - input argument and also output of the function | |
) internal view { | |
// tx.members | |
uint256 now_ = block.timestamp; // local var | |
// add any uncounted bytes | |
_context.t += _context.c; | |
// compress with finalization flag | |
_compress(_context, true); | |
// flip little to big endian and store in output buffer | |
for (uint256 i = 0; i < _context.digestSize / 8; i++) { | |
_output_[i] = _getWords(_context.h[i]); | |
} | |
// properly pad output if it doesn't fill a full word | |
if (_context.digestSize < 32) { | |
_output_[_context.digestSize / 8] = _shiftRight( | |
_toLittleEndian(_context.h[_context.digestSize / 8]), | |
64 - 8 * (_context.digestSize % 8) | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment