Skip to content

Commit d39e0fa

Browse files
committed
python: adapt to changed/new APrimeFE.from_{int,bytes}... API
1 parent b9a6038 commit d39e0fa

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

python/chilldkg_ref/chilldkg.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ def deserialize_recovery_data(
392392
if len(rest) < 32 * n:
393393
raise ValueError
394394
enc_secshares, rest = (
395-
[Scalar.from_bytes(rest[i : i + 32]) for i in range(0, 32 * n, 32)],
395+
[Scalar.from_bytes_checked(rest[i : i + 32]) for i in range(0, 32 * n, 32)],
396396
rest[32 * n :],
397397
)
398398

python/chilldkg_ref/encpedpop.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from secp256k1lab.secp256k1 import Scalar, GE
44
from secp256k1lab.ecdh import ecdh_libsecp256k1
55
from secp256k1lab.keys import pubkey_gen_plain
6-
from secp256k1lab.util import int_from_bytes
76

87
from . import simplpedpop
98
from .util import (
@@ -29,15 +28,13 @@ def ecdh(
2928
data += their_pubkey + my_pubkey
3029
assert len(data) == 32 + 2 * 33
3130
data += context
32-
return Scalar(int_from_bytes(tagged_hash_bip_dkg("encpedpop ecdh", data)))
31+
return Scalar.from_bytes_wrapping(tagged_hash_bip_dkg("encpedpop ecdh", data))
3332

3433

3534
def self_pad(symkey: bytes, nonce: bytes, context: bytes) -> Scalar:
3635
# Pad for symmetric encryption to ourselves
37-
return Scalar(
38-
int_from_bytes(
39-
tagged_hash_bip_dkg("encaps_multi self_pad", symkey + nonce + context)
40-
)
36+
return Scalar.from_bytes_wrapping(
37+
tagged_hash_bip_dkg("encaps_multi self_pad", symkey + nonce + context)
4138
)
4239

4340

python/chilldkg_ref/vss.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def invalid_taproot_commit(self) -> Tuple[VSSCommitment, Scalar, GE]:
9595
# The function returns the updated VSS commitment and the tweak `t` which
9696
# must be added to all secret shares of the commitment.
9797
pk = self.commitment_to_secret()
98-
secshare_tweak = Scalar.from_bytes(
98+
secshare_tweak = Scalar.from_bytes_checked(
9999
tagged_hash("TapTweak", pk.to_bytes_compressed())
100100
)
101101
pubshare_tweak = secshare_tweak * G
@@ -112,7 +112,7 @@ def __init__(self, f: Polynomial) -> None:
112112
@staticmethod
113113
def generate(seed: bytes, t: int) -> VSS:
114114
coeffs = [
115-
Scalar.from_bytes(
115+
Scalar.from_bytes_checked(
116116
tagged_hash_bip_dkg("vss coeffs", seed + i.to_bytes(4, byteorder="big"))
117117
)
118118
for i in range(t)

python/tests.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def test_correctness_dkg_output(t, n, dkg_outputs: List[simplpedpop.DKGOutput]):
312312

313313
# Check that each secshare matches the corresponding pubshare
314314
secshares_scalar = [
315-
None if secshare is None else Scalar.from_bytes(secshare)
315+
None if secshare is None else Scalar.from_bytes_checked(secshare)
316316
for secshare in secshares
317317
]
318318
for i in range(1, n + 1):

0 commit comments

Comments
 (0)