Skip to content
Snippets Groups Projects
Commit f80f65e3 authored by Vincent Texier's avatar Vincent Texier
Browse files

[fix] #58 fix challenge uuid string format

parent 99383cbd
No related branches found
No related tags found
No related merge requests found
import json
import uuid
from typing import Optional
from duniterpy.documents import Document
from duniterpy.key import VerifyingKey, SigningKey
from duniterpy.helpers import get_ws2p_challenge
class Connect(Document):
......@@ -25,7 +26,7 @@ class Connect(Document):
self.pubkey = pubkey
if challenge is None:
# create challenge
self.challenge = uuid.uuid4().hex + uuid.uuid4().hex
self.challenge = get_ws2p_challenge()
else:
self.challenge = challenge
# add and verify signature
......@@ -71,7 +72,7 @@ class Ack(Document):
def __init__(self, currency: str, pubkey: str, challenge: str,
signature: Optional[str] = None) -> None:
"""
Init Connect message document
Init Ack message document
:param currency: Name of currency
:param pubkey: Public key of node
......@@ -124,7 +125,7 @@ class Ok(Document):
def __init__(self, currency: str, pubkey: str, challenge: str,
signature: Optional[str] = None) -> None:
"""
Init Connect message document
Init Ok message document
:param currency: Name of currency
:param pubkey: Public key of node
......
import uuid
from typing import Union
from libnacl.encode import hex_decode, hex_encode
......@@ -60,3 +61,12 @@ def convert_seed_to_seedhex(seed: bytes) -> str:
:rtype str:
"""
return hex_encode(seed).decode("utf-8")
def get_ws2p_challenge() -> str:
"""
Return two uuid v4 concatened as ws2p challenge
:rtype str:
"""
return str(uuid.uuid4()) + str(uuid.uuid4())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment