Package convex.core.data
Class AccountKey
- All Implemented Interfaces:
IValidated
,IWriteable
,Comparable<ABlobLike<?>>
Immutable class representing an Ed25519 Public Key for an Account
Using Ed25519:
- AccountKey is the Public Key (32 bytes)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final AccountKey
A null Account KeyFields inherited from class convex.core.data.AArrayBlob
contentHash, offset, store
Fields inherited from class convex.core.data.ACell
cachedRef, memorySize
-
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.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
static AccountKey
fromHexOrNull
(String hexString) Constructs an AccountKey object from a hex stringgetChunk
(long i) Gets a chunk of this Blob, as a canonical flat Blob up to the maximum Blob chunk size.int
Method to calculate the encoding length of a Cell.boolean
Returns true if this Cell is in a canonical representation.boolean
Determines if this Cell Represents an embedded object.static AccountKey
Attempts to parse an account key on best efforts basis.static AccountKey
Attempts to parse account key.static AccountKey
static AccountKey
readRaw
(ByteBuffer data) protected Blob
Converts this Cell to a 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, appendHex, appendSmall, byteAt, byteAtUnchecked, compareTo, compareTo, encodeRaw, equals, equalsBytes, equalsBytes, getByteBuffer, getBytes, getContentHash, getHexDigit, getInternalArray, getInternalOffset, getRef, getRefCount, hexMatch, hexMatch, hexMatches, isChunkPacked, isFullyPacked, longAt, longValue, rangeMatches, rangeMatches, read, shortAt, slice, toFlatBlob, updateDigest, updateRefs, validate
Methods inherited from class convex.core.data.ABlob
computeHash, count, empty, encode, equals, get, getElementRef, getTag, getType, hashCode, isCVMValue, print, read, replaceSlice, size, slice, toBlob, toByteBuffer
Methods inherited from class convex.core.data.ABlobLike
getBytes, hexEquals, hexLength, isDataValue, toHexString, toHexString
Methods inherited from class convex.core.data.ACountable
isEmpty
Methods inherited from class convex.core.data.ACell
attachMemorySize, attachRef, cachedEncoding, cachedHash, createEncoding, equals, genericEquals, getCanonical, getChildRefs, getEncoding, getHash, getMemorySize, getMemorySize, getRef, toCVMString, toString
Methods inherited from class convex.core.data.AObject
attachEncoding, print, print
-
Field Details
-
LENGTH
public static final int LENGTH- See Also:
-
LENGTH_BITS
public static final int LENGTH_BITS- See Also:
-
NULL
A null Account Key
-
-
Method Details
-
createRef
-
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
-
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
-
parse
Attempts to parse an account key on best efforts basis.- Parameters:
o
- Any object expected to represent an Account Key- Returns:
- AccountKey instance, or null if not possible to parse
-
parse
Attempts to parse account key. Handles leading/trailing whitespace and optional 0x- Parameters:
s
- String containing account key- Returns:
- AccountKey, or null if not possible to parse
-
fromHexOrNull
Constructs an AccountKey object from a hex string- Parameters:
hexString
- Hex String- Returns:
- An AccountKey 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 AccountKey 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
-
readRaw
-
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.
-
getEncodingLength
public int 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 flat Blob up to the maximum Blob 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. Assumes not already calculated Requires any child Refs to be either direct or of persisted in store at minimum, or you might get a MissingDataException- Overrides:
calcMemorySize
in classAArrayBlob
- Returns:
- Memory Size of this Cell
-
isCanonical
public boolean isCanonical()Description copied from class:ACell
Returns true if this Cell is in a canonical representation. Non-canonical objects may be used on a temporary internal basis, they should be converted to canonical representations for general purpose use.- 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 a canonical version. Must return this Cell if already canonical, may be O(n) in size of value otherwise. Callers should usually use getCanonical(), which caches canonical instances once created- Specified by:
toCanonical
in classABlob
- Returns:
- Canonical version of Cell
-