Files
status-python-sdk/utils/keys.py
T
Nick Ninov 0491c597f7 create_account: store credentials locally
- Initial documentation with how to run the project
- Store `create_account_and_login` credentials locally so they can be reused when messaging
- Script can be ran with arguments
2026-02-24 21:46:56 +02:00

19 lines
582 B
Python

from hashlib import shake_256
def compress_public_key(public_key):
if not public_key.startswith("0x"):
public_key = "0x" + public_key
if len(public_key) != 132:
raise ValueError("Invalid public key")
x = public_key[4:68] # Extract X coordinate (first 32 bytes after prefix)
y = public_key[68:132] # Extract Y coordinate (last 32 bytes)
prefix = "03" if int(y, 16) % 2 else "02" # Add prefix 02 for even Y, 03 for odd Y
return "0x" + prefix + x
def shake256(msg):
h = shake_256()
h.update(msg)
return "0x" + h.hexdigest(64)