Skip to main content

A simple implementation of unauthenticated ECDH

Project description

A simple implementation of unauthenticated ECDH

This package implements unauthenticated ECDH between two endpoints. Authentication can then later be added by, for example, mutual short string authentication (as exemplified by the simpleauthstrings package).

Here is a sample with working code:

from blindecdh import ECDHProtocol
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.serialization import (

def pubkey_to_pem(pubkey):
    return pubkey.public_bytes(

def pem_to_pubkey(pem):
    return load_pem_public_key(pem)

# ------------------------

# Alice's side.

## Instantiate the protocol.
alice = ECDHProtocol()

## Serialize and send Alice's public key.
## The specific communications mechanism is omitted for brevity.
## We assume both parties traffic in PEM-encoded certificates.

## Get and deserialize Bob's public key.
bobs_public_key = pem_to_pubkey(bob_socket.receive())

## Compute the result.
result =

## Display the derived key.  It will match Bob's.

# -----------------------

# Bob's side.

bob = ECDHProtocol()

## Get and deserialize Alice's public key.
## On Bob's side we do the send first, but here we receive first.
alices_public_key = pem_to_pubkey(alice_socket.receive())

## Serialize and send Bob's public key.

## Compute the result.
result =

## Display the derived key.  It will match Bob's.

See module for developer documentation.

This package is distributed under the GNU Lesser General Public License v2.1. For relicensing, contact the package author.

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

blindecdh-0.1.4.tar.gz (13.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page