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
ff6dbbe0
Commit
ff6dbbe0
authored
5 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[enh] SigningKey: allow to pass a Path
parent
4057ce93
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
duniterpy/key/signing_key.py
+15
-12
15 additions, 12 deletions
duniterpy/key/signing_key.py
with
15 additions
and
12 deletions
duniterpy/key/signing_key.py
+
15
−
12
View file @
ff6dbbe0
...
...
@@ -5,6 +5,7 @@ duniter public and private keys
"""
import
re
from
typing
import
Optional
,
Union
,
TypeVar
,
Type
from
pathlib
import
Path
import
libnacl.sign
import
pyaes
...
...
@@ -64,7 +65,7 @@ class SigningKey(libnacl.sign.Signer):
return
cls
(
seed
)
def
save_seedhex_file
(
self
,
path
:
str
)
->
None
:
def
save_seedhex_file
(
self
,
path
:
Union
[
Path
,
str
]
)
->
None
:
"""
Save hexadecimal seed file from seed
...
...
@@ -75,11 +76,11 @@ class SigningKey(libnacl.sign.Signer):
fh
.
write
(
seedhex
)
@staticmethod
def
from_seedhex_file
(
path
:
str
)
->
SigningKeyType
:
def
from_seedhex_file
(
path
:
Union
[
Path
,
str
]
)
->
SigningKeyType
:
"""
Return SigningKey instance from Seedhex file
:param
str
path: Hexadecimal seed file path
:param path: Hexadecimal seed file path
"""
with
open
(
path
,
"
r
"
)
as
fh
:
seedhex
=
fh
.
read
()
...
...
@@ -100,7 +101,7 @@ class SigningKey(libnacl.sign.Signer):
seed
=
convert_seedhex_to_seed
(
seedhex
)
return
cls
(
seed
)
def
save_private_key
(
self
,
path
:
str
)
->
None
:
def
save_private_key
(
self
,
path
:
Union
[
Path
,
str
]
)
->
None
:
"""
Save authentication file
...
...
@@ -109,7 +110,7 @@ class SigningKey(libnacl.sign.Signer):
self
.
save
(
path
)
@staticmethod
def
from_private_key
(
path
:
str
)
->
SigningKeyType
:
def
from_private_key
(
path
:
Union
[
Path
,
str
]
)
->
SigningKeyType
:
"""
Read authentication file
Add public key attribute
...
...
@@ -135,7 +136,9 @@ class SigningKey(libnacl.sign.Signer):
)
@classmethod
def
from_pubsec_file
(
cls
:
Type
[
SigningKeyType
],
path
:
str
)
->
SigningKeyType
:
def
from_pubsec_file
(
cls
:
Type
[
SigningKeyType
],
path
:
Union
[
Path
,
str
]
)
->
SigningKeyType
:
"""
Return SigningKey instance from Duniter WIF file
...
...
@@ -166,7 +169,7 @@ class SigningKey(libnacl.sign.Signer):
return
cls
(
seed
)
def
save_pubsec_file
(
self
,
path
:
str
)
->
None
:
def
save_pubsec_file
(
self
,
path
:
Union
[
Path
,
str
]
)
->
None
:
"""
Save a Duniter PubSec file (PubSec) v1
...
...
@@ -194,7 +197,7 @@ sec: {signkey}""".format(
@staticmethod
def
from_wif_or_ewif_file
(
path
:
str
,
password
:
Optional
[
str
]
=
None
path
:
Union
[
Path
,
str
]
,
password
:
Optional
[
str
]
=
None
)
->
SigningKeyType
:
"""
Return SigningKey instance from Duniter WIF or EWIF file
...
...
@@ -239,7 +242,7 @@ sec: {signkey}""".format(
return
result
@staticmethod
def
from_wif_file
(
path
:
str
)
->
SigningKeyType
:
def
from_wif_file
(
path
:
Union
[
Path
,
str
]
)
->
SigningKeyType
:
"""
Return SigningKey instance from Duniter WIF file
...
...
@@ -286,7 +289,7 @@ sec: {signkey}""".format(
return
cls
(
seed
)
def
save_wif_file
(
self
,
path
:
str
)
->
None
:
def
save_wif_file
(
self
,
path
:
Union
[
Path
,
str
]
)
->
None
:
"""
Save a Wallet Import Format file (WIF) v1
...
...
@@ -316,7 +319,7 @@ Data: {data}""".format(
)
@staticmethod
def
from_ewif_file
(
path
:
str
,
password
:
str
)
->
SigningKeyType
:
def
from_ewif_file
(
path
:
Union
[
Path
,
str
]
,
password
:
str
)
->
SigningKeyType
:
"""
Return SigningKey instance from Duniter EWIF file
...
...
@@ -395,7 +398,7 @@ Data: {data}""".format(
return
cls
(
seed
)
def
save_ewif_file
(
self
,
path
:
str
,
password
:
str
)
->
None
:
def
save_ewif_file
(
self
,
path
:
Union
[
Path
,
str
]
,
password
:
str
)
->
None
:
"""
Save an Encrypted Wallet Import Format file (WIF v2)
...
...
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