mirror of
https://github.com/trezor/trezor-firmware.git
synced 2026-02-20 00:33:30 +01:00
Address code review: simplify ctypes buffer conversions in test_curves.py
Co-authored-by: obrusvit <14001709+obrusvit@users.noreply.github.com>
This commit is contained in:
@@ -417,11 +417,11 @@ def test_sign_native(curve, r):
|
||||
public_key = private_key.public_key()
|
||||
|
||||
# Verify the C library signature
|
||||
r_from_sig = int.from_bytes(bytes(bytearray(sig[:32])), "big")
|
||||
s_from_sig = int.from_bytes(bytes(bytearray(sig[32:])), "big")
|
||||
r_from_sig = int.from_bytes(sig[:32], "big")
|
||||
s_from_sig = int.from_bytes(sig[32:], "big")
|
||||
der_verify = encode_dss_signature(r_from_sig, s_from_sig)
|
||||
public_key.verify(
|
||||
der_verify, bytes(bytearray(digest)), ec.ECDSA(Prehashed(hashes.SHA256()))
|
||||
der_verify, bytes(digest), ec.ECDSA(Prehashed(hashes.SHA256()))
|
||||
)
|
||||
|
||||
|
||||
@@ -441,11 +441,11 @@ def test_sign_zkp(r):
|
||||
public_key = private_key.public_key()
|
||||
|
||||
# Verify the C library signature
|
||||
r_from_sig = int.from_bytes(bytes(bytearray(sig[:32])), "big")
|
||||
s_from_sig = int.from_bytes(bytes(bytearray(sig[32:])), "big")
|
||||
r_from_sig = int.from_bytes(sig[:32], "big")
|
||||
s_from_sig = int.from_bytes(sig[32:], "big")
|
||||
der_verify = encode_dss_signature(r_from_sig, s_from_sig)
|
||||
public_key.verify(
|
||||
der_verify, bytes(bytearray(digest)), ec.ECDSA(Prehashed(hashes.SHA256()))
|
||||
der_verify, bytes(digest), ec.ECDSA(Prehashed(hashes.SHA256()))
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user