19 lines
624 B
Python
19 lines
624 B
Python
"""Delta signing utilities for BeVault MVP."""
|
|
from __future__ import annotations
|
|
import hmac
|
|
import hashlib
|
|
from .core import HedgeDelta
|
|
|
|
|
|
def sign_delta(delta: HedgeDelta, key: bytes) -> str:
|
|
"""Sign a HedgeDelta deterministically using HMAC-SHA256.
|
|
|
|
The signature is derived from the delta contents (asset, hedge_size, timestamp, policy_tag).
|
|
The resulting hex digest is stable for identical inputs and keys.
|
|
"""
|
|
payload = f"{delta.asset}:{delta.hedge_size}:{delta.timestamp}:{delta.policy_tag}"
|
|
return hmac.new(key, payload.encode("utf-8"), hashlib.sha256).hexdigest()
|
|
|
|
|
|
__all__ = ["sign_delta"]
|