Skip to content
Closed
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
10 changes: 7 additions & 3 deletions py_clob_client_v2/order_utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import random
import time
import secrets


def generate_order_salt() -> str:
return str(int(random.random() * (time.time_ns() // 1_000_000)))
# 64 bits of entropy from a cryptographically strong RNG. The previous
# implementation used `random.random() * current_ms_time`, which:
# - is not cryptographically secure
# - always yields a value strictly less than `current_ms_time`
# - has a realistic collision rate under concurrent order creation
return str(secrets.randbits(64))