Skip to content

Commit 5d5e4eb

Browse files
author
Spencer Miller
committed
fix CtString type
1 parent 0fedac9 commit 5d5e4eb

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

coti/crypto_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from cryptography.hazmat.primitives.asymmetric import padding
66
from cryptography.hazmat.primitives.asymmetric import rsa
77
from eth_keys import keys
8-
from .types import ItString, ItUint
8+
from .types import CtString, CtUint, ItString, ItUint
99

1010
block_size = AES.block_size
1111
address_size = 20
@@ -152,7 +152,7 @@ def build_string_input_text(plaintext: int, user_aes_key: str, sender_address: s
152152
return input_text
153153

154154

155-
def decrypt_uint(ciphertext: int, user_aes_key: str) -> int:
155+
def decrypt_uint(ciphertext: CtUint, user_aes_key: str) -> int:
156156
# Convert ct to bytes (big-endian)
157157
byte_array = ciphertext.to_bytes(32, byteorder='big')
158158

@@ -169,7 +169,7 @@ def decrypt_uint(ciphertext: int, user_aes_key: str) -> int:
169169
return decrypted_uint
170170

171171

172-
def decrypt_string(ciphertext: int, user_aes_key: str) -> str:
172+
def decrypt_string(ciphertext: CtString, user_aes_key: str) -> str:
173173
if 'value' in ciphertext or hasattr(ciphertext, 'value'): # format when reading ciphertext from an event
174174
__ciphertext = ciphertext['value']
175175
elif isinstance(ciphertext, tuple): # format when reading ciphertext from state variable

coti/types.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
CtUint: TypeAlias = int
66

7-
class CtString(TypedDict):
8-
value: List[int]
7+
CtString: TypeAlias = tuple[List[int]]
98

109
class ItBool(TypedDict):
1110
ciphertext: int
@@ -15,6 +14,9 @@ class ItUint(TypedDict):
1514
ciphertext: int
1615
signature: bytes
1716

18-
class ItString(TypedDict):
19-
ciphertext: CtString
17+
class ItStringCiphertext(TypedDict):
18+
value: List[int]
19+
20+
class ItString(TypedDict):
21+
ciphertext: ItStringCiphertext
2022
signature: List[bytes]

0 commit comments

Comments
 (0)