sawtooth_signing package¶
Submodules¶
sawtooth_signing.core module¶
-
exception
sawtooth_signing.core.
NoSuchAlgorithmError
[source]¶ Bases:
Exception
Thrown when trying to create an algorithm which does not exist.
-
exception
sawtooth_signing.core.
SigningError
[source]¶ Bases:
Exception
Thrown when an error occurs during the signing process.
-
exception
sawtooth_signing.core.
ParseError
[source]¶ Bases:
Exception
Thrown when an error occurs during deserialization of a Private or Public key from various formats.
-
class
sawtooth_signing.core.
PrivateKey
[source]¶ Bases:
object
A private key instance.
The underlying content is dependent on implementation.
-
class
sawtooth_signing.core.
PublicKey
[source]¶ Bases:
object
A public key instance.
The underlying content is dependent on implementation.
-
class
sawtooth_signing.core.
Context
[source]¶ Bases:
object
A context for a cryptographic signing algorithm.
-
sign
(message, private_key)[source]¶ Sign a message
Given a private key for this algorithm, sign the given message bytes and return a hex-encoded string of the resulting signature.
Parameters: - message (bytes) – the message bytes
- private_key (
PrivateKey
) – the private key
Returns: The signature in a hex-encoded string
Raises: SigningError
– if any error occurs during the signing process
-
verify
(signature, message, public_key)[source]¶ Verifies that a signature of a message was produced with the associated public key.
Parameters: - signature (str) – the hex-encoded signature
- message (bytes) – the message bytes
- public_key (
PublicKey
) – the public key to use for verification
Returns: True if the public key is associated with the signature for that method, False otherwise
Return type: boolean
-
new_random_private_key
()[source]¶ Generates a new random PrivateKey using this context.
Returns: a random private key Return type: ( PrivateKey
)
-
get_public_key
(private_key)[source]¶ Produce a public key for the given private key.
Parameters: private_key ( PrivateKey
) – a private keyReturns: ( PublicKey
) the public key for the given private key
-
sawtooth_signing.secp256k1 module¶
-
class
sawtooth_signing.secp256k1.
Secp256k1PrivateKey
(secp256k1_private_key)[source]¶ Bases:
sawtooth_signing.core.PrivateKey
-
secp256k1_private_key
¶
-
-
class
sawtooth_signing.secp256k1.
Secp256k1PublicKey
(secp256k1_public_key)[source]¶ Bases:
sawtooth_signing.core.PublicKey
-
secp256k1_public_key
¶
-
Module contents¶
-
class
sawtooth_signing.
Signer
(context, private_key)[source]¶ Bases:
object
A convenient wrapper of Context and PrivateKey