Use ferveo 0.1.11 so that DkgPublicKey.serialized_size() can be used. Updated some typehints.

pull/3121/head
derekpierre 2023-05-08 09:14:30 -04:00
parent fe62f3cabb
commit ae3f267fb6
6 changed files with 14 additions and 9 deletions

View File

@ -14,7 +14,7 @@ hendrix = ">=4.0"
nucypher-core = ">=0.7.0"
# Cryptography
cryptography = ">=3.2"
ferveo = ">=0.1.10"
ferveo = ">=0.1.11"
mnemonic = "*"
pynacl= ">=1.4.0"
pyopenssl = "*"

View File

@ -1 +1 @@
Updates to use ferveo v0.1.10.
Updates to use ferveo v0.1.11.

View File

@ -557,6 +557,8 @@ class CoordinatorAgent(EthereumContractAgent):
transcript: bytes = bytes()
class G1Point(NamedTuple):
"""Coordinator contract representation of DkgPublicKey."""
# TODO validation of these if used directly
word0: bytes # 32 bytes
word1: bytes # 16 bytes
@ -567,8 +569,10 @@ class CoordinatorAgent(EthereumContractAgent):
@classmethod
def from_bytes(cls, data: bytes):
if len(data) != 48:
raise ValueError(f"Invalid byte length ({len(data)}) for G1Point")
if len(data) != DkgPublicKey.serialized_size():
raise ValueError(
f"Invalid byte length; expected {DkgPublicKey.serialized_size()} bytes but got {len(data)} bytes for G1Point"
)
return cls(word0=data[:32], word1=data[32:48])
def to_dkg_public_key(self) -> DkgPublicKey:

View File

@ -38,20 +38,20 @@ def _make_dkg(
return dkg
def generate_transcript(*args, **kwargs):
def generate_transcript(*args, **kwargs) -> Transcript:
dkg = _make_dkg(*args, **kwargs)
transcript = dkg.generate_transcript()
return transcript
def derive_public_key(*args, **kwargs):
def derive_public_key(*args, **kwargs) -> DkgPublicKey:
dkg = _make_dkg(*args, **kwargs)
return dkg.public_key
def aggregate_transcripts(
transcripts: List[Tuple[Validator, Transcript]], shares: int, *args, **kwargs
) -> Tuple[AggregatedTranscript, PublicKey, DkgPublicParameters]:
) -> Tuple[AggregatedTranscript, DkgPublicKey, DkgPublicParameters]:
validators = [t[0] for t in transcripts]
_dkg = _make_dkg(nodes=validators, shares=shares, *args, **kwargs)
pvss_aggregated = _dkg.aggregate_transcripts(transcripts)

View File

@ -31,7 +31,7 @@ eth-rlp==0.3.0 ; python_version >= '3.7' and python_version < '4'
eth-tester==0.8.0b3
eth-typing==3.3.0 ; python_version < '4' and python_full_version >= '3.7.2'
eth-utils==2.1.0
ferveo==0.1.10
ferveo==0.1.11
flask==2.2.5
frozenlist==1.3.3 ; python_version >= '3.7'
hendrix==4.0.0

View File

@ -12,6 +12,7 @@ import pytest
from click.testing import CliRunner
from eth_account import Account
from eth_utils import to_checksum_address
from ferveo_py.ferveo_py import DkgPublicKey
from ferveo_py.ferveo_py import Keypair as FerveoKeyPair
from ferveo_py.ferveo_py import Validator
from twisted.internet.task import Clock
@ -699,7 +700,7 @@ def ursulas(testerchain, staking_providers, ursula_test_config):
@pytest.fixture(scope="module")
def dkg_public_key(get_random_checksum_address):
def dkg_public_key(get_random_checksum_address) -> DkgPublicKey:
ritual_id = 0
num_shares = 4
threshold = 3