Package org.drasyl.identity
Class Identity
java.lang.Object
org.drasyl.identity.Identity
Represents the private identity of a peer (includes the proof of work, the public and private
key). Should be kept secret!
This is an immutable object.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Identity
Generates a new random identity.Returns the address for this identity.abstract KeyPair<IdentityPublicKey,
IdentitySecretKey> abstract ProofOfWork
boolean
isValid()
Validates the identity by checking whether the proof of work matches the public key.static Identity
static Identity
static Identity
of
(int proofOfWork, IdentitySecretKey identitySecretKey) static Identity
of
(int proofOfWork, KeyPair<IdentityPublicKey, IdentitySecretKey> identityKeyPair, KeyPair<KeyAgreementPublicKey, KeyAgreementSecretKey> keyAgreementKeyPair) static Identity
of
(ProofOfWork proofOfWork, String identityPublicKey, String identitySecretKey) static Identity
of
(ProofOfWork proofOfWork, IdentityPublicKey identityPublicKey, IdentitySecretKey identitySecretKey) static Identity
of
(ProofOfWork proofOfWork, IdentitySecretKey identitySecretKey) static Identity
of
(ProofOfWork proofOfWork, KeyPair<IdentityPublicKey, IdentitySecretKey> identityKeyPair) static Identity
of
(ProofOfWork proofOfWork, KeyPair<IdentityPublicKey, IdentitySecretKey> identityKeyPair, KeyPair<KeyAgreementPublicKey, KeyAgreementSecretKey> keyAgreementKeyPair) UnlikeObject.toString()
, this method returns the identity with the unmasked secret keys.
-
Field Details
-
POW_DIFFICULTY
public static final byte POW_DIFFICULTY
-
-
Constructor Details
-
Identity
public Identity()
-
-
Method Details
-
getProofOfWork
-
getIdentityKeyPair
-
getKeyAgreementKeyPair
-
getIdentityPublicKey
-
getIdentitySecretKey
-
toUnmaskedString
UnlikeObject.toString()
, this method returns the identity with the unmasked secret keys.- Returns:
- identity with unmasked secret keys
-
getAddress
Returns the address for this identity.- Returns:
- returns the address for this identity.
-
getKeyAgreementPublicKey
-
getKeyAgreementSecretKey
-
isValid
public boolean isValid()Validates the identity by checking whether the proof of work matches the public key.- Returns:
true
if this identity is valid. Otherwisefalse
-
of
public static Identity of(ProofOfWork proofOfWork, KeyPair<IdentityPublicKey, IdentitySecretKey> identityKeyPair, KeyPair<KeyAgreementPublicKey, KeyAgreementSecretKey> keyAgreementKeyPair) - Throws:
NullPointerException
- ifproofOfWork
,identityKeyPair
orkeyAgreementKeyPair
isnull
.
-
of
public static Identity of(ProofOfWork proofOfWork, IdentityPublicKey identityPublicKey, IdentitySecretKey identitySecretKey) - Throws:
NullPointerException
- ifproofOfWork
,identityPublicKey
oridentitySecretKey
isnull
.IllegalArgumentException
- ifidentityPublicKey
andidentitySecretKey
can not be converted to a key agreement key pair.
-
of
public static Identity of(ProofOfWork proofOfWork, KeyPair<IdentityPublicKey, IdentitySecretKey> identityKeyPair) - Throws:
IllegalArgumentException
- ifidentityKeyPair
can not be converted to a key agreement key pair.NullPointerException
- ifproofOfWork
,identityKeyPair
or a key within the pair isnull
-
of
public static Identity of(ProofOfWork proofOfWork, String identityPublicKey, String identitySecretKey) -
of
-
of
public static Identity of(int proofOfWork, KeyPair<IdentityPublicKey, IdentitySecretKey> identityKeyPair, KeyPair<KeyAgreementPublicKey, KeyAgreementSecretKey> keyAgreementKeyPair) - Throws:
NullPointerException
- ifidentityKeyPair
orkeyAgreementKeyPair
isnull
.
-
of
- Throws:
NullPointerException
- ifidentitySecretKey
isnull
.
-
of
- Throws:
NullPointerException
- ifproofOfWork
oridentitySecretKey
isnull
.
-
of
- Throws:
IllegalArgumentException
- ifidentitySecretKey
is not a valid secret key.
-
generateIdentity
Generates a new random identity.- Returns:
- the generated identity
- Throws:
IOException
- if an identity could not be generated
-