Dev: Update ruff precommit hooks (#434)

* update ruff

* test

* update ruff

* only ruff check

* CI rename
This commit is contained in:
callebtc
2024-02-17 21:22:07 +01:00
committed by GitHub
parent c285d48edf
commit fca2a6cb4b
9 changed files with 410 additions and 556 deletions

View File

@@ -68,6 +68,7 @@ def hash_to_curve(message: bytes) -> PublicKey:
point = PublicKey(b"\x02" + _hash, raw=True)
except Exception:
msg_to_hash = _hash
print(_hash)
return point
@@ -101,18 +102,14 @@ def hash_to_curve_domain_separated(message: bytes) -> PublicKey:
raise ValueError("No valid point found")
def step1_alice(
secret_msg: str, blinding_factor: Optional[PrivateKey] = None
) -> tuple[PublicKey, PrivateKey]:
def step1_alice(secret_msg: str, blinding_factor: Optional[PrivateKey] = None) -> tuple[PublicKey, PrivateKey]:
Y: PublicKey = hash_to_curve(secret_msg.encode("utf-8"))
r = blinding_factor or PrivateKey()
B_: PublicKey = Y + r.pubkey # type: ignore
return B_, r
def step1_alice_domain_separated(
secret_msg: str, blinding_factor: Optional[PrivateKey] = None
) -> tuple[PublicKey, PrivateKey]:
def step1_alice_domain_separated(secret_msg: str, blinding_factor: Optional[PrivateKey] = None) -> tuple[PublicKey, PrivateKey]:
Y: PublicKey = hash_to_curve_domain_separated(secret_msg.encode("utf-8"))
r = blinding_factor or PrivateKey()
B_: PublicKey = Y + r.pubkey # type: ignore
@@ -151,9 +148,7 @@ def hash_e(*publickeys: PublicKey) -> bytes:
return e
def step2_bob_dleq(
B_: PublicKey, a: PrivateKey, p_bytes: bytes = b""
) -> Tuple[PrivateKey, PrivateKey]:
def step2_bob_dleq(B_: PublicKey, a: PrivateKey, p_bytes: bytes = b"") -> Tuple[PrivateKey, PrivateKey]:
if p_bytes:
# deterministic p for testing
p = PrivateKey(privkey=p_bytes, raw=True)
@@ -174,9 +169,7 @@ def step2_bob_dleq(
return epk, spk
def alice_verify_dleq(
B_: PublicKey, C_: PublicKey, e: PrivateKey, s: PrivateKey, A: PublicKey
) -> bool:
def alice_verify_dleq(B_: PublicKey, C_: PublicKey, e: PrivateKey, s: PrivateKey, A: PublicKey) -> bool:
R1 = s.pubkey - A.mult(e) # type: ignore
R2 = B_.mult(s) - C_.mult(e) # type: ignore
e_bytes = e.private_key