Merge pull request #41 from zixuanzh/rsa-public-key

Rsa public key added for id generation
This commit is contained in:
Robert Zajac 2018-11-11 13:27:51 -05:00 committed by GitHub
commit c8447ef6ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -2,6 +2,7 @@ from ..peer.peerstore import PeerStore
from ..network.swarm import Swarm
from ..host.basic_host import BasicHost
from ..transport.upgrader import TransportUpgrader
from Crypto.PublicKey import RSA
class Libp2p(object):
@ -15,16 +16,18 @@ class Libp2p(object):
self.idOpt = idOpt
else:
# TODO generate RSA public key pair
pass
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.muxerOpt = muxerOpt
self.muxerOpt = muxerOpt
self.secOpt = secOpt
self.peerstore = peerstore
def new_node(self):
swarm = Swarm(self.id, self.peerstore)
swarm = Swarm(self.idOpt, self.peerstore)
host = BasicHost(swarm)
upgrader = TransportUpgrader(self.secOpt, self.transportOpt)

View File

@ -1,3 +1,4 @@
asyncio
pylint
pytest
pycryptodome