Skip to content

Commit

Permalink
Merge pull request #385 from backend-developers-ltd/test-auth-request
Browse files Browse the repository at this point in the history
Fix keypair creation in facilitator V0AuthenticationRequest
  • Loading branch information
adal-chiriliuc-reef authored Jan 28, 2025
2 parents 2e8503d + 4e9fabf commit ecda52f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 2 additions & 4 deletions compute_horde/compute_horde/fv_protocol/validator_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,15 @@ def from_keypair(cls, keypair: bittensor.Keypair) -> Self:

def verify_signature(self) -> bool:
public_key_bytes = bytes.fromhex(self.public_key)
keypair = bittensor.Keypair(public_key=public_key_bytes, ss58_format=42)
keypair = bittensor.Keypair(public_key=self.public_key, ss58_format=42)
# make mypy happy
valid: bool = keypair.verify(public_key_bytes, self.signature)
return valid

@property
def ss58_address(self) -> str:
# make mypy happy
address: str = bittensor.Keypair(
public_key=bytes.fromhex(self.public_key), ss58_format=42
).ss58_address
address: str = bittensor.Keypair(public_key=self.public_key, ss58_format=42).ss58_address
return address


Expand Down
7 changes: 7 additions & 0 deletions compute_horde/tests/test_signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
V2JobRequest,
to_json_array,
)
from compute_horde.fv_protocol.validator_requests import V0AuthenticationRequest
from compute_horde.signature import (
SIGNERS_REGISTRY,
VERIFIERS_REGISTRY,
Expand Down Expand Up @@ -200,3 +201,9 @@ def test_signed_fields__volumes_uploads():
output_upload=uploads[0],
)
assert v2_job_request.get_signed_fields() == facilitator_signed_fields


def test_authentication_request(keypair):
authentication_request = V0AuthenticationRequest.from_keypair(keypair)
assert authentication_request.verify_signature()
assert authentication_request.ss58_address == keypair.ss58_address

0 comments on commit ecda52f

Please sign in to comment.