CkPublicKey class final
Load, inspect, convert, export, and use public-key material.
PublicKey represents one public key at a time and provides loading,
inspection, and format-conversion operations. It can load keys from many
common formats,
including DER, PEM, XML, JWK, Base64 DER, RFC 4716 SSH2 blocks, raw ECDSA
coordinates, and Ed25519 hex, then export them as DER, PEM, encoded DER,
JWK, XML, or files. Public
keys are commonly used for signature verification, encryption, JWT/JWS
validation, SSH-related workflows, and interoperability with certificates,
private keys, and external cryptographic systems.
Load public keys
Import public keys from PEM, DER, XML, JWK, Base64 DER, RFC 4716 SSH2 blocks, raw ECDSA coordinates, or Ed25519 hex.
Export and convert
Convert public keys to DER, PEM, encoded DER, JWK, XML, or file-based output for use by other systems and APIs.
Work with key types
Represent public keys for RSA, DSA, ECDSA, Ed25519, and related public-key cryptographic workflows.
Verify signatures
Pass public keys to Chilkat classes that verify signatures, JWTs, JWS objects, signed data, or protocol-specific authentication messages.
Encrypt or validate data
Use public-key material for operations where the public half of a key pair is required, such as encryption or verification.
Interoperate with certs and keys
Use Cert to obtain a public key from an X.509 certificate, or
use PrivateKey to obtain the public portion of an encrypted private key.
Common pattern:
Each object holds zero or one key. A successful load replaces the current
key, and every failed load clears it. General loaders can accept supported
unencrypted private-key representations and retain only their public
portion. Direct X.509 certificate input and encrypted private-key input are
not supported. Load certificates with Cert, and load encrypted private
keys with PrivateKey, then obtain the public key from those objects.
For an extended overview, see PublicKey Class Overview.
A CkPublicKey owns a native Chilkat object. It is released automatically when the
Dart object is garbage collected, or immediately by dispose. Use it only from
the isolate that created it.
- Implemented types
Constructors
- CkPublicKey()
-
Creates a new
CkPublicKeyobject.
Properties
- debugLogFilePath ↔ String
-
If set to a file path, this property logs the LastErrorText of each
Chilkat method or property call to the specified file. This logging helps
identify the context and history of Chilkat calls leading up to any crash
or hang, aiding in debugging.
getter/setter pair
- empty → bool
-
Returns
_TRUE_if no public key is currently loaded, and_FALSE_if this object contains a public key. A newly constructedPublicKeyobject is empty.no setter - hashCode → int
-
The hash code for this object.
no setterinherited
- isDisposed → bool
-
Whether dispose has been called on this object.
no setter
- keySize → int
-
Returns the key size in bits. The meaning is algorithm-specific:
no setter
- keyType → String
-
Returns the type of public key currently held by this object.
no setter
- lastErrorHtml → String
-
Provides HTML-formatted information about the last called method or
property. If a method call fails or behaves unexpectedly, check this
property for details. Note that information is available regardless of the
method call's success.
no setter
- lastErrorText → String
-
Provides plain text information about the last called method or property.
If a method call fails or behaves unexpectedly, check this property for
details. Note that information is available regardless of the method
call's success.
no setter
- lastErrorXml → String
-
Provides XML-formatted information about the last called method or
property. If a method call fails or behaves unexpectedly, check this
property for details. Note that information is available regardless of the
method call's success.
no setter
- lastMethodSuccess ↔ bool
-
Indicates the success or failure of the most recent method call:
truemeans success,falsemeans failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- verboseLogging ↔ bool
-
If set to
true, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value isfalse. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.getter/setter pair - version → String
-
Version of the component/library, such as "10.1.0"
no setter
Methods
-
dispose(
) → void - Releases the native object now instead of waiting for garbage collection.
-
getDerBd(
bool preferPkcs1, CkBinData bd) → void -
Writes the public key as binary DER to
bd.preferPkcs1selects the representation using the same RSA, EC, DSA, and Ed25519 rules described forGetDer. -
getEncoded(
bool preferPkcs1, String encoding) → String -
Returns the DER representation selected by
preferPkcs1, encoded as text using the binary encoding named byencoding. The DER-selection rules are the same as forGetDer. -
getJwk(
) → String - Returns the public key as a compact JWK (JSON Web Key). Binary values use Base64url encoding without padding. Repeated calls for the same key produce the same compact member order.
-
getJwkThumbprint(
String hashAlg) → String -
Returns the RFC 7638 JWK thumbprint for this public key. Chilkat
constructs the required canonical JSON object from the public JWK members,
hashes its UTF-8 representation using the algorithm named by
hashAlg, and returns the digest using Base64url encoding without padding. -
getPem(
bool preferPkcs1) → String -
Returns the public key in PEM format.
preferPkcs1selects the underlying DER representation as follows: -
getXml(
) → String - Returns the public key in Chilkat XML format. The exact representation depends on the key type.
-
loadBase64(
String keyStr) → void -
Loads a public key from standard Base64-encoded DER in
keyStr. Whitespace within the Base64 text is permitted. The decoded DER is inspected to determine the key type and structure. For RSA, both PKCS #1RSAPublicKeyand X.509SubjectPublicKeyInfoare recognized. -
loadBd(
CkBinData bd) → void -
Loads a public key from the data in
bd. TheBinDatamay contain binary DER or any textual representation recognized by loadFromString, including PEM, Chilkat XML, JWK, standard Base64 DER, and supported RFC 4716 SSH2 public-key blocks. -
loadEcdsa(
String curveName, String qx, String qy) → void -
Loads an elliptic-curve public key directly from its affine point
coordinates.
curveNamenames the curve,qxis the hexadecimal x-coordinate (Qx), andqyis the hexadecimal y-coordinate (Qy). -
loadEd25519(
String pubKey) → void -
Loads a raw Ed25519 public key from the hexadecimal string in
pubKey.pubKeymust contain exactly 64 hexadecimal characters representing 32 bytes. Uppercase and lowercase hexadecimal are accepted. -
loadFromFile(
String path) → void -
Loads a public key from the local filesystem path specified by
path. Chilkat examines the file contents rather than the filename extension. Supported content includes binary DER, PEM, Chilkat XML, JWK, standard Base64 DER, and RFC 4716 SSH2 public-key blocks for supported RSA and Ed25519 keys. -
loadFromString(
String keyString) → void -
Loads a public key from the string in
keyString. Chilkat examines the content and recognizes these textual representations: -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
saveDerFile(
bool preferPkcs1, String path) → void -
Saves the public key to
pathas binary DER.preferPkcs1selects the representation using the same RSA, EC, and Ed25519 rules described forGetDer. -
savePemFile(
bool preferPkcs1, String path) → void -
Saves the public key to
pathin PEM format.preferPkcs1selects the representation and PEM label using the same rules described for getPem. -
saveXmlFile(
String path) → void -
Saves the public key to the local filesystem path specified by
pathusing exactly the same key-type-specific XML text returned by getXml. No additional BOM or line ending is added. -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited