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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ProofOfWorkgenerateProofOfWork(DrasylAddress address, byte difficulty) static bytegetDifficulty(ProofOfWork proofOfWork, IdentityPublicKey publicKey) abstract intgetNonce()incNonce()intintValue()Returns the value of thisProofOfWorkas anint.booleanisValid(DrasylAddress address, byte difficulty) Checks if the current proof of work is valid for given public key and difficulty.static ProofOfWorkof(int nonce) toString()
-
Constructor Details
-
ProofOfWork
public ProofOfWork()
-
-
Method Details
-
getNonce
public abstract int getNonce() -
toString
-
intValue
public int intValue()Returns the value of thisProofOfWorkas 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- ifnonceisnull
-
generateProofOfWork
-