Package org.drasyl.identity
Class ProofOfWork
java.lang.Object
org.drasyl.identity.ProofOfWork
This class models the proof of work for a given public key. Hence, identity creation becomes an
expensive operation and sybil attacks should be made more difficult.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ProofOfWork
generateProofOfWork
(DrasylAddress address, byte difficulty) static byte
getDifficulty
(ProofOfWork proofOfWork, IdentityPublicKey publicKey) abstract int
getNonce()
incNonce()
int
intValue()
Returns the value of thisProofOfWork
as anint
.boolean
isValid
(DrasylAddress address, byte difficulty) Checks if the current proof of work is valid for given public key and difficulty.static ProofOfWork
of
(int nonce) toString()
-
Constructor Details
-
ProofOfWork
public ProofOfWork()
-
-
Method Details
-
getNonce
public abstract int getNonce() -
toString
-
intValue
public int intValue()Returns the value of thisProofOfWork
as anint
. -
isValid
Checks if the current proof of work is valid for given public key and difficulty.- Parameters:
address
- the public keydifficulty
- the difficulty- Returns:
- if valid
true
, otherwisefalse
- Throws:
IllegalArgumentException
- if the difficulty is not in between [0,64]
-
getDifficulty
-
incNonce
-
of
- Throws:
NullPointerException
- ifnonce
isnull
-
generateProofOfWork
-