Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions dev-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@

set -e # Exit on error

VENV_DIR_DEFAULT=".venv"
if [ -d "myenv" ] && [ ! -d ".venv" ]; then
VENV_DIR_DEFAULT="myenv"
fi
VENV_DIR="${VENV_DIR:-$VENV_DIR_DEFAULT}"

PYTHON_BIN="${PYTHON_BIN:-python3}"

echo "🚀 Setting up Akave Python SDK development environment..."
echo ""

echo "📍 Checking Python version..."
python_version=$(python --version 2>&1 | awk '{print $2}')
python_version=$($PYTHON_BIN --version 2>&1 | awk '{print $2}')
echo "✅ Found Python $python_version"
echo ""

if [ ! -d "myenv" ]; then
if [ ! -d "$VENV_DIR" ]; then
echo "📦 Creating virtual environment..."
python -m venv myenv
$PYTHON_BIN -m venv "$VENV_DIR"
echo "✅ Virtual environment created"
else
echo "✅ Virtual environment already exists"
Expand All @@ -21,9 +29,9 @@ echo ""

echo "🔄 Activating virtual environment..."
if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]]; then
source myenv/Scripts/activate
source "$VENV_DIR"/Scripts/activate
else
source myenv/bin/activate
source "$VENV_DIR"/bin/activate
fi
echo "✅ Virtual environment activated"
echo ""
Expand Down Expand Up @@ -52,8 +60,8 @@ echo ""
echo "✨ Setup complete! Your development environment is ready."
echo ""
echo "To activate the virtual environment, run:"
echo " source myenv/bin/activate (Linux/macOS)"
echo " myenv\\Scripts\\activate (Windows)"
echo " source $VENV_DIR/bin/activate (Linux/macOS)"
echo " $VENV_DIR\\Scripts\\activate (Windows)"
echo ""
echo "To run code quality checks, use:"
echo " ./run-checks.sh (Linux/macOS)"
Expand Down
15 changes: 6 additions & 9 deletions private/encryption/encryption.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
from cryptography.hazmat.primitives import hashes
from typing import Tuple, cast


KEY_LENGTH = 32


def derive_key(key: bytes, info: bytes) -> bytes:
hkdf = HKDF(
algorithm=hashes.SHA256(),
length=KEY_LENGTH,
salt=None,
info=info,
backend=default_backend(),
)
hkdf = HKDF(algorithm=hashes.SHA256(), length=KEY_LENGTH, salt=None, info=info)
return hkdf.derive(key)


Expand All @@ -33,7 +30,7 @@ def make_gcm_cipher(origin_key: bytes, info: bytes) -> Tuple[Cipher, bytes]:
raise ValueError(f"Key must be {KEY_LENGTH} bytes long")
key = derive_key(origin_key, info)
nonce = os.urandom(12) # AES-GCM standard nonce size
cipher = Cipher(algorithms.AES(key), modes.GCM(nonce), backend=default_backend())
cipher = Cipher(algorithms.AES(key), modes.GCM(nonce))
return cipher, nonce


Expand All @@ -57,7 +54,7 @@ def decrypt(key: bytes, encrypted_data: bytes, info: bytes) -> bytes:
tag = encrypted_data[-tag_size:]

derived_key = derive_key(key, info)
cipher = Cipher(algorithms.AES(derived_key), modes.GCM(nonce, tag), backend=default_backend())
cipher = Cipher(algorithms.AES(derived_key), modes.GCM(nonce, tag))
decryptor = cipher.decryptor()
decrypted_data = decryptor.update(ciphertext) + decryptor.finalize()
return cast(bytes, decrypted_data)
21 changes: 20 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,33 @@ eth-utils>=2.1.0
rlp>=2.0.1
pycryptodome==3.20.0


# Logging & monitoring
opentelemetry-api==1.28.0
opentelemetry-sdk==1.28.0
opentelemetry-exporter-jaeger==1.21.0
opentelemetry-instrumentation-grpc==0.49b0
prometheus-client==0.19.0
structlog==24.1.0

# Error handling & utilities
pydantic>=2.6.3; python_version < "3.13"
pydantic>=2.10.0; python_version >= "3.13"
rich==13.7.0

# Cobra CLI equivalent
click==8.1.7


# File utilities
watchdog==3.0.0

# YAML parsing (alternative to `go-yaml`)
PyYAML==6.0.1

#math
cryptography==36.0.0
cryptography>=41.0.0; python_version < "3.13"
cryptography>=43.0.0; python_version >= "3.13"

#erasure
reedsolo
Expand Down
Loading
Loading