ECC Operations

Elliptic Curve Cryptography (ECC) operations for the TROPIC01 chip.

ECC operations module for TROPIC01 secure element.

This module provides structured classes for ECC key information and signature objects, replacing the tuple-based API.

Main exports:
  • EccKeyInfo: Information about keys in secure slots

  • EcdsaSignature: ECDSA signature from P256 curve

  • EddsaSignature: EdDSA signature from Ed25519 curve

Example:

from tropicsquare import TropicSquare
from tropicsquare.ecc import EccKeyInfo, EcdsaSignature
from tropicsquare.constants.ecc import ECC_CURVE_ED25519

ts = TropicSquare(transport)
ts.start_secure_session(...)

# Read key information
key_info = ts.ecc_key_read(0)
if key_info.curve == ECC_CURVE_ED25519:
    print("Ed25519 key")
print(key_info.public_key.hex())

# Create signature
signature = ts.ecdsa_sign(1, message_hash)
print(signature.r.hex())
class tropicsquare.ecc.EccKeyInfo(curve, origin, public_key)[source]

Bases: object

ECC key information from secure key slot.

Represents the public key and metadata stored in a TROPIC01 ECC key slot, as returned by ecc_key_read().

Parameters:
  • curve (int) – Curve type (ECC_CURVE_P256 or ECC_CURVE_ED25519)

  • origin (int) – Key origin (ECC_KEY_ORIGIN_GENERATED or ECC_KEY_ORIGIN_STORED)

  • public_key (bytes) – Public key bytes (32 or 64 bytes depending on curve)

Example:

key_info = ts.ecc_key_read(0)
if key_info.curve == ECC_CURVE_ED25519:
    print("Ed25519 key")
print(key_info.public_key.hex())
__init__(curve, origin, public_key)[source]

Initialize ECC key information.

Parameters:
  • curve (int) – Curve type constant

  • origin (int) – Key origin constant

  • public_key (bytes) – Public key bytes

to_dict()[source]

Convert key information to dictionary.

Returns:

Dictionary with curve, origin, and public_key fields

Return type:

dict

Example:

{
    'curve': 1,
    'origin': 0,
    'public_key': '04a1b2c3...'
}
__str__()[source]

Get human-readable string representation.

Returns:

Formatted string with key information

Return type:

str

__repr__()[source]

Get detailed string representation for debugging.

Returns:

Detailed representation with class name and fields

Return type:

str

Supported Curves

  • P-256 (NIST P-256 / secp256r1) - ECDSA signatures

  • Ed25519 - EdDSA signatures

See Also