Skip to content

Latest commit

 

History

History
9 lines (7 loc) · 1.88 KB

File metadata and controls

9 lines (7 loc) · 1.88 KB

Computes SHA2 small sigma 0.

Input: [x, ...]
Output: [y, ...]

Where y = σ_0(x), as defined in SHA specification
See https://github.com/itzmeanjan/merklize-sha/blob/8a2c006/include/sha2.hpp#L73-L79

miden::core::crypto::hashes::sha256

Procedure Description
merge SHA256 2-to-1 hash (merge): Given 64 -bytes input, computes 32 -bytes SHA256 digest

Input: [m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15, ...]
Output: [dig0, dig1, dig2, dig3, dig4, dig5, dig6, dig7, ...]

Where: m[0,16) = 32 -bit word

Note, each SHA256 word is 32 -bit wide, so that's how input is expected.
As you've 64 -bytes, consider packing 4 consecutive bytes into single word,
maintaining big endian byte order.

SHA256 digest is represented in terms of eight 32 -bit words ( big endian byte order ).
hash SHA256 1-to-1 hash: Given 32 -bytes input, computes 32 -bytes SHA256 digest

Expected stack state:

Input: [m0, m1, m2, m3, m4, m5, m6, m7, ...]
Output: [dig0, dig1, dig2, dig3, dig4, dig5, dig6, dig7, ...]

Where: m[0,8) = 32 -bit word

Note, each SHA256 word is 32 -bit wide, so that's how input is expected.
As you've 32 -bytes, consider packing 4 consecutive bytes into single word,
maintaining big endian byte order.

SHA256 digest is represented in terms of eight 32 -bit words ( big endian byte order ).
hash_bytes Given a memory address and a message length in bytes, compute its sha256 digest

- There must be space for writing the padding after the message in memory
- The padding space after the message must be all zeros before this procedure is called

Input: [addr, len, ...]
Output: [dig0, dig1, dig2, dig3, dig4, dig5, dig6, dig7, ...]