1
0
Fork 0
mirror of synced 2025-09-24 04:40:05 +00:00
ZoKrates/zokrates_stdlib/stdlib/hashes/sha256/512bitPadded.zok
2020-08-04 20:49:32 +02:00

32 lines
No EOL
804 B
Text

import "./1024bit" as sha256
// A function that takes 2 u32[8] arrays as inputs, concatenates them, pads them,
// and returns their sha256 hash as a u32[8]
def main(u32[8] a, u32[8] b) -> u32[8]:
// Hash is computed on the full 512bit block size
// padding does not fit in the primary block
// add dummy block (single "1" followed by "0" + total length)
u32[8] dummyblock1 = [ \
0x80000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000
]
u32[8] dummyblock2 = [ \
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000200
]
return sha256(a, b, dummyblock1, dummyblock2)