> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cdp.coinbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# KeyParser

> Parses private keys from various formats.

Package: [`com.coinbase.cdp.auth`](/sdks/cdp-sdks-v2/java/com/coinbase/cdp/auth/index)

```java theme={null}
public final class KeyParser extends Object
```

Parses private keys from various formats.

Supports:

* PEM-encoded EC keys (ES256)
* Base64-encoded Ed25519 keys (64 bytes: 32-byte seed + 32-byte public key)
* Base64-encoded PKCS#8 DER keys (for wallet secrets)

## Method Details

### `parsePrivateKey`

```java theme={null}
public static PrivateKey parsePrivateKey(String keyData)
```

Parses a private key from PEM (EC) or base64 (Ed25519) format.

**Parameters:**

`keyData` (`String`) - the key data (PEM string or base64 encoded)

**Returns:**

`PrivateKey` - the parsed private key

**Throws:**

`[KeyParseException](/sdks/cdp-sdks-v2/java/com/coinbase/cdp/auth/exceptions/KeyParseException "class in com.coinbase.cdp.auth.exceptions")` - if parsing fails

### `parseWalletKey`

```java theme={null}
public static PrivateKey parseWalletKey(String walletSecret)
```

Parses a wallet secret (base64 DER-encoded EC key).

**Parameters:**

`walletSecret` (`String`) - the base64-encoded PKCS#8 DER key

**Returns:**

`PrivateKey` - the parsed private key

**Throws:**

`[KeyParseException](/sdks/cdp-sdks-v2/java/com/coinbase/cdp/auth/exceptions/KeyParseException "class in com.coinbase.cdp.auth.exceptions")` - if parsing fails

### `isEcKey`

```java theme={null}
public static boolean isEcKey(PrivateKey key)
```

Determines if a key is an EC key (ES256).

**Parameters:**

`key` (`PrivateKey`) - the private key

**Returns:**

`boolean` - true if the key uses EC algorithm

### `isEd25519Key`

```java theme={null}
public static boolean isEd25519Key(PrivateKey key)
```

Determines if a key is an Ed25519 key (EdDSA).

**Parameters:**

`key` (`PrivateKey`) - the private key

**Returns:**

`boolean` - true if the key uses Ed25519/EdDSA algorithm
