aboutsummaryrefslogtreecommitdiff
path: root/lib/curve25519-donna/python-src/curve25519/keys.py
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-11-05 01:45:06 +0100
committerdec05eba <dec05eba@protonmail.com>2020-11-05 01:45:06 +0100
commit2a8202e74846d191a321cca1202175af9db6107d (patch)
treea6f455caf07da1186851f343a237a4c4e4484f46 /lib/curve25519-donna/python-src/curve25519/keys.py
parent8efa0ec17d8c262f9c3fd7603e8074f74a053708 (diff)
Convert to sibs projectHEADmaster
Diffstat (limited to 'lib/curve25519-donna/python-src/curve25519/keys.py')
-rw-r--r--lib/curve25519-donna/python-src/curve25519/keys.py46
1 files changed, 0 insertions, 46 deletions
diff --git a/lib/curve25519-donna/python-src/curve25519/keys.py b/lib/curve25519-donna/python-src/curve25519/keys.py
deleted file mode 100644
index e131dac..0000000
--- a/lib/curve25519-donna/python-src/curve25519/keys.py
+++ /dev/null
@@ -1,46 +0,0 @@
-from . import _curve25519
-from hashlib import sha256
-import os
-
-# the curve25519 functions are really simple, and could be used without an
-# OOP layer, but it's a bit too easy to accidentally swap the private and
-# public keys that way.
-
-def _hash_shared(shared):
- return sha256(b"curve25519-shared:"+shared).digest()
-
-class Private:
- def __init__(self, secret=None, seed=None):
- if secret is None:
- if seed is None:
- secret = os.urandom(32)
- else:
- secret = sha256(b"curve25519-private:"+seed).digest()
- else:
- assert seed is None, "provide secret, seed, or neither, not both"
- if not isinstance(secret, bytes) or len(secret) != 32:
- raise TypeError("secret= must be 32-byte string")
- self.private = _curve25519.make_private(secret)
-
- def serialize(self):
- return self.private
-
- def get_public(self):
- return Public(_curve25519.make_public(self.private))
-
- def get_shared_key(self, public, hashfunc=None):
- if not isinstance(public, Public):
- raise ValueError("'public' must be an instance of Public")
- if hashfunc is None:
- hashfunc = _hash_shared
- shared = _curve25519.make_shared(self.private, public.public)
- return hashfunc(shared)
-
-class Public:
- def __init__(self, public):
- assert isinstance(public, bytes)
- assert len(public) == 32
- self.public = public
-
- def serialize(self):
- return self.public