Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update dependecies #94

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cpp/tools/ppc-builder/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
configparser
requests
toml
uuid
52 changes: 0 additions & 52 deletions python/ppc_common/ppc_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from enum import Enum, unique

import jwt
from ecdsa import SigningKey, SECP256k1, VerifyingKey
from gmssl import func, sm2, sm3
from google.protobuf.descriptor import FieldDescriptor
from jsoncomment import JsonComment
Expand Down Expand Up @@ -326,57 +325,6 @@ def make_job_event_message(job_id, job_priority, initiator_agency_id, receiver_a
return message.encode('utf-8')


def sign_with_secp256k1(message, private_key_str):
if isinstance(private_key_str, str):
private_key = SigningKey.from_string(
bytes().fromhex(private_key_str), curve=SECP256k1)
else:
private_key = SigningKey.from_string(private_key_str, curve=SECP256k1)
signature_bytes = private_key.sign(
make_hash(message, CryptoType.ECDSA, HashType.BYTES))
return str(encode(signature_bytes), 'utf-8')


def verify_with_secp256k1(message, signature_str, public_key_str):
if isinstance(public_key_str, str):
verify_key = VerifyingKey.from_string(
bytes().fromhex(public_key_str), curve=SECP256k1)
else:
verify_key = VerifyingKey.from_string(
decode(public_key_str), curve=SECP256k1)
return verify_key.verify(decode(signature_str), make_hash(message, CryptoType.ECDSA, HashType.BYTES))


def sign_with_sm2(message, private_key_str):
sm2_crypt = sm2.CryptSM2(private_key_str, "")
random_hex_str = func.random_hex(sm2_crypt.para_len)
message_hash = make_hash(message, CryptoType.GM).encode(encoding='utf-8')
signature_str = sm2_crypt.sign(message_hash, random_hex_str)
return signature_str


def verify_with_sm2(message, signature_str, public_key_str):
sm2_crypt = sm2.CryptSM2("", public_key_str)
message_hash = make_hash(message, CryptoType.GM).encode(encoding='utf-8')
return sm2_crypt.verify(signature_str, message_hash)


def make_signature(message, private_key_str, crypto_type):
if crypto_type == CryptoType.ECDSA:
return sign_with_secp256k1(message, private_key_str)

if crypto_type == CryptoType.GM:
return sign_with_sm2(message, private_key_str)


def verify_signature(message, signature, public_key_str, crypto_type):
if crypto_type == CryptoType.ECDSA:
return verify_with_secp256k1(message, signature, public_key_str)

if crypto_type == CryptoType.GM:
return verify_with_sm2(message, signature, public_key_str)


def exec_bash_command(cmd):
"""replace commands.get_status_output

Expand Down
4 changes: 1 addition & 3 deletions python/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ pycryptodome==3.9.9
pyjwt
pyyaml
mysqlclient==2.1.0
waitress==2.1.2
waitress==3.0.1
sqlparse~=0.4.1
ecdsa==0.19.0
toolz~=0.11.1
tenacity==7.0.0
coincurve~=13.0.0
Expand All @@ -47,7 +46,6 @@ requests-toolbelt==0.9.1
hdfs
scikit-learn~=0.24.2
gmpy2
openpyxl
networkx
pydot
snowland-smx
Expand Down
10 changes: 0 additions & 10 deletions python/wedpr_ml_toolkit/wedpr_ml_toolkit/common/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import random
from wedpr_ml_toolkit.common.utils.constant import Constant
from urllib.parse import urlencode, urlparse, parse_qs, quote


class IdPrefixEnum(Enum):
Expand All @@ -22,15 +21,6 @@ def generate_nonce(nonce_len):
return ''.join(str(random.choice(Constant.NUMERIC_ARRAY)) for _ in range(nonce_len))


def add_params_to_url(url, params):
parsed_url = urlparse(url)
query_params = parse_qs(parsed_url.query)
for key, value in params.items():
query_params[key] = value
new_query = urlencode(query_params, doseq=True)
return parsed_url._replace(query=new_query).geturl()


def file_exists(_file):
if os.path.exists(_file) and os.path.isfile(_file):
return True
Expand Down
Loading