added rsa public key generation
This commit is contained in:
parent
2639777d08
commit
e20d6df667
|
@ -3,6 +3,7 @@ from ..peer.peerstore import PeerStore
|
||||||
from ..network.swarm import Swarm
|
from ..network.swarm import Swarm
|
||||||
from ..host.basic_host import BasicHost
|
from ..host.basic_host import BasicHost
|
||||||
from ..transport.upgrader import TransportUpgrader
|
from ..transport.upgrader import TransportUpgrader
|
||||||
|
from Crypto.PublicKey import RSA
|
||||||
|
|
||||||
class Libp2p(object):
|
class Libp2p(object):
|
||||||
|
|
||||||
|
@ -16,6 +17,9 @@ class Libp2p(object):
|
||||||
self.idOpt = idOpt
|
self.idOpt = idOpt
|
||||||
else:
|
else:
|
||||||
# TODO generate RSA public key pair
|
# TODO generate RSA public key pair
|
||||||
|
new_key = RSA.generate(2048, e=65537)
|
||||||
|
self.idOpt = new_key.publickey().exportKey("PEM")
|
||||||
|
self.private_key = new_key.exportKey("PEM")
|
||||||
|
|
||||||
self.transportOpt = transportOpt
|
self.transportOpt = transportOpt
|
||||||
self.muxerOpt = muxerOpt
|
self.muxerOpt = muxerOpt
|
||||||
|
@ -24,7 +28,7 @@ class Libp2p(object):
|
||||||
|
|
||||||
def new_node(self):
|
def new_node(self):
|
||||||
|
|
||||||
swarm = Swarm(self.id, self.peerstore)
|
swarm = Swarm(self.idOpt, self.peerstore)
|
||||||
host = BasicHost(swarm)
|
host = BasicHost(swarm)
|
||||||
upgrader = TransportUpgrader(self.secOpt, self.transportOpt)
|
upgrader = TransportUpgrader(self.secOpt, self.transportOpt)
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
asyncio
|
asyncio
|
||||||
pylint
|
pylint
|
||||||
pytest
|
pytest
|
||||||
|
pycryptodome
|
||||||
|
|
Loading…
Reference in New Issue
Block a user