Skip to content

Instantly share code, notes, and snippets.

@F483
Created May 23, 2016 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save F483/5aa17faf0d82b6756326dc767e514d97 to your computer and use it in GitHub Desktop.
Save F483/5aa17faf0d82b6756326dc767e514d97 to your computer and use it in GitHub Desktop.
ecies example
#!/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