Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
DuniterPy
Commits
f80f65e3
Commit
f80f65e3
authored
5 years ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
[fix]
#58
fix challenge uuid string format
parent
99383cbd
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
duniterpy/documents/ws2p/messages.py
+5
-4
5 additions, 4 deletions
duniterpy/documents/ws2p/messages.py
duniterpy/tools.py
+10
-0
10 additions, 0 deletions
duniterpy/tools.py
with
15 additions
and
4 deletions
duniterpy/documents/ws2p/messages.py
+
5
−
4
View file @
f80f65e3
import
json
import
json
import
uuid
from
typing
import
Optional
from
typing
import
Optional
from
duniterpy.documents
import
Document
from
duniterpy.documents
import
Document
from
duniterpy.key
import
VerifyingKey
,
SigningKey
from
duniterpy.key
import
VerifyingKey
,
SigningKey
from
duniterpy.helpers
import
get_ws2p_challenge
class
Connect
(
Document
):
class
Connect
(
Document
):
...
@@ -25,7 +26,7 @@ class Connect(Document):
...
@@ -25,7 +26,7 @@ class Connect(Document):
self
.
pubkey
=
pubkey
self
.
pubkey
=
pubkey
if
challenge
is
None
:
if
challenge
is
None
:
# create challenge
# create challenge
self
.
challenge
=
uuid
.
uuid4
().
hex
+
uuid
.
uuid4
().
hex
self
.
challenge
=
get_ws2p_challenge
()
else
:
else
:
self
.
challenge
=
challenge
self
.
challenge
=
challenge
# add and verify signature
# add and verify signature
...
@@ -71,7 +72,7 @@ class Ack(Document):
...
@@ -71,7 +72,7 @@ class Ack(Document):
def
__init__
(
self
,
currency
:
str
,
pubkey
:
str
,
challenge
:
str
,
def
__init__
(
self
,
currency
:
str
,
pubkey
:
str
,
challenge
:
str
,
signature
:
Optional
[
str
]
=
None
)
->
None
:
signature
:
Optional
[
str
]
=
None
)
->
None
:
"""
"""
Init
Connect
message document
Init
Ack
message document
:param currency: Name of currency
:param currency: Name of currency
:param pubkey: Public key of node
:param pubkey: Public key of node
...
@@ -124,7 +125,7 @@ class Ok(Document):
...
@@ -124,7 +125,7 @@ class Ok(Document):
def
__init__
(
self
,
currency
:
str
,
pubkey
:
str
,
challenge
:
str
,
def
__init__
(
self
,
currency
:
str
,
pubkey
:
str
,
challenge
:
str
,
signature
:
Optional
[
str
]
=
None
)
->
None
:
signature
:
Optional
[
str
]
=
None
)
->
None
:
"""
"""
Init
Connect
message document
Init
Ok
message document
:param currency: Name of currency
:param currency: Name of currency
:param pubkey: Public key of node
:param pubkey: Public key of node
...
...
This diff is collapsed.
Click to expand it.
duniterpy/tools.py
+
10
−
0
View file @
f80f65e3
import
uuid
from
typing
import
Union
from
typing
import
Union
from
libnacl.encode
import
hex_decode
,
hex_encode
from
libnacl.encode
import
hex_decode
,
hex_encode
...
@@ -60,3 +61,12 @@ def convert_seed_to_seedhex(seed: bytes) -> str:
...
@@ -60,3 +61,12 @@ def convert_seed_to_seedhex(seed: bytes) -> str:
:rtype str:
:rtype str:
"""
"""
return
hex_encode
(
seed
).
decode
(
"
utf-8
"
)
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
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment