Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
odesenfans committed Sep 29, 2023
1 parent 937bb11 commit ca9b1d4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
24 changes: 12 additions & 12 deletions src/aleph_vrf/executor/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ async def receive_generate(
SAVED_GENERATED_BYTES[execution_id] = generated_bytes
ANSWERED_REQUESTS.add(vrf_request.request_id)

response_hash = VRFRandomNumberHash(
random_number_hash = VRFRandomNumberHash(
nb_bytes=vrf_request.nb_bytes,
nonce=vrf_request.nonce,
request_id=vrf_request.request_id,
Expand All @@ -129,20 +129,20 @@ async def receive_generate(

ref = (
f"vrf"
f"_{response_hash.request_id}"
f"_{response_hash.execution_id}"
f"_{random_number_hash.request_id}"
f"_{random_number_hash.execution_id}"
f"_{GENERATE_MESSAGE_REF_PATH}"
)

message_hash = await publish_data(
aleph_client=aleph_client, data=response_hash, ref=ref
aleph_client=aleph_client, data=random_number_hash, ref=ref
)

published_response_hash = PublishedVRFRandomNumberHash.from_vrf_response_hash(
vrf_response_hash=response_hash, message_hash=message_hash
published_random_number_hash = PublishedVRFRandomNumberHash.from_vrf_response_hash(
vrf_response_hash=random_number_hash, message_hash=message_hash
)

return APIResponse(data=published_response_hash)
return APIResponse(data=published_random_number_hash)


@app.post("/publish/{message_hash}")
Expand Down Expand Up @@ -173,7 +173,7 @@ async def receive_publish(

random_bytes: bytes = SAVED_GENERATED_BYTES.pop(response_hash.execution_id)

response_random_number = VRFRandomNumber(
random_number = VRFRandomNumber(
request_id=response_hash.request_id,
execution_id=response_hash.execution_id,
vrf_request=response_hash.vrf_request,
Expand All @@ -185,13 +185,13 @@ async def receive_publish(
ref = f"vrf_{response_hash.request_id}_{response_hash.execution_id}"

message_hash = await publish_data(
aleph_client=aleph_client, data=response_bytes, ref=ref
aleph_client=aleph_client, data=random_number, ref=ref
)
published_random_bytes = PublishedVRFRandomNumber.from_vrf_random_number(
vrf_random_number=response_bytes, message_hash=message_hash
published_random_number = PublishedVRFRandomNumber.from_vrf_random_number(
vrf_random_number=random_number, message_hash=message_hash
)

return APIResponse(data=published_random_bytes)
return APIResponse(data=published_random_number)


async def publish_data(
Expand Down
1 change: 0 additions & 1 deletion tests/coordinator/test_integration_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
PublishedVRFRandomNumberHash,
PublishedVRFRandomNumber,
)
from aleph_vrf.types import RequestId
from aleph_vrf.utils import xor_all, bytes_to_int, binary_to_bytes, verify


Expand Down

0 comments on commit ca9b1d4

Please sign in to comment.