Created
May 23, 2016 11:28
-
-
Save F483/5aa17faf0d82b6756326dc767e514d97 to your computer and use it in GitHub Desktop.
ecies example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import pyelliptic | |
import time | |
data = b"x" * (1024 ** 2 * 100) # 100M | |
# TODO curve25519 (openssl and tor default) | |
# curve = "sect283r1" # default | |
# curve = "sect571r1" | |
curve = "secp256k1" # bitcoin curve | |
alice = pyelliptic.ECC(curve=curve) | |
bob = pyelliptic.ECC(curve=curve) | |
before = time.time() | |
ciphertext = alice.encrypt(data, bob.get_pubkey()) | |
after = time.time() | |
print("encrypt:", after - before) | |
before = time.time() | |
decrypted_data = bob.decrypt(ciphertext) | |
after = time.time() | |
print("encrypt:", after - before) | |
print(data == decrypted_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment