mirror of
https://github.com/varun-r-mallya/py-libp2p.git
synced 2026-02-11 15:40:54 +00:00
Make a KeyPair dataclass for passing around key pairs
This commit is contained in:
@ -1,9 +1,7 @@
|
||||
from typing import Tuple
|
||||
|
||||
import Crypto.PublicKey.RSA as RSA
|
||||
from Crypto.PublicKey.RSA import RsaKey
|
||||
|
||||
from libp2p.crypto.keys import KeyType, PrivateKey, PublicKey
|
||||
from libp2p.crypto.keys import KeyPair, KeyType, PrivateKey, PublicKey
|
||||
|
||||
|
||||
class RSAPublicKey(PublicKey):
|
||||
@ -42,13 +40,11 @@ class RSAPrivateKey(PrivateKey):
|
||||
return RSAPublicKey(self.impl.publickey())
|
||||
|
||||
|
||||
def create_new_key_pair(
|
||||
bits: int = 2048, e: int = 65537
|
||||
) -> Tuple[PrivateKey, PublicKey]:
|
||||
def create_new_key_pair(bits: int = 2048, e: int = 65537) -> KeyPair:
|
||||
"""
|
||||
Returns a new RSA keypair with the requested key size (``bits``) and the given public
|
||||
exponent ``e``. Sane defaults are provided for both values.
|
||||
"""
|
||||
private_key = RSAPrivateKey.new(bits, e)
|
||||
public_key = private_key.get_public_key()
|
||||
return private_key, public_key
|
||||
return KeyPair(private_key, public_key)
|
||||
|
||||
Reference in New Issue
Block a user