Signature Classes

Classes for handling ECDSA and EdDSA signatures.

Signature classes for TROPIC01 ECC signing operations.

class tropicsquare.ecc.signature.Signature(r, s)[source]

Bases: object

Base class for cryptographic signatures.

Represents a digital signature with R and S components as returned by TROPIC01 signing operations (ECDSA and EdDSA).

Parameters:
  • r (bytes) – R component of signature (32 bytes)

  • s (bytes) – S component of signature (32 bytes)

__init__(r, s)[source]

Initialize signature.

Parameters:
  • r (bytes) – R component (32 bytes)

  • s (bytes) – S component (32 bytes)

to_dict()[source]

Convert signature to dictionary.

Returns:

Dictionary with R and S components

Return type:

dict

Example:

{
    'r': 'a1b2c3...',
    's': 'd4e5f6...'
}
__str__()[source]

Get human-readable string representation.

Returns:

Formatted signature with R and S components

Return type:

str

__repr__()[source]

Get detailed string representation for debugging.

Returns:

Detailed representation with class name

Return type:

str

class tropicsquare.ecc.signature.EcdsaSignature(r, s)[source]

Bases: Signature

ECDSA signature from P256 curve signing operation.

Represents an ECDSA (Elliptic Curve Digital Signature Algorithm) signature created using the P256 curve. This signature can be verified using standard ECDSA verification with the corresponding public key.

The signature consists of two 32-byte components (R, S) that can be converted to DER encoding for use with standard cryptographic libraries.

Example:

signature = ts.ecdsa_sign(1, message_hash)
print(signature.r.hex())
print(signature.s.hex())
Parameters:
class tropicsquare.ecc.signature.EddsaSignature(r, s)[source]

Bases: Signature

EdDSA signature from Ed25519 curve signing operation.

Represents an EdDSA (Edwards-curve Digital Signature Algorithm) signature created using the Ed25519 curve. This signature can be verified using standard Ed25519 verification with the corresponding public key.

The signature consists of two 32-byte components (R, S) that form the standard 64-byte Ed25519 signature format when concatenated.

Example:

signature = ts.eddsa_sign(0, message)
print(signature.r.hex())
print(signature.s.hex())
Parameters:

Signature Types

  • EcdsaSignature - ECDSA signatures for P-256 curve

  • EddsaSignature - EdDSA signatures for Ed25519 curve

See Also