Package convex.core.data
Class AccountKey
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.data.ACountable<CVMByte>
convex.core.data.ABlob
convex.core.data.AArrayBlob
convex.core.data.AccountKey
- All Implemented Interfaces:
IValidated
,IWriteable
,Comparable<ABlob>
Immutable class representing an Ed25519 Public Key for an Account
Using Ed25519:
- AccountKey is the Public Key (32 bytes)
-
Field Summary
FieldsFields inherited from class convex.core.data.AArrayBlob
length, offset, store
Fields inherited from class convex.core.data.ABlob
contentHash
Fields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY
-
Method Summary
Modifier and TypeMethodDescriptionprotected long
Calculates the Memory Size for this Cell.static AccountKey
Creates an AccountKey from a blob.Creates a new Ref for this Cellstatic AccountKey
Creates a "Dummy" Address that is not a valid public key, and therefore cannot have valid signed transactions.int
encode(byte[] bs, int pos)
Writes this Cell's encoding to a byte array, including a tag byte which will be written firstboolean
Determines if this Blob is equal to another Blob.boolean
equals(AccountKey o)
int
Estimate the encoded data size for this Cell.static AccountKey
fromChecksumHex(String hexString)
Constructs an AccountKey object from a checksummed hex string.static AccountKey
Constructs an AccountKey object from a hex string.static AccountKey
fromHexOrNull(AString a)
static AccountKey
fromHexOrNull(String hexString)
Constructs an AccountKey object from a hex stringgetChunk(long i)
Gets a chunk of this Blob, as a canonical Blob up to the maximum chunk sizelong
Method to calculate the encoding length of a Cell.byte
getTag()
Gets the tag byte for this cell.getType()
Gets the most specific known runtime Type for this Cell.boolean
Returns true if this Cell is in a canonical format for message writing.boolean
Returns true if this object represents a first class CVM Value.boolean
Determines if this Cell Represents an embedded object.boolean
Returns true if this object is a regular blob (i.e.static AccountKey
readRaw(ByteBuffer data)
Converts this Cell to its canonical version.Converts this AccountKey to a checksummed hex string.void
Validates the local structure and invariants of this cell.static AccountKey
wrap(byte[] data)
Wraps the specified bytes as an AccountKey object.static AccountKey
wrap(byte[] data, int offset)
Wraps the specified bytes as an AccountKey object.Methods inherited from class convex.core.data.AArrayBlob
append, byteAt, commonHexPrefixLength, compareTo, compareTo, count, encodeRaw, equalsBytes, equalsBytes, getByteBuffer, getBytes, getHexDigit, getInternalArray, getInternalOffset, getRefCount, getUnchecked, hexMatches, hexMatchLength, longValue, rangeMatches, rangeMatches, slice, slice, toBlob, toHexString, toHexString, toLong, updateDigest, validate, writeToBuffer, writeToBuffer
Methods inherited from class convex.core.data.ABlob
computeHash, empty, equals, get, getBytes, getContentHash, getElementRef, hashCode, hexEquals, hexEquals, hexLength, print, toByteBuffer, toHexString
Methods inherited from class convex.core.data.ACountable
isEmpty, size
Methods inherited from class convex.core.data.ACell
announce, announce, attachMemorySize, attachRef, cachedEncoding, cachedHash, createAnnounced, createEncoding, createPersisted, createPersisted, equals, getChildRefs, getEncoding, getHash, getMemorySize, getRef, getRef, toString, updateRefs, write
Methods inherited from class convex.core.data.AObject
attachEncoding, print
-
Field Details
-
LENGTH
public static final int LENGTH- See Also:
- Constant Field Values
-
TYPE
-
LENGTH_BITS
public static final int LENGTH_BITS- See Also:
- Constant Field Values
-
ZERO
-
-
Method Details
-
getType
Description copied from class:ACell
Gets the most specific known runtime Type for this Cell. -
createRef
Description copied from class:ACell
Creates a new Ref for this Cell -
wrap
Wraps the specified bytes as an AccountKey object. Warning: underlying bytes are used directly. Use only if no external references to the byte array will be retained.- Parameters:
data
- Byte array to wrap as Account Key- Returns:
- An Address wrapping the given bytes
-
wrap
Wraps the specified bytes as an AccountKey object. Warning: underlying bytes are used directly. Use only if no external references to the byte array will be retained.- Parameters:
data
- Data array containing address bytes.offset
- Offset into byte array- Returns:
- An Address wrapping the given bytes
-
create
Creates an AccountKey from a blob. Must have correct length.- Parameters:
b
- Blob to wrap as Account Key- Returns:
- AccountKey instance, or null if not valid
-
dummy
Creates a "Dummy" Address that is not a valid public key, and therefore cannot have valid signed transactions. To do this, a short hex nonce is repeated to fill the entire address length. This construction makes it possible to examine an Address and assess whether it is (plausibly) a dummy address.- Parameters:
nonce
- Hex string to repeat to produce a visible dummy address- Returns:
- An Address that cannot be used to sign transactions.
-
equals
Description copied from class:ABlob
Determines if this Blob is equal to another Blob. Blobs are defined to be equal if they have the same on-chain representation, i.e. if and only if all of the following are true: - Blob is of the same general type - Blobs are of the same length - All byte values are equal -
equals
-
fromHex
Constructs an AccountKey object from a hex string. Throws an exception if string is not valid- Parameters:
hexString
- Hex String- Returns:
- An AccountKey constructed from the hex string
-
fromHexOrNull
Constructs an AccountKey object from a hex string- Parameters:
hexString
- Hex String- Returns:
- An Address constructed from the hex string, or null if not a valid hex string
-
fromHexOrNull
-
fromChecksumHex
Constructs an AccountKey object from a checksummed hex string. Throws an exception if checksum is not valid- Parameters:
hexString
- Hex String- Returns:
- An Address constructed from the hex string
-
toChecksumHex
Converts this AccountKey to a checksummed hex string.- Returns:
- A String containing the checksummed hex representation of this Address
-
readRaw
-
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- Specified by:
encode
in interfaceIWriteable
- Specified by:
encode
in classACell
- Parameters:
bs
- A byte array to which to write the encodingpos
- The offset into the byte array- Returns:
- New position after writing
-
isCVMValue
public final boolean isCVMValue()Description copied from class:ACell
Returns true if this object represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false. CVM values might not be in a canonical format, e.g. temporary data structures- Specified by:
isCVMValue
in classACell
- Returns:
- true if the object is a CVM Value, false otherwise
-
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 likely to contain the entire object when represented in binary format, including the tag byte.- Returns:
- The estimated size for the binary representation of this object.
-
getEncodingLength
public long getEncodingLength()Description copied from class:ACell
Method to calculate the encoding length of a Cell. May be overridden to avoid creating encodings during memory size calculations. This reduces hashing!- Overrides:
getEncodingLength
in classACell
- Returns:
- Exact encoding length of this Cell
-
getChunk
Description copied from class:ABlob
Gets a chunk of this Blob, as a canonical Blob up to the maximum chunk size -
validateCell
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 classAArrayBlob
- Throws:
InvalidDataException
- If the Cell is invalid
-
isEmbedded
public boolean isEmbedded()Description copied from class:ACell
Determines if this Cell Represents an embedded object. Embedded objects are encoded directly into the encoding of the containing Cell (avoiding the need for a hashed reference). Subclasses should override this if they have a cheap O(1) way to determine if they are embedded or otherwise.- Overrides:
isEmbedded
in classACell
- Returns:
- true if Cell is embedded, false otherwise
-
calcMemorySize
protected long calcMemorySize()Description copied from class:ACell
Calculates the Memory Size for this Cell. Requires any child Refs to be either Direct or of persisted status at minimum, or you might get a MissingDataException- Overrides:
calcMemorySize
in classACell
- Returns:
- Memory Size of this Cell
-
isRegularBlob
public boolean isRegularBlob()Description copied from class:ABlob
Returns true if this object is a regular blob (i.e. not a special blob type like Hash or Address)- Overrides:
isRegularBlob
in classABlob
- Returns:
- True if a regular blob
-
getTag
public byte getTag()Description copied from class:ACell
Gets the tag byte for this cell. The tag byte is always written as the first byte of the Cell's Encoding -
isCanonical
public boolean isCanonical()Description copied from class:ACell
Returns true if this Cell is in a canonical format for message writing. Reading or writing a non-canonical value should be considered illegal, but non-canonical objects may be used on a temporary internal basis.- Specified by:
isCanonical
in classACell
- Returns:
- true if the object is in canonical format, false otherwise
-
toCanonical
Description copied from class:ACell
Converts this Cell to its canonical version. Returns this if already canonical- Specified by:
toCanonical
in classABlob
- Returns:
- Canonical version of Cell
-