[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Drop the HSv3PublicBlindedKey class
commit 864cc12bc3bf057d92f96bc40369447003151ea5
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Thu Nov 7 14:42:57 2019 -0800
Drop the HSv3PublicBlindedKey class
This class' verify() method was never called, making it effectively a container
for its single attribute.
---
stem/descriptor/hidden_service.py | 8 +++-----
stem/descriptor/hsv3_crypto.py | 31 ++++++-------------------------
2 files changed, 9 insertions(+), 30 deletions(-)
diff --git a/stem/descriptor/hidden_service.py b/stem/descriptor/hidden_service.py
index 7b6651b7..54874f0d 100644
--- a/stem/descriptor/hidden_service.py
+++ b/stem/descriptor/hidden_service.py
@@ -849,7 +849,7 @@ def _get_descriptor_signing_cert(descriptor_signing_public_key, blinded_priv_key
expiration_date = datetime.datetime.utcnow() + datetime.timedelta(hours=54)
signing_key = stem.util._pubkey_bytes(descriptor_signing_public_key)
- extensions = [Ed25519Extension(ExtensionType.HAS_SIGNING_KEY, None, blinded_priv_key.public_key().public_key)]
+ extensions = [Ed25519Extension(ExtensionType.HAS_SIGNING_KEY, None, blinded_priv_key.blinded_pubkey)]
desc_signing_cert = Ed25519CertificateV1(CertType.HS_V3_DESC_SIGNING, expiration_date, 1, signing_key, extensions, signing_key = blinded_priv_key)
@@ -1027,13 +1027,11 @@ class HiddenServiceDescriptorV3(BaseHiddenServiceDescriptor):
raise ValueError('Need to provide a blinding param for this descriptor')
# Get the identity public key
- public_identity_key = ed25519_private_identity_key.public_key()
- public_identity_key_bytes = stem.util._pubkey_bytes(public_identity_key)
+ public_identity_key_bytes = stem.util._pubkey_bytes(ed25519_private_identity_key)
# Blind the identity key to get ephemeral blinded key
blinded_privkey = stem.descriptor.hsv3_crypto.HSv3PrivateBlindedKey(ed25519_private_identity_key, blinding_param = blinding_param)
- blinded_pubkey = blinded_privkey.public_key()
- blinded_pubkey_bytes = blinded_pubkey.public_key
+ blinded_pubkey_bytes = blinded_privkey.blinded_pubkey
# Generate descriptor signing key
signing_key = Ed25519PrivateKey.generate()
diff --git a/stem/descriptor/hsv3_crypto.py b/stem/descriptor/hsv3_crypto.py
index 73654866..5bce5dcf 100644
--- a/stem/descriptor/hsv3_crypto.py
+++ b/stem/descriptor/hsv3_crypto.py
@@ -2,11 +2,8 @@ import hashlib
import struct
import os
+import stem.descriptor.ed25519_exts_ref
import stem.descriptor.slow_ed25519
-import stem.prereq
-
-from stem.descriptor import ed25519_exts_ref
-from stem.descriptor import slow_ed25519
"""
@@ -31,30 +28,14 @@ class HSv3PrivateBlindedKey(object):
secret_seed = hazmat_private_key.private_bytes(encoding = serialization.Encoding.Raw, format = serialization.PrivateFormat.Raw, encryption_algorithm = serialization.NoEncryption())
assert(len(secret_seed) == 32)
- expanded_identity_priv_key = ed25519_exts_ref.expandSK(secret_seed)
- identity_public_key = slow_ed25519.publickey(secret_seed)
-
- self.blinded_secret_key = ed25519_exts_ref.blindESK(expanded_identity_priv_key, blinding_param)
- blinded_public_key = ed25519_exts_ref.blindPK(identity_public_key, blinding_param)
- self.blinded_public_key = HSv3PublicBlindedKey(blinded_public_key)
+ expanded_identity_priv_key = stem.descriptor.ed25519_exts_ref.expandSK(secret_seed)
+ identity_public_key = stem.descriptor.slow_ed25519.publickey(secret_seed)
- def public_key(self):
- return self.blinded_public_key
+ self.blinded_secret_key = stem.descriptor.ed25519_exts_ref.blindESK(expanded_identity_priv_key, blinding_param)
+ self.blinded_pubkey = stem.descriptor.ed25519_exts_ref.blindPK(identity_public_key, blinding_param)
def sign(self, msg):
- return ed25519_exts_ref.signatureWithESK(msg, self.blinded_secret_key, self.blinded_public_key.public_key)
-
-
-class HSv3PublicBlindedKey(object):
- def __init__(self, public_key):
- self.public_key = public_key
-
- def verify(self, signature, message):
- """
- raises exception if sig not valid
- """
-
- stem.descriptor.slow_ed25519.checkvalid(signature, message, self.public_key)
+ return stem.descriptor.ed25519_exts_ref.signatureWithESK(msg, self.blinded_secret_key, self.blinded_pubkey)
"""
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits