add ed25519 private key deserializer

This commit is contained in:
Alex Stokes 2019-09-24 09:50:03 -07:00
parent bbd8279811
commit 487c923791
No known key found for this signature in database
GPG Key ID: 51CE1721B245C086
2 changed files with 8 additions and 2 deletions

View File

@ -47,6 +47,11 @@ class Ed25519PrivateKey(PrivateKey):
def to_bytes(self) -> bytes:
return bytes(self.impl)
@classmethod
def from_bytes(cls, data: bytes) -> "Ed25519PrivateKey":
impl = PrivateKeyImpl(data)
return cls(impl)
def get_type(self) -> KeyType:
return KeyType.Ed25519

View File

@ -1,4 +1,4 @@
from libp2p.crypto.ed25519 import Ed25519PublicKey
from libp2p.crypto.ed25519 import Ed25519PrivateKey, Ed25519PublicKey
from libp2p.crypto.exceptions import MissingDeserializerError
from libp2p.crypto.keys import KeyType, PrivateKey, PublicKey
from libp2p.crypto.rsa import RSAPublicKey
@ -11,7 +11,8 @@ key_type_to_public_key_deserializer = {
}
key_type_to_private_key_deserializer = {
KeyType.Secp256k1.value: Secp256k1PrivateKey.from_bytes
KeyType.Secp256k1.value: Secp256k1PrivateKey.from_bytes,
KeyType.Ed25519.value: Ed25519PrivateKey.from_bytes,
}