Package convex.core.crypto
Class Ed25519Signature
java.lang.Object
convex.core.data.AObject
convex.core.data.ACell
convex.core.data.ACountable<CVMLong>
convex.core.data.ABlob
convex.core.data.AArrayBlob
convex.core.crypto.ASignature
convex.core.crypto.Ed25519Signature
- All Implemented Interfaces:
IValidated,IWriteable,Comparable<ABlob>
Immutable data value class representing an Ed25519 digital signature.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intLength in bytes of an Ed25519 signaturestatic final Ed25519SignatureA Signature containing zero bytes (not valid)Fields 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintencode(byte[] bs, int pos) Writes this Cell's encoding to a byte array, including a tag byte which will be written first.intEstimate the encoded data size for this Cell.byte[]getBytes()Gets the raw bytes representing this signature, as a zero based arraygetChunk(long i) Gets a chunk of this Blob, as a canonical Blob up to the maximum chunk size.booleanReturns true if this Cell is in a canonical representation for message writing.final booleanReturns true if this Cell represents a first class CVM Value.static Ed25519Signatureread(ByteBuffer bb) Read a signature from a ByteBuffer.static ASignaturestatic Ed25519SignaturereadRaw(ByteBuffer bb) Read signature raw data from a ByteBuffer.Converts this Cell to its canonical version.toCVMString(long limit) Returns the CVM String representation of this Cell.voidValidates the local structure and invariants of this cell.booleanverify(AArrayBlob message, AccountKey publicKey) Checks if the signature is valid for a given message hashstatic Ed25519Signaturewrap(byte[] signature) Creates a Signature instance with specific bytesstatic Ed25519Signaturewrap(byte[] data, int pos) Creates a Signature instance with specific bytesMethods inherited from class convex.core.crypto.ASignature
equals, fromBlob, fromHex, getTag, isEmbedded, isRegularBlobMethods inherited from class convex.core.data.AArrayBlob
append, appendHex, appendSmall, byteAt, commonHexPrefixLength, compareTo, compareTo, count, encodeRaw, equalsBytes, equalsBytes, getByteBuffer, getBytes, getHexDigit, getInternalArray, getInternalOffset, getRefCount, getUnchecked, hexMatches, hexMatchLength, longAt, longValue, rangeMatches, rangeMatches, shortAt, slice, toExactLong, toFlatBlob, updateDigest, validate, writeToBuffer, writeToBufferMethods inherited from class convex.core.data.ABlob
computeHash, empty, equals, get, getContentHash, getElementRef, getType, hashCode, hexEquals, hexEquals, hexLength, 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, calcMemorySize, createAnnounced, createEncoding, createPersisted, createPersisted, createRef, equals, getCanonical, getChildRefs, getEncoding, getEncodingLength, getHash, getMemorySize, getRef, getRef, isCompletelyEncoded, mark, mark, toString, updateRefs, writeMethods 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:
signature- Bytes for signature- Returns:
- Signature instance
-
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
-
isCVMValue
public final boolean isCVMValue()Description copied from class:ACellReturns true if this Cell represents a first class CVM Value. Sub-structural cells that are not themselves first class values should return false, pretty much everything else should return true. Note: CVM values might not be in a canonical format, e.g. temporary data structures- Overrides:
isCVMValuein classABlob- Returns:
- true if the object is a CVM Value, false otherwise
-
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
-
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
-
toCVMString
Description copied from class:ACellReturns the CVM String representation of this Cell. Normally, this is as printed, but may be different for some types. MUST return null in O(1) time if the length of the CVM String would exceed limit. The String representation is intended to be a easy-to-read textual representation of the Cell's data content.- Overrides:
toCVMStringin 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:ASignatureChecks if the signature is valid for a given message hash- Specified by:
verifyin classASignature- Parameters:
message- Message to verifypublicKey- Public key of signer- Returns:
- True if signature is valid, false otherwise
-
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
-
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.
-
getBytes
public byte[] getBytes()Description copied from class:ASignatureGets the raw bytes representing this signature, as a zero based array- Specified by:
getBytesin classASignature- Returns:
- byte array from this signature
-
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
-