Module: identity_key_pair
- class x3dh.identity_key_pair.IdentityKeyPair[source]
Bases:
ABCAn identity key pair.
There are following requirements for the identity key pair:
It must be able to create and verify Ed25519-compatible signatures.
It must be able to perform X25519-compatible Diffie-Hellman key agreements.
There are at least two different kinds of key pairs that can fulfill these requirements: Ed25519 key pairs and Curve25519 key pairs. The birational equivalence of both curves can be used to “convert” one pair to the other.
Both types of key pairs share the same private key, however instead of a private key, a seed can be used which the private key is derived from using SHA-512. This is standard practice for Ed25519, where the other 32 bytes of the SHA-512 seed hash are used as a nonce during signing. If a new key pair has to be generated, this implementation generates a seed.
- property model: IdentityKeyPairModel
Returns: The internal state of this
IdentityKeyPairas a pydantic model.
- property json: JSONObject
Returns: The internal state of this
IdentityKeyPairas a JSON-serializable Python object.
- static from_model(model)[source]
- Parameters:
model (
IdentityKeyPairModel) – The pydantic model holding the internal state of anIdentityKeyPair, as produced bymodel.- Return type:
- Returns:
A configured instance of
IdentityKeyPair, with internal state restored from the model.
Warning
Migrations are not provided via the
model/from_model()API. Usejson/from_json()instead. Refer to Serialization and Migration in the documentation for details.
- static from_json(serialized)[source]
- Parameters:
serialized (JSONObject) – A JSON-serializable Python object holding the internal state of an
IdentityKeyPair, as produced byjson.- Return type:
- Returns:
A configured instance of
IdentityKeyPair, with internal state restored from the serialized data.
- abstract property secret_type: SecretType
Returns: The type of secret used by this identity key (i.e. a seed or private key).
- abstract property secret: bytes
Returns: The secret used by this identity key, i.e. the seed or private key.
- abstractmethod as_priv()[source]
- Return type:
- Returns:
An
IdentityKeyPairPrivderived from this instance, or the instance itself if it already is anIdentityKeyPairPriv.
- class x3dh.identity_key_pair.IdentityKeyPairPriv(priv)[source]
Bases:
IdentityKeyPairAn
IdentityKeyPairrepresented by a Curve25519/Ed25519 private key.- Parameters:
priv (bytes)
- property secret_type: SecretType
Returns: The type of secret used by this identity key (i.e. a seed or private key).
- property secret: bytes
Returns: The secret used by this identity key, i.e. the seed or private key.
- as_priv()[source]
- Return type:
- Returns:
An
IdentityKeyPairPrivderived from this instance, or the instance itself if it already is anIdentityKeyPairPriv.
- class x3dh.identity_key_pair.IdentityKeyPairSeed(seed)[source]
Bases:
IdentityKeyPairAn
IdentityKeyPairrepresented by a Curve25519/Ed25519 seed.- Parameters:
seed (bytes)
- property secret_type: SecretType
Returns: The type of secret used by this identity key (i.e. a seed or private key).
- property secret: bytes
Returns: The secret used by this identity key, i.e. the seed or private key.
- as_priv()[source]
- Return type:
- Returns:
An
IdentityKeyPairPrivderived from this instance, or the instance itself if it already is anIdentityKeyPairPriv.