Class ProofOfWork

java.lang.Object
org.drasyl.identity.ProofOfWork

public abstract class ProofOfWork extends Object
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 Details

    • ProofOfWork

      public ProofOfWork()
  • Method Details

    • getNonce

      public abstract int getNonce()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • intValue

      public int intValue()
      Returns the value of this ProofOfWork as an int.
    • isValid

      public boolean isValid(DrasylAddress address, byte difficulty)
      Checks if the current proof of work is valid for given public key and difficulty.
      Parameters:
      address - the public key
      difficulty - the difficulty
      Returns:
      if valid true, otherwise false
      Throws:
      IllegalArgumentException - if the difficulty is not in between [0,64]
    • getDifficulty

      public static byte getDifficulty(ProofOfWork proofOfWork, IdentityPublicKey publicKey)
    • incNonce

      public ProofOfWork incNonce()
    • of

      public static ProofOfWork of(int nonce)
      Throws:
      NullPointerException - if nonce is null
    • generateProofOfWork

      public static ProofOfWork generateProofOfWork(DrasylAddress address, byte difficulty)