Skip to main content

Reference implementation of Curve25519 and Curve448 (goldilocks) as specified in RFC7748

Project description

This package contains a simple reference implementation of Curve25519 and Curve448 (goldilocks) as specified in RFC7748.

Caution: this implementation is inadvisable for use if timing invariance matters. Future versions of this package may implement a C backend.

eccsnacks is a play on the word ecchacks, a cool site by djb and Tanja Lange.

Installation

pip install eccsnacks

Usage

These examples demonstrate the Diffie-Hellman operation for each curve.

Curve25519:

from os import urandom
from eccsnacks.curve25519 import scalarmult, scalarmult_base

# Private keys in Curve25519 can be any 32-byte string.
a = urandom(32)
a_pub = scalarmult_base(a)

b = urandom(32)
b_pub = scalarmult_base(b)

# perform Diffie-Hellman computation for alice and bob
k_ab = scalarmult(a, b_pub)
k_ba = scalarmult(b, a_pub)

# keys should be the same
assert k_ab == k_ba

Curve448:

from os import urandom
from eccsnacks.curve448 import scalarmult, scalarmult_base

# Private keys in Curve448 can be any 32-byte string.
a = urandom(56)
a_pub = scalarmult_base(a)

b = urandom(56)
b_pub = scalarmult_base(b)

# perform Diffie-Hellman computation for alice and bob
k_ab = scalarmult(a, b_pub)
k_ba = scalarmult(b, a_pub)

# keys should be the same
assert k_ab == k_ba

Todo

  • Fast timing invariant implementation of both curves in C.

  • More curves.

Alternatives

Acknowledgements

  • Matthew Dempsky for slownacl which initially served as a baseline when implementing Curve25519.

  • djb for Curve25519

  • Mike Hamburg for Curve448

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eccsnacks-1.0.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eccsnacks-1.0.1-py3.5.egg (7.0 kB view details)

Uploaded Egg

File details

Details for the file eccsnacks-1.0.1.tar.gz.

File metadata

  • Download URL: eccsnacks-1.0.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for eccsnacks-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d6bbe85c079c3938e832998e9bf98110faafcdd4614aacf7a97305ebf338a308
MD5 09d535b6dfb07013cf4c2fe9bd25dc2d
BLAKE2b-256 c15bd4fdaca320473906f310bddbc722b8f935de5038217d0348ffccdf3e1887

See more details on using hashes here.

File details

Details for the file eccsnacks-1.0.1-py3.5.egg.

File metadata

  • Download URL: eccsnacks-1.0.1-py3.5.egg
  • Upload date:
  • Size: 7.0 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/33.1.1 requests-toolbelt/0.9.1 tqdm/4.44.1 CPython/3.6.1

File hashes

Hashes for eccsnacks-1.0.1-py3.5.egg
Algorithm Hash digest
SHA256 89cc9ac8e55fff49b604edbc127c652f026ee7b498fd66b9cefc8b6b4f3b60ce
MD5 b76b4525a95303b51627e2eb5a5936e3
BLAKE2b-256 23ad6098e53d65acb5ed355e5e0ed84db365bd11892a53d2bc8d4b677d257d09

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page