The private key detection is automatic with the class PrivateKey. It currently works with RSA (X.509 with PKCS#12 files: .p12, or .pfx) and with ECDSA (Ethereum account exported in a JSON file).
pip install digsigRSA (X.509)
from digsig import PrivateKey, PublicKey
private_key = PrivateKey.get_instance('fnmt.p12', 'p4ssw0rd')
signature = private_key.sign('message')
# public_key = private_key.public_key
public_key = PublicKey.get_instance('fnmt.pem')ECDSA (Ethereum)
from digsig import PrivateKey, PublicKey
private_key = PrivateKey.get_instance('ethereum.json', 'p4ssw0rd')
signature = private_key.sign('message')
public_key = private_key.public_keyfrom digsig import RsaPrivateKey, RsaModes, RsaFormats
private_key = RsaPrivateKey('fnmt.p12', 'p4ssw0rd', mode=RsaModes.PSS_MGF1_SHA3_256)
signature = private_key.sign('message')
# public_key = private_key.public_key
public_key = RsaPublicKey('fnmt.pem', mode=RsaModes.PSS_MGF1_SHA3_256)from digsig import EcdsaPrivateKey, EcdsaModes
private_key = EcdsaPrivateKey('account.json', 'p4ssw0rd', mode=EcdsaModes.SECP256K1_SHA3_256)
signature = private_key.sign('message')
public_key = private_key.public_keyfrom digsig.errors import InvalidSignatureError
try:
public_key.verify(signature)
except InvalidSignatureError:
print('Invalid signature.')from digsig import RsaPrivateKey, RsaModes
private_key = RsaPrivateKey(mode=RsaModes.PSS_MGF1_SHA256)
public_key = private_key.public_keyfrom digsig import EcdsaPrivateKey, EcdsaModes
private_key = EcdsaPrivateKey(mode=EcdsaModes.SECP256K1_KECCAK_256_ETHEREUM)
public_key = private_key.public_keyprivate_pem = private_key.private_pem
public_pem = private_key.public_key.public_pemprivate_value = private_key.private_value
private_value_bytes = private_key.private_value_bytes
private_value_hex = private_key.private_value_hex
private_value_base64 = private_key.private_value_base64
ethereum_keystore = private_key.get_ethereum_account()
public_value = private_key.public_key.public_value
public_bytes = private_key.public_key.public_bytes
public_base64 = private_key.public_key.public_base64
ethereum_address = private_key.public_key.ethereum_addressTo-Do
To-Do
To-Do
To-Do
