Skip to content

Commit d5a5794

Browse files
author
Spencer Miller
committed
remove utils
1 parent f5a5565 commit d5a5794

4 files changed

Lines changed: 21 additions & 155 deletions

File tree

coti/crypto_utils.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
from cryptography.hazmat.primitives import serialization
55
from cryptography.hazmat.primitives.asymmetric import padding
66
from cryptography.hazmat.primitives.asymmetric import rsa
7+
from eth_account import Account
78
from eth_keys import keys
9+
from .types import ItString, ItUint
810

911
block_size = AES.block_size
1012
address_size = 20
@@ -71,7 +73,7 @@ def generate_aes_key():
7173
return key
7274

7375

74-
def sign_input_text(sender, addr, function_selector, ct, key):
76+
def sign_input_text(sender: Account, addr: str, function_selector: str, ct, key):
7577
function_selector_bytes = bytes.fromhex(function_selector[2:])
7678

7779
# Ensure all input sizes are the correct length
@@ -101,7 +103,7 @@ def sign(message, key):
101103
return signature
102104

103105

104-
def build_input_text(plaintext, user_aes_key, sender, contract, function_selector, signing_key):
106+
def build_input_text(plaintext: int, user_aes_key, sender: Account, contract, function_selector: str, signing_key) -> ItUint:
105107
sender_address_bytes = bytes.fromhex(sender.address[2:])
106108
contract_address_bytes = bytes.fromhex(contract.address[2:])
107109

@@ -124,7 +126,7 @@ def build_input_text(plaintext, user_aes_key, sender, contract, function_selecto
124126
}
125127

126128

127-
def build_string_input_text(plaintext, user_aes_key, sender, contract, function_selector, signing_key):
129+
def build_string_input_text(plaintext, user_aes_key, sender, contract, function_selector, signing_key) -> ItString:
128130
input_text = {
129131
'ciphertext': {
130132
'value': []
@@ -154,7 +156,7 @@ def build_string_input_text(plaintext, user_aes_key, sender, contract, function_
154156
return input_text
155157

156158

157-
def decrypt_uint(ciphertext, user_key):
159+
def decrypt_uint(ciphertext, user_key) -> int:
158160
# Convert ct to bytes (big-endian)
159161
byte_array = ciphertext.to_bytes(32, byteorder='big')
160162

@@ -171,7 +173,7 @@ def decrypt_uint(ciphertext, user_key):
171173
return decrypted_uint
172174

173175

174-
def decrypt_string(ciphertext, user_key):
176+
def decrypt_string(ciphertext, user_key) -> str:
175177
if 'value' in ciphertext or hasattr(ciphertext, 'value'): # format when reading ciphertext from an event
176178
__ciphertext = ciphertext['value']
177179
elif isinstance(ciphertext, tuple): # format when reading ciphertext from state variable

coti/types.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import Dict, List, TypeAlias, Union
2+
3+
ItBool: TypeAlias = Dict[str, Union[int, bytes]] # { 'ciphertext': int, 'signature': bytes }
4+
5+
ItUint: TypeAlias = Dict[str, Union[int, bytes]] # { 'ciphertext': int, 'signature': bytes }
6+
7+
ItString: TypeAlias = Dict[str, Union[Dict[str, List[int]], List[bytes]]] # { 'ciphertext': { 'value': List[int] }, 'signature': List[bytes] }
8+
9+
CtBool: TypeAlias = int
10+
11+
CtUint: TypeAlias = int
12+
13+
CtString: TypeAlias = Dict[str, List[int]] # { 'value': List[int] }

coti/utils.py

Lines changed: 0 additions & 149 deletions
This file was deleted.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
url='https://github.com/coti-io/coti-sdk-python',
1212
keywords='COTI SDK Privacy',
1313
install_requires=[
14-
'pycryptodome==3.19.0', 'cryptography==3.4.8', 'eth-keys==0.4.0', 'eth-account==0.10.0', 'web3==6.11.2'
14+
'pycryptodome==3.19.0', 'cryptography==3.4.8', 'eth-keys>=0.4.0', 'eth-account>=0.13.1'
1515
],
1616
python_requires=">=3.9",
1717
)

0 commit comments

Comments
 (0)