Package convex.core.data
Class 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, storeFields inherited from class convex.core.data.ABlob
contentHashFields inherited from class convex.core.data.ACell
cachedRef, EMPTY_ARRAY -
Method Summary
Modifier and TypeMethodDescriptionprotected longCalculates the Memory Size for this Cell.static AccountKeyCreates an AccountKey from a blob.Creates a new Ref for this Cellstatic AccountKeyCreates a "Dummy" Address that is not a valid public key, and therefore cannot have valid signed transactions.intencode(byte[] bs, int pos) Writes this Cell's encoding to a byte array, including a tag byte which will be written first.booleanequals(AccountKey o) intEstimate the encoded data size for this Cell.static AccountKeyfromChecksumHex(String hexString) Constructs an AccountKey object from a checksummed hex string.static AccountKeyConstructs an AccountKey object from a hex string.static AccountKeystatic AccountKeyfromHexOrNull(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.intMethod to calculate the encoding length of a Cell.booleanReturns true if this Cell is in a canonical representation for message writing.booleanDetermines if this Cell Represents an embedded object.static AccountKeyAttempts to parse an account key on best efforts basis.static AccountKeyAttempts to parse account key.static AccountKeystatic AccountKeyreadRaw(ByteBuffer data) Converts this Cell to its canonical version.Converts this AccountKey to a checksummed hex string.voidValidates the local structure and invariants of this cell.static AccountKeywrap(byte[] data) Wraps the specified bytes as an AccountKey object.static AccountKeywrap(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, commonHexPrefixLength, compareTo, compareTo, count, encodeRaw, equals, equalsBytes, equalsBytes, getByteBuffer, getBytes, getHexDigit, getInternalArray, getInternalOffset, getRefCount, getTag, hexMatches, hexMatchLength, longAt, longValue, rangeMatches, rangeMatches, shortAt, slice, toExactLong, toFlatBlob, updateDigest, validateMethods inherited from class convex.core.data.ABlob
computeHash, empty, equals, get, getContentHash, getElementRef, getType, hashCode, hexEquals, hexEquals, hexLength, isCVMValue, isRegularBlob, print, slice, toByteBuffer, toHexString, toHexStringMethods inherited from class convex.core.data.ACountable
isEmpty, sizeMethods 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, toCVMString, toString, updateRefsMethods 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:
-
-
Method Details
-
createRef
Description copied from class:ACellCreates 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
-
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
-
encode
public int encode(byte[] bs, int pos) Description copied from class:ACellWrites 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:
encodein interfaceIWriteable- Specified by:
encodein 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:IWriteableEstimate 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:ACellMethod to calculate the encoding length of a Cell. May be overridden to avoid creating encodings during memory size calculations. This reduces hashing!- Overrides:
getEncodingLengthin classACell- Returns:
- Exact encoding length of this Cell
-
getChunk
Description copied from class:ABlobGets 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:ACellValidates 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:
validateCellin classAArrayBlob- Throws:
InvalidDataException- If the Cell is invalid
-
isEmbedded
public boolean isEmbedded()Description copied from class:ACellDetermines 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:
isEmbeddedin classACell- Returns:
- true if Cell is embedded, false otherwise
-
calcMemorySize
protected long calcMemorySize()Description copied from class:ACellCalculates 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:
calcMemorySizein classACell- Returns:
- Memory Size of this Cell
-
isCanonical
public boolean isCanonical()Description copied from class:ACellReturns 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:
isCanonicalin classACell- Returns:
- true if the object is in canonical format, false otherwise
-
toCanonical
Description copied from class:ACellConverts this Cell to its canonical version. Must return this Cell if already canonical, may be O(n) in size of value otherwise.- Specified by:
toCanonicalin classABlob- Returns:
- Canonical version of Cell
-