Class Ed25519Signature

All Implemented Interfaces:
IValidated, IWriteable, Comparable<ABlob>

public class Ed25519Signature extends ASignature
Immutable data value class representing an Ed25519 digital signature.
  • Field Details

    • SIGNATURE_LENGTH

      public static final int SIGNATURE_LENGTH
      Length in bytes of an Ed25519 signature
      See Also:
    • ZERO

      public static final Ed25519Signature ZERO
      A Signature containing zero bytes (not valid)
  • Constructor Details

    • Ed25519Signature

      public Ed25519Signature(byte[] data, int pos)
  • Method Details

    • wrap

      public static Ed25519Signature wrap(byte[] signature)
      Creates a Signature instance with specific bytes
      Parameters:
      signature - Bytes for signature
      Returns:
      Signature instance
    • wrap

      public static Ed25519Signature wrap(byte[] data, int pos)
      Creates a Signature instance with specific bytes
      Parameters:
      signature - Bytes for signature
      Returns:
      Signature instance
    • isCanonical

      public boolean isCanonical()
      Description copied from class: ACell
      Returns true if this Cell is in a canonical representation for message writing. Non-canonical objects may be used on a temporary internal basis, they must always be converted to canonical representations for external use (e.g. Encoding).
      Specified by:
      isCanonical in class ACell
      Returns:
      true if the object is in canonical format, false otherwise
    • toCanonical

      public Ed25519Signature toCanonical()
      Description copied from class: ACell
      Converts this Cell to its canonical version. Must return this Cell if already canonical, may be O(n) in size of value otherwise.
      Specified by:
      toCanonical in class ABlob
      Returns:
      Canonical version of Cell
    • isCVMValue

      public final boolean isCVMValue()
      Description copied from class: ACell
      Returns true if this Cell represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false, pretty much everything else should return true. Note: CVM values might not be in a canonical format, e.g. temporary data structures
      Overrides:
      isCVMValue in class ABlob
      Returns:
      true if the object is a CVM Value, false otherwise
    • read

      public static Ed25519Signature read(ByteBuffer bb) throws BadFormatException
      Read a signature from a ByteBuffer. Assumes tag already read.
      Parameters:
      bb - ByteBuffer to read from
      Returns:
      Signature instance
      Throws:
      BadFormatException - If encoding is invalid
    • readRaw

      public static Ed25519Signature readRaw(ByteBuffer bb) throws BadFormatException
      Read signature raw data from a ByteBuffer. Assumes tag and count already read if present.
      Parameters:
      bb - ByteBuffer to read from
      Returns:
      Signature instance
      Throws:
      BadFormatException - If encoding is invalid
    • readRaw

      public static ASignature readRaw(Blob b, int pos)
    • encode

      public int encode(byte[] bs, int pos)
      Description copied from class: ACell
      Writes this Cell's encoding to a byte array, including a tag byte which will be written first. Cell must be canonical, or else an error may occur.
      Specified by:
      encode in interface IWriteable
      Specified by:
      encode in class ACell
      Parameters:
      bs - A byte array to which to write the encoding
      pos - The offset into the byte array
      Returns:
      New position after writing
    • toCVMString

      public AString toCVMString(long limit)
      Description copied from class: ACell
      Returns the CVM String representation of this Cell. Normally, this is as printed, but may be different for some types. MUST return null in O(1) time if the length of the CVM String would exceed limit. The String representation is intended to be a easy-to-read textual representation of the Cell's data content.
      Overrides:
      toCVMString in class ACell
      Parameters:
      limit - Limit of CVM String length in UTF-8 bytes
      Returns:
      CVM String, or null if limit exceeded
    • verify

      public boolean verify(AArrayBlob message, AccountKey publicKey)
      Description copied from class: ASignature
      Checks if the signature is valid for a given message hash
      Specified by:
      verify in class ASignature
      Parameters:
      message - Message to verify
      publicKey - Public key of signer
      Returns:
      True if signature is valid, false otherwise
    • validateCell

      public void validateCell() throws InvalidDataException
      Description copied from class: ACell
      Validates the local structure and invariants of this cell. Called by validate() super implementation. Should validate directly contained data, but should not validate all other structure of this cell. In particular, should not traverse potentially missing child Refs.
      Overrides:
      validateCell in class AArrayBlob
      Throws:
      InvalidDataException - If the Cell is invalid
    • estimatedEncodingSize

      public int estimatedEncodingSize()
      Description copied from interface: IWriteable
      Estimate the encoded data size for this Cell. Used for quickly sizing buffers. Implementations should try to return a size that is highly likely to contain the entire object when encoded, including the tag byte. Should not traverse soft Refs, i.e. must be usable on arbitrary partial data structures
      Returns:
      The estimated size for the binary representation of this object.
    • getBytes

      public byte[] getBytes()
      Description copied from class: ASignature
      Gets the raw bytes representing this signature, as a zero based array
      Specified by:
      getBytes in class ASignature
      Returns:
      byte array from this signature
    • getChunk

      public Blob getChunk(long i)
      Description copied from class: ABlob
      Gets a chunk of this Blob, as a canonical Blob up to the maximum chunk size. Returns empty Blob if and only if referencing the end of a Blob with fully packed chunks
      Specified by:
      getChunk in class ABlob
      Parameters:
      i - Index of chunk
      Returns:
      A Blob containing the specified chunk data.