Package convex.core.crypto
Class Ed25519Signature
- All Implemented Interfaces:
IValidated
,IWriteable
,Comparable<ABlobLike<?>>
Immutable data value class representing an Ed25519 digital signature.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Length in bytes of an Ed25519 signaturestatic final Ed25519Signature
A Signature containing zero bytes (not valid)Fields inherited from class convex.core.data.AArrayBlob
contentHash, offset, store
Fields inherited from class convex.core.data.ACell
cachedRef, memorySize
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Estimate the encoded data size for this Cell.getChunk
(long i) Gets a chunk of this Blob, as a canonical flat Blob up to the maximum Blob chunk size.boolean
Returns true if this Cell is in a canonical representation.static Ed25519Signature
read
(ByteBuffer bb) Read a signature from a ByteBuffer.static ASignature
static Ed25519Signature
readRaw
(ByteBuffer bb) Read signature raw data from a ByteBuffer.Converts this Cell to a canonical version.toCVMString
(long limit) Returns the CVM String representation of this Cell.void
Validates the local structure and invariants of this cell.boolean
verify
(AArrayBlob message, AccountKey publicKey) Checks if the signature is valid for a given message hashstatic Ed25519Signature
wrap
(byte[] signature) Creates a Signature instance with specific bytesstatic Ed25519Signature
wrap
(byte[] data, int pos) Creates a Signature instance with specific bytesMethods inherited from class convex.core.crypto.ASignature
equals, fromBlob, fromHex, isEmbedded
Methods inherited from class convex.core.data.AArrayBlob
append, appendHex, appendSmall, byteAt, byteAtUnchecked, calcMemorySize, compareTo, compareTo, encodeRaw, 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, createRef, equals, genericEquals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getMemorySize, getRef, toString
Methods inherited from class convex.core.data.AObject
attachEncoding, print, print
-
Field Details
-
SIGNATURE_LENGTH
public static final int SIGNATURE_LENGTHLength in bytes of an Ed25519 signature- See Also:
-
ZERO
A Signature containing zero bytes (not valid)
-
-
Constructor Details
-
Ed25519Signature
public Ed25519Signature(byte[] data, int pos)
-
-
Method Details
-
wrap
Creates a Signature instance with specific bytes- Parameters:
signature
- Bytes for signature- Returns:
- Signature instance
-
wrap
Creates a Signature instance with specific bytes- Parameters:
data
- 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. 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
-
read
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
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
-
toCVMString
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. SHOULD return null in O(1) time if the length of the CVM String can be proved to exceed the limit. MUST complete in O(limit) time and space otherwise The String representation is intended to be a easy-to-read textual representation of the Cell's data content.- Overrides:
toCVMString
in classACell
- Parameters:
limit
- Limit of CVM String length in UTF-8 bytes- Returns:
- CVM String, or null if limit exceeded
-
verify
Description copied from class:ASignature
Checks if the signature is valid for a given message hash- Specified by:
verify
in classASignature
- Parameters:
message
- Message to verifypublicKey
- Public key of signer- Returns:
- True if signature is valid, false otherwise
-
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
-
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.
-
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
-