bbclib.libs.bbclib_keypair module

Copyright (c) 2018 beyond-blockchain.org.

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

bbclib.libs.bbclib_keypair.KeyPair

alias of bbclib.libs.bbclib_keypair.KeyPairPy

class bbclib.libs.bbclib_keypair.KeyPairPy(curvetype=2, compression=False, privkey=None, pubkey=None)[source]

Bases: object

POINT_CONVERSION_COMPRESSED = 2
POINT_CONVERSION_UNCOMPRESSED = 4

Key pair container

generate()[source]

Generate a new key pair

get_private_key_in_der()[source]

Return private key in DER format

get_private_key_in_pem()[source]

Return private key in PEM format

get_public_key_in_der()[source]

Return private key in DER format

get_public_key_in_pem()[source]

Return public key in PEM format

import_publickey_cert_pem(cert_pemstring, privkey_pemstring=None)[source]

Verify and import X509 public key certificate in pem format

mk_keyobj_from_private_key(privkey)[source]

Make a keypair object from the binary data of private key

mk_keyobj_from_private_key_der(derdat)[source]

Make a keypair object from the private key in DER format

mk_keyobj_from_private_key_pem(pemdat_string)[source]

Make a keypair object from the private key in PEM format

sign(digest)[source]

Sign to the given value

Parameters:digest (bytes) – given value
Returns:signature
Return type:bytes
to_binary(dat)[source]
verify(digest, sig)[source]

Verify the digest and the signature using the private key in this object

class bbclib.libs.bbclib_keypair.KeyType[source]

Bases: object

ECDSA_P256v1 = 2
ECDSA_SECP256k1 = 1
NOT_INITIALIZED = 0