Class: Key

api. Key

Key represents a cryptographic key. It can be symmetric or asymmetric. In the case of an asymmetric key, the key can be public or private. In the case of a private asymmetric key, the getPublicKey() method allows to retrieve the corresponding public-key. A key can be referenced via the Subject Key Identifier (SKI) and resolvable by the appropriate CryptoSuite implementation

new Key()

Methods


getPublicKey()

Returns the corresponding public key if this key is an asymmetric private key. If this key is already public, returns this key itself.
Returns:
the corresponding public key if this key is an asymmetric private key. If this key is already public, returns this key itself.
Type
module:api.Key

getSKI()

Returns the subject key identifier of this key
Returns:
The subject key identifier of this key as a hexidecial encoded string
Type
string

isPrivate()

Returns true if this key is an asymmetric private key, false otherwise.
Returns:
if this key is an asymmetric private key
Type
boolean

isSymmetric()

Returns true if this key is a symmetric key, false is this key is asymmetric
Returns:
if this key is a symmetric key
Type
boolean

toBytes()

Converts this key to its PEM representation, if this operation is allowed.
Returns:
the PEM string representation of the key
Type
string