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 first.boolean
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 size.long
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 representation for message writing.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, appendHexString, appendSmall, byteAt, commonHexPrefixLength, compareTo, compareTo, count, encodeRaw, encodeRawData, equalsBytes, equalsBytes, getByteBuffer, getBytes, getHexDigit, getInternalArray, getInternalOffset, getRefCount, getUnchecked, hexMatches, hexMatchLength, longValue, rangeMatches, rangeMatches, slice, toFlatBlob, toLong, updateDigest, validate, writeToBuffer, writeToBuffer
Methods inherited from class convex.core.data.ABlob
computeHash, empty, equals, get, getBytes, getContentHash, getElementRef, hashCode, hexEquals, hexEquals, hexLength, isCVMValue, print, slice, toByteBuffer, toCVMString, toHexString, toHexString, 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, getCanonical, getChildRefs, getEncoding, getHash, getMemorySize, getRef, getRef, isCompletelyEncoded, mark, mark, toString, updateRefs, write
Methods inherited from class convex.core.data.AObject
attachEncoding, print, 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. Cell must be canonical, or else an error may occur.- 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
-
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. Returns empty Blob if and only if referencing the end of a Blob with fully packed chunks -
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 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 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 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 Cell if already canonical, may be O(n) in size of value otherwise.- Specified by:
toCanonical
in classABlob
- Returns:
- Canonical version of Cell
-