Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
clients
python
DuniterPy
Commits
dec3b867
Commit
dec3b867
authored
Jan 13, 2019
by
Vincent Texier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[enh] Use static method to load private key file
parent
08077e86
Pipeline
#4374
passed with stages
in 3 minutes and 30 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
20 deletions
+18
-20
duniterpy/key/signing_key.py
duniterpy/key/signing_key.py
+18
-20
No files found.
duniterpy/key/signing_key.py
View file @
dec3b867
...
...
@@ -68,7 +68,6 @@ class SigningKey(libnacl.sign.Signer):
return
cls
(
seed
)
def
save_private_key
(
self
,
path
:
str
)
->
None
:
"""
Save authentication file
...
...
@@ -77,7 +76,7 @@ class SigningKey(libnacl.sign.Signer):
"""
self
.
save
(
path
)
@
staticmethod
def
from_private_key
(
path
:
str
)
->
SigningKeyType
:
"""
Read authentication file
...
...
@@ -89,7 +88,6 @@ class SigningKey(libnacl.sign.Signer):
key
.
pubkey
=
Base58Encoder
.
encode
(
key
.
vk
)
return
key
def
decrypt_seal
(
self
,
message
:
bytes
)
->
str
:
"""
Decrypt message with a curve25519 version of the ed25519 key pair
...
...
@@ -135,26 +133,26 @@ class SigningKey(libnacl.sign.Signer):
return
cls
(
seed
)
def
save_pubsec_file
(
self
,
path
:
str
)
->
None
:
"""
Save a Duniter PubSec file (PubSec) v1
:param path: Path to file
"""
# version
version
=
1
# base58 encode keys
base58_signing_key
=
Base58Encoder
.
encode
(
self
.
sk
)
base58_public_key
=
self
.
pubkey
# save file
with
open
(
path
,
'w'
)
as
fh
:
fh
.
write
(
"""Type: PubSec
"""
Save a Duniter PubSec file (PubSec) v1
:param path: Path to file
"""
# version
version
=
1
# base58 encode keys
base58_signing_key
=
Base58Encoder
.
encode
(
self
.
sk
)
base58_public_key
=
self
.
pubkey
# save file
with
open
(
path
,
'w'
)
as
fh
:
fh
.
write
(
"""Type: PubSec
Version: {version}
pub: {pubkey}
sec: {signkey}"""
.
format
(
version
=
version
,
pubkey
=
base58_public_key
,
signkey
=
base58_signing_key
)
)
)
@
classmethod
def
from_wif_file
(
cls
:
Type
[
SigningKeyType
],
path
:
str
)
->
SigningKeyType
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment