From ab0ca66da524c104a1d93af2092b4810a84d8ac8 Mon Sep 17 00:00:00 2001 From: Bazsalanszky Date: Tue, 6 Dec 2022 15:25:51 +0100 Subject: [PATCH] Removed gradle and added ZoKrates COde --- CCTF_Solutions_main/.gitignore | 5 +---- CCTF_Solutions_main/hash.zok | 8 ++++++++ CCTF_Solutions_main/root.zok | 11 +++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 CCTF_Solutions_main/hash.zok create mode 100644 CCTF_Solutions_main/root.zok diff --git a/CCTF_Solutions_main/.gitignore b/CCTF_Solutions_main/.gitignore index b0126f1..d29e6db 100644 --- a/CCTF_Solutions_main/.gitignore +++ b/CCTF_Solutions_main/.gitignore @@ -1,8 +1,5 @@ *.bpmn -root.zok -stateChange.zok -hash.zok -hash + # Compiled class file *.class diff --git a/CCTF_Solutions_main/hash.zok b/CCTF_Solutions_main/hash.zok new file mode 100644 index 0000000..9a271b4 --- /dev/null +++ b/CCTF_Solutions_main/hash.zok @@ -0,0 +1,8 @@ +import "hashes/sha256/sha256Padded.zok" as sha256; + +def main(public u32[8] hash,private u8[8] flag) { + u32[8] genHash = sha256(flag); + log("Hash: {} {} {} {} {} {} {} {}",genHash[0],genHash[1],genHash[2],genHash[3],genHash[4],genHash[5],genHash[6],genHash[7]); + //assert(genHash == hash); + return; +} diff --git a/CCTF_Solutions_main/root.zok b/CCTF_Solutions_main/root.zok new file mode 100644 index 0000000..4c0466c --- /dev/null +++ b/CCTF_Solutions_main/root.zok @@ -0,0 +1,11 @@ +import "hashes/sha256/sha256Padded.zok" as sha256; +from "utils/casts.zok" import cast; + +def main(public u32[8] hash,public u32[5] address,private u8[8] flag) { + u8[20] addr8 = cast(address); + u8[28] forHash = [...addr8,...flag]; + u32[8] genHash = sha256(flag); + log("Hash: {} {} {} {} {} {} {} {}",genHash[0],genHash[1],genHash[2],genHash[3],genHash[4],genHash[5],genHash[6],genHash[7]); + assert(genHash == hash); + return; +} \ No newline at end of file