# Class: PublicSubkeyPacket

## PublicSubkeyPacket(dateopt, configopt)

A Public-Subkey packet (tag 14) has exactly the same format as a Public-Key packet, but denotes a subkey. One or more subkeys may be associated with a top-level key. By convention, the top-level key provides signature services, and the subkeys provide encryption services.

## Constructor

#### new PublicSubkeyPacket(dateopt, configopt)

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`date` | Date | <optional> | Creation date
`config` | Object | <optional> | Full configuration, defaults to openpgp.config

Source:
  - packet/public_subkey.js, line 39

### Extends

- PublicKeyPacket

### Members

#### algorithm :String

Public key algorithm.

##### Type:

- String

Overrides:
  - PublicKeyPacket#algorithm
Source:
  - packet/public_key.js, line 60

#### created :Date

Key creation date.

##### Type:

- Date

Overrides:
  - PublicKeyPacket#created
Source:
  - packet/public_key.js, line 55

#### expirationTimeV3 :Integer

Time until expiration in days (V3 only)

##### Type:

- Integer

Overrides:
  - PublicKeyPacket#expirationTimeV3
Source:
  - packet/public_key.js, line 70

#### fingerprint :Uint8Array

Fingerprint bytes

##### Type:

- Uint8Array

Overrides:
  - PublicKeyPacket#fingerprint
Source:
  - packet/public_key.js, line 75

#### keyID :module:type/keyid~KeyID

KeyID

##### Type:

- module:type/keyid~KeyID

Overrides:
  - PublicKeyPacket#keyID
Source:
  - packet/public_key.js, line 80

#### publicParams :Object

Algorithm specific public params

##### Type:

- Object

Overrides:
  - PublicKeyPacket#publicParams
Source:
  - packet/public_key.js, line 65

#### readPublicKey

Alias of read()

Overrides:
  - PublicKeyPacket#readPublicKey
Source:
  - packet/public_key.js, line 280
See:
  - PublicKeyPacket#read

#### version :Integer

Packet version

##### Type:

- Integer

Overrides:
  - PublicKeyPacket#version
Source:
  - packet/public_key.js, line 50

#### writePublicKey

Alias of write()

Overrides:
  - PublicKeyPacket#writePublicKey
Source:
  - packet/public_key.js, line 286
See:
  - PublicKeyPacket#write

### Methods

#### (static) fromSecretSubkeyPacket(secretSubkeyPacket) → {SecretSubkeyPacket}

Create a PublicSubkeyPacket from a SecretSubkeyPacket

##### Parameters:

Name | Type | Description
--- | --- | ---
`secretSubkeyPacket` | SecretSubkeyPacket | subkey packet to convert

Source:
  - packet/public_subkey.js, line 49

##### Returns:

public key packet

Type
  SecretSubkeyPacket

#### (async) computeFingerprint()

Computes and set the fingerprint of the key

Overrides:
  - PublicKeyPacket#computeFingerprint
Source:
  - packet/public_key.js, line 222

#### (async) computeFingerprintAndKeyID()

Computes and set the key ID and fingerprint of the key

Overrides:
  - PublicKeyPacket#computeFingerprintAndKeyID
Source:
  - packet/public_key.js, line 206

#### getAlgorithmInfo() → {Object}

Returns algorithm information

Overrides:
  - PublicKeyPacket#getAlgorithmInfo
Source:
  - packet/public_key.js, line 262

##### Returns:

An object of the form {algorithm: String, bits:int, curve:String}.

Type
  Object

#### getCreationTime() → {Date}

Returns the creation time of the key

Overrides:
  - PublicKeyPacket#getCreationTime
Source:
  - packet/public_key.js, line 190

##### Returns:

Type
  Date

#### getFingerprint() → {String}

Calculates and returns the fingerprint of the key, as a string

Overrides:
  - PublicKeyPacket#getFingerprint
Source:
  - packet/public_key.js, line 246

##### Returns:

A string containing the fingerprint in lowercase hex

Type
  String

#### getFingerprintBytes() → {Uint8Array}

Returns the fingerprint of the key, as an array of bytes

Overrides:
  - PublicKeyPacket#getFingerprintBytes
Source:
  - packet/public_key.js, line 238

##### Returns:

A Uint8Array containing the fingerprint

Type
  Uint8Array

#### getKeyID() → {module:type/keyid~KeyID}

Return the key ID of the key

Overrides:
  - PublicKeyPacket#getKeyID
Source:
  - packet/public_key.js, line 198

##### Returns:

The 8-byte key ID

Type
  module:type/keyid~KeyID

#### hasSameFingerprintAs() → {Boolean}

Calculates whether two keys have the same fingerprint without actually calculating the fingerprint

Overrides:
  - PublicKeyPacket#hasSameFingerprintAs
Source:
  - packet/public_key.js, line 254

##### Returns:

Whether the two keys have the same version and public key data.

Type
  Boolean

#### isDecrypted() → {Boolean|null}

Check whether secret-key data is available in decrypted form. Returns null for public keys.

Overrides:
  - PublicKeyPacket#isDecrypted
Source:
  - packet/public_key.js, line 182

##### Returns:

Type
  Boolean | null

#### (async) read(bytes) → {Object}

Internal Parser for public keys as specified in RFC 4880 section 5.5.2 Public-Key Packet Formats

##### Parameters:

Name | Type | Description
--- | --- | ---
`bytes` | Uint8Array | Input array to read the packet from

Overrides:
  - PublicKeyPacket#read
Source:
  - packet/public_key.js, line 107

##### Returns:

This object with attributes set by the parser

Type
  Object

#### write() → {Uint8Array}

Creates an OpenPGP public key packet for the given key.

Overrides:
  - PublicKeyPacket#write
Source:
  - packet/public_key.js, line 146

##### Returns:

Bytes encoding the public key OpenPGP packet.

Type
  Uint8Array

#### writeForHash(version)

Write packet in order to be hashed; either for a signature or a fingerprint

##### Parameters:

Name | Type | Description
--- | --- | ---
`version` | Integer | target version of signature or key

Overrides:
  - PublicKeyPacket#writeForHash
Source:
  - packet/public_key.js, line 169