From b8b29b7879966fa5ede4797f609c15c276d9b1d6 Mon Sep 17 00:00:00 2001 From: jiajun chen <601427268@qq.com> Date: Sat, 16 Nov 2024 14:54:07 +0100 Subject: [PATCH 1/3] Fix unhexlify binary value and incompatible HI type when construct hash --- csr-gen.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/csr-gen.py b/csr-gen.py index 44e7f82..a5ddd7d 100644 --- a/csr-gen.py +++ b/csr-gen.py @@ -43,13 +43,13 @@ def det_orchid(raa, hda, hi): # print("HID:", b_hid) # perform hash with cSHAKE using input data - h_orchid_left = unhexlify(b_prefix + b_hid + b_ogaid) + h_orchid_left = unhexlify(hex(int(b_prefix + b_hid + b_ogaid, 2))[2:]) # print(h_orchid_left.hex()) shake = cSHAKE128.new(custom = ContextID) # print(type(h_orchid_left)) # print("HI:", type(hi), hi) print("HI:", hi) - shake.update((h_orchid_left + hi)) + shake.update((h_orchid_left + unhexlify(hi))) h_hash = shake.read(8).hex() # format orchid in binary From 3abf9a15667f3b223078952f843dbc6b75f501ad Mon Sep 17 00:00:00 2001 From: jiajun chen <601427268@qq.com> Date: Thu, 21 Nov 2024 17:05:50 +0100 Subject: [PATCH 2/3] Fix the unclear variable name --- csr-gen.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/csr-gen.py b/csr-gen.py index a5ddd7d..e2890d2 100644 --- a/csr-gen.py +++ b/csr-gen.py @@ -43,17 +43,17 @@ def det_orchid(raa, hda, hi): # print("HID:", b_hid) # perform hash with cSHAKE using input data - h_orchid_left = unhexlify(hex(int(b_prefix + b_hid + b_ogaid, 2))[2:]) + h_orchid_left = hex(int(b_prefix + b_hid + b_ogaid, 2))[2:] # print(h_orchid_left.hex()) shake = cSHAKE128.new(custom = ContextID) # print(type(h_orchid_left)) # print("HI:", type(hi), hi) print("HI:", hi) - shake.update((h_orchid_left + unhexlify(hi))) + shake.update((unhexlify(h_orchid_left) + unhexlify(hi))) h_hash = shake.read(8).hex() # format orchid in binary - h_orchid = hex(int(b_prefix + b_hid + b_ogaid, 2))[2:] + h_hash + h_orchid = h_orchid_left + h_hash orchid = 2 print("DET:", h_orchid) From bf56f7ae0213a4edaab3ea569e41f75800fef267 Mon Sep 17 00:00:00 2001 From: jiajun chen <601427268@qq.com> Date: Sat, 23 Nov 2024 17:39:32 +0100 Subject: [PATCH 3/3] Fix the same issue in endorse script --- hda-endorse.py | 6 +++--- raa-endorse.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hda-endorse.py b/hda-endorse.py index 806f23a..67cdc8f 100644 --- a/hda-endorse.py +++ b/hda-endorse.py @@ -75,12 +75,12 @@ def det_orchid(raa, hda, hi): # print("HID:", b_hid) # perform hash with cSHAKE using input data - h_orchid_left = unhexlify(b_prefix + b_hid + b_ogaid) + h_orchid_left = hex(int(b_prefix + b_hid + b_ogaid, 2))[2:] # print(h_orchid_left.hex()) shake = cSHAKE128.new(custom = ContextID) # print(type(h_orchid_left),h_orchid_left) # print("hi",type(hi), hi) - shake.update((h_orchid_left + hi)) + shake.update((unhexlify(h_orchid_left) + unhexlify(hi))) h_hash = shake.read(8).hex() # format orchid in binary @@ -208,7 +208,7 @@ def det_orchid(raa, hda, hi): pleasesign = hex(int(vnbtime))[2:].zfill(8) + hex(int(vnatime))[2:].zfill(8) + det.zfill(32) + ua_hihex.zfill(64) + DETofHDA #print(pleasesign) -pleasesignb = bytes(pleasesign, 'utf-8') +pleasesignb = unhexlify(pleasesign) #print(type(pleasesignb),pleasesignb) signature = hda_prkey.sign(pleasesignb) #print(type(signature.hex()),signature.hex()) diff --git a/raa-endorse.py b/raa-endorse.py index 8898914..755076c 100644 --- a/raa-endorse.py +++ b/raa-endorse.py @@ -76,7 +76,7 @@ def det_orchid(raa, hda, hi): # print("HID:", b_hid) # perform hash with cSHAKE using input data - h_orchid_left = unhexlify(b_prefix + b_hid + b_ogaid) + h_orchid_left = hex(int(b_prefix + b_hid + b_ogaid, 2))[2:] # print(h_orchid_left.hex()) shake = cSHAKE128.new(custom = ContextID) # print(type(h_orchid_left),h_orchid_left) @@ -212,7 +212,7 @@ def det_orchid(raa, hda, hi): pleasesign = hex(int(vnbtime))[2:].zfill(8) + hex(int(vnatime))[2:].zfill(8) + det.zfill(32) + hda_hihex.zfill(64) + DETofRAA #print(pleasesign) -pleasesignb = bytes(pleasesign, 'utf-8') +pleasesignb = unhexlify(pleasesign) #print(type(pleasesignb),pleasesignb) signature = raa_prkey.sign(pleasesignb) #print(type(signature.hex()),signature.hex())