# Module: crypto/public_key/elliptic/ecdh

Key encryption and decryption for RFC 6637 ECDH

Source:
  - crypto/public_key/elliptic/ecdh.js, line 18

Source:
  - crypto/public_key/elliptic/ecdh_x.js, line 1

### Methods

#### (async, static) decrypt(oid, kdfParams, V, C, Q, d, fingerprint) → {Promise.<Uint8Array>}

Decrypt and unwrap the value derived from session key

##### Parameters:

Name | Type | Description
--- | --- | ---
`oid` | module:type/oid | Elliptic curve object identifier
`kdfParams` | module:type/kdf_params | KDF params including cipher and algorithm to use
`V` | Uint8Array | Public part of ephemeral key
`C` | Uint8Array | Encrypted and wrapped value derived from session key
`Q` | Uint8Array | Recipient public key
`d` | Uint8Array | Recipient private key
`fingerprint` | Uint8Array | Recipient fingerprint

Source:
  - crypto/public_key/elliptic/ecdh.js, line 194

##### Returns:

Value derived from session key.

Type
  Promise.<Uint8Array>

#### (async, static) decrypt(algo, ephemeralPublicKey, wrappedKey,, A, k) → {Promise.<Uint8Array>}

Decrypt and unwrap the session key

##### Parameters:

Name | Type | Description
--- | --- | ---
`algo` | module:enums.publicKey | Algorithm identifier
`ephemeralPublicKey` | Uint8Array | (K_A)
`wrappedKey,` | Uint8Array |
`A` | Uint8Array | Recipient public key (K_b), needed for KDF
`k` | Uint8Array | Recipient secret key (b)

Source:
  - crypto/public_key/elliptic/ecdh_x.js, line 139

##### Returns:

decrypted session key data

Type
  Promise.<Uint8Array>

#### (async, static) encrypt(oid, kdfParams, data, Q, fingerprint) → {Promise.<{publicKey: Uint8Array, wrappedKey: Uint8Array}>}

Encrypt and wrap a session key

##### Parameters:

Name | Type | Description
--- | --- | ---
`oid` | module:type/oid | Elliptic curve object identifier
`kdfParams` | module:type/kdf_params | KDF params including cipher and algorithm to use
`data` | Uint8Array | Unpadded session key data
`Q` | Uint8Array | Recipient public key
`fingerprint` | Uint8Array | Recipient fingerprint

Source:
  - crypto/public_key/elliptic/ecdh.js, line 130

##### Returns:

Type
  Promise.<{publicKey: Uint8Array, wrappedKey: Uint8Array}>

#### (async, static) encrypt(algo, data, recipientA) → {Promise.<{ephemeralPublicKey: Uint8Array, wrappedKey: Uint8Array}>}

Wrap and encrypt a session key

##### Parameters:

Name | Type | Description
--- | --- | ---
`algo` | module:enums.publicKey | Algorithm identifier
`data` | Uint8Array | session key data to be encrypted
`recipientA` | Uint8Array | Recipient public key (K_B)

Source:
  - crypto/public_key/elliptic/ecdh_x.js, line 89

##### Returns:

ephemeral public key (K_A) and encrypted key

Type
  Promise.<{ephemeralPublicKey: Uint8Array, wrappedKey: Uint8Array}>

#### (static) generate(algo) → {Promise.<{A: Uint8Array, k: Uint8Array}>}

Generate ECDH key for Montgomery curves

##### Parameters:

Name | Type | Description
--- | --- | ---
`algo` | module:enums.publicKey | Algorithm identifier

Source:
  - crypto/public_key/elliptic/ecdh_x.js, line 25

##### Returns:

Type
  Promise.<{A: Uint8Array, k: Uint8Array}>

#### (async, static) validateParams(oid, Q, d) → {Promise.<Boolean>}

Validate ECDH parameters

##### Parameters:

Name | Type | Description
--- | --- | ---
`oid` | module:type/oid | Elliptic curve object identifier
`Q` | Uint8Array | ECDH public point
`d` | Uint8Array | ECDH secret scalar

Source:
  - crypto/public_key/elliptic/ecdh.js, line 45

##### Returns:

Whether params are valid.

Type
  Promise.<Boolean>

#### (async, static) validateParams(algo, A, k) → {Promise.<Boolean>}

Validate ECDH parameters

##### Parameters:

Name | Type | Description
--- | --- | ---
`algo` | module:enums.publicKey | Algorithm identifier
`A` | Uint8Array | ECDH public point
`k` | Uint8Array | ECDH secret scalar

Source:
  - crypto/public_key/elliptic/ecdh_x.js, line 52

##### Returns:

Whether params are valid.

Type
  Promise.<Boolean>

#### (async, inner) genPrivateEphemeralKey(curve, V, Q, d) → {Promise.<{secretKey: Uint8Array, sharedKey: Uint8Array}>}

Generate ECDHE secret from private key and public part of ephemeral key

##### Parameters:

Name | Type | Description
--- | --- | ---
`curve` | CurveWithOID | Elliptic curve object
`V` | Uint8Array | Public part of ephemeral key
`Q` | Uint8Array | Recipient public key
`d` | Uint8Array | Recipient private key

Source:
  - crypto/public_key/elliptic/ecdh.js, line 152

##### Returns:

Type
  Promise.<{secretKey: Uint8Array, sharedKey: Uint8Array}>

#### (async, inner) genPublicEphemeralKey(curve, Q) → {Promise.<{publicKey: Uint8Array, sharedKey: Uint8Array}>}

Generate ECDHE ephemeral key and secret from public key

##### Parameters:

Name | Type | Description
--- | --- | ---
`curve` | CurveWithOID | Elliptic curve object
`Q` | Uint8Array | Recipient public key

Source:
  - crypto/public_key/elliptic/ecdh.js, line 92

##### Returns:

Type
  Promise.<{publicKey: Uint8Array, sharedKey: Uint8Array}>

#### (async, inner) nodePrivateEphemeralKey(curve, V, d) → {Promise.<{secretKey: Uint8Array, sharedKey: Uint8Array}>}

Generate ECDHE secret from private key and public part of ephemeral key using nodeCrypto

##### Parameters:

Name | Type | Description
--- | --- | ---
`curve` | CurveWithOID | Elliptic curve object
`V` | Uint8Array | Public part of ephemeral key
`d` | Uint8Array | Recipient private key

Source:
  - crypto/public_key/elliptic/ecdh.js, line 340

##### Returns:

Type
  Promise.<{secretKey: Uint8Array, sharedKey: Uint8Array}>

#### (async, inner) nodePublicEphemeralKey(curve, Q) → {Promise.<{publicKey: Uint8Array, sharedKey: Uint8Array}>}

Generate ECDHE ephemeral key and secret from public key using nodeCrypto

##### Parameters:

Name | Type | Description
--- | --- | ---
`curve` | CurveWithOID | Elliptic curve object
`Q` | Uint8Array | Recipient public key

Source:
  - crypto/public_key/elliptic/ecdh.js, line 356

##### Returns:

Type
  Promise.<{publicKey: Uint8Array, sharedKey: Uint8Array}>

#### (async, inner) webPrivateEphemeralKey(curve, V, Q, d) → {Promise.<{secretKey: Uint8Array, sharedKey: Uint8Array}>}

Generate ECDHE secret from private key and public part of ephemeral key using webCrypto

##### Parameters:

Name | Type | Description
--- | --- | ---
`curve` | CurveWithOID | Elliptic curve object
`V` | Uint8Array | Public part of ephemeral key
`Q` | Uint8Array | Recipient public key
`d` | Uint8Array | Recipient private key

Source:
  - crypto/public_key/elliptic/ecdh.js, line 240

##### Returns:

Type
  Promise.<{secretKey: Uint8Array, sharedKey: Uint8Array}>

#### (async, inner) webPublicEphemeralKey(curve, Q) → {Promise.<{publicKey: Uint8Array, sharedKey: Uint8Array}>}

Generate ECDHE ephemeral key and secret from public key using webCrypto

##### Parameters:

Name | Type | Description
--- | --- | ---
`curve` | CurveWithOID | Elliptic curve object
`Q` | Uint8Array | Recipient public key

Source:
  - crypto/public_key/elliptic/ecdh.js, line 291

##### Returns:

Type
  Promise.<{publicKey: Uint8Array, sharedKey: Uint8Array}>

Key encryption and decryption for RFC 6637 ECDH

Source:
  - crypto/public_key/elliptic/ecdh.js, line 18

Source:
  - crypto/public_key/elliptic/ecdh_x.js, line 1

### Methods

#### (async, static) decrypt(oid, kdfParams, V, C, Q, d, fingerprint) → {Promise.<Uint8Array>}

Decrypt and unwrap the value derived from session key

##### Parameters:

Name | Type | Description
--- | --- | ---
`oid` | module:type/oid | Elliptic curve object identifier
`kdfParams` | module:type/kdf_params | KDF params including cipher and algorithm to use
`V` | Uint8Array | Public part of ephemeral key
`C` | Uint8Array | Encrypted and wrapped value derived from session key
`Q` | Uint8Array | Recipient public key
`d` | Uint8Array | Recipient private key
`fingerprint` | Uint8Array | Recipient fingerprint

Source:
  - crypto/public_key/elliptic/ecdh.js, line 194

##### Returns:

Value derived from session key.

Type
  Promise.<Uint8Array>

#### (async, static) decrypt(algo, ephemeralPublicKey, wrappedKey,, A, k) → {Promise.<Uint8Array>}

Decrypt and unwrap the session key

##### Parameters:

Name | Type | Description
--- | --- | ---
`algo` | module:enums.publicKey | Algorithm identifier
`ephemeralPublicKey` | Uint8Array | (K_A)
`wrappedKey,` | Uint8Array |
`A` | Uint8Array | Recipient public key (K_b), needed for KDF
`k` | Uint8Array | Recipient secret key (b)

Source:
  - crypto/public_key/elliptic/ecdh_x.js, line 139

##### Returns:

decrypted session key data

Type
  Promise.<Uint8Array>

#### (async, static) encrypt(oid, kdfParams, data, Q, fingerprint) → {Promise.<{publicKey: Uint8Array, wrappedKey: Uint8Array}>}

Encrypt and wrap a session key

##### Parameters:

Name | Type | Description
--- | --- | ---
`oid` | module:type/oid | Elliptic curve object identifier
`kdfParams` | module:type/kdf_params | KDF params including cipher and algorithm to use
`data` | Uint8Array | Unpadded session key data
`Q` | Uint8Array | Recipient public key
`fingerprint` | Uint8Array | Recipient fingerprint

Source:
  - crypto/public_key/elliptic/ecdh.js, line 130

##### Returns:

Type
  Promise.<{publicKey: Uint8Array, wrappedKey: Uint8Array}>

#### (async, static) encrypt(algo, data, recipientA) → {Promise.<{ephemeralPublicKey: Uint8Array, wrappedKey: Uint8Array}>}

Wrap and encrypt a session key

##### Parameters:

Name | Type | Description
--- | --- | ---
`algo` | module:enums.publicKey | Algorithm identifier
`data` | Uint8Array | session key data to be encrypted
`recipientA` | Uint8Array | Recipient public key (K_B)

Source:
  - crypto/public_key/elliptic/ecdh_x.js, line 89

##### Returns:

ephemeral public key (K_A) and encrypted key

Type
  Promise.<{ephemeralPublicKey: Uint8Array, wrappedKey: Uint8Array}>

#### (static) generate(algo) → {Promise.<{A: Uint8Array, k: Uint8Array}>}

Generate ECDH key for Montgomery curves

##### Parameters:

Name | Type | Description
--- | --- | ---
`algo` | module:enums.publicKey | Algorithm identifier

Source:
  - crypto/public_key/elliptic/ecdh_x.js, line 25

##### Returns:

Type
  Promise.<{A: Uint8Array, k: Uint8Array}>

#### (async, static) validateParams(oid, Q, d) → {Promise.<Boolean>}

Validate ECDH parameters

##### Parameters:

Name | Type | Description
--- | --- | ---
`oid` | module:type/oid | Elliptic curve object identifier
`Q` | Uint8Array | ECDH public point
`d` | Uint8Array | ECDH secret scalar

Source:
  - crypto/public_key/elliptic/ecdh.js, line 45

##### Returns:

Whether params are valid.

Type
  Promise.<Boolean>

#### (async, static) validateParams(algo, A, k) → {Promise.<Boolean>}

Validate ECDH parameters

##### Parameters:

Name | Type | Description
--- | --- | ---
`algo` | module:enums.publicKey | Algorithm identifier
`A` | Uint8Array | ECDH public point
`k` | Uint8Array | ECDH secret scalar

Source:
  - crypto/public_key/elliptic/ecdh_x.js, line 52

##### Returns:

Whether params are valid.

Type
  Promise.<Boolean>

#### (async, inner) genPrivateEphemeralKey(curve, V, Q, d) → {Promise.<{secretKey: Uint8Array, sharedKey: Uint8Array}>}

Generate ECDHE secret from private key and public part of ephemeral key

##### Parameters:

Name | Type | Description
--- | --- | ---
`curve` | CurveWithOID | Elliptic curve object
`V` | Uint8Array | Public part of ephemeral key
`Q` | Uint8Array | Recipient public key
`d` | Uint8Array | Recipient private key

Source:
  - crypto/public_key/elliptic/ecdh.js, line 152

##### Returns:

Type
  Promise.<{secretKey: Uint8Array, sharedKey: Uint8Array}>

#### (async, inner) genPublicEphemeralKey(curve, Q) → {Promise.<{publicKey: Uint8Array, sharedKey: Uint8Array}>}

Generate ECDHE ephemeral key and secret from public key

##### Parameters:

Name | Type | Description
--- | --- | ---
`curve` | CurveWithOID | Elliptic curve object
`Q` | Uint8Array | Recipient public key

Source:
  - crypto/public_key/elliptic/ecdh.js, line 92

##### Returns:

Type
  Promise.<{publicKey: Uint8Array, sharedKey: Uint8Array}>

#### (async, inner) nodePrivateEphemeralKey(curve, V, d) → {Promise.<{secretKey: Uint8Array, sharedKey: Uint8Array}>}

Generate ECDHE secret from private key and public part of ephemeral key using nodeCrypto

##### Parameters:

Name | Type | Description
--- | --- | ---
`curve` | CurveWithOID | Elliptic curve object
`V` | Uint8Array | Public part of ephemeral key
`d` | Uint8Array | Recipient private key

Source:
  - crypto/public_key/elliptic/ecdh.js, line 340

##### Returns:

Type
  Promise.<{secretKey: Uint8Array, sharedKey: Uint8Array}>

#### (async, inner) nodePublicEphemeralKey(curve, Q) → {Promise.<{publicKey: Uint8Array, sharedKey: Uint8Array}>}

Generate ECDHE ephemeral key and secret from public key using nodeCrypto

##### Parameters:

Name | Type | Description
--- | --- | ---
`curve` | CurveWithOID | Elliptic curve object
`Q` | Uint8Array | Recipient public key

Source:
  - crypto/public_key/elliptic/ecdh.js, line 356

##### Returns:

Type
  Promise.<{publicKey: Uint8Array, sharedKey: Uint8Array}>

#### (async, inner) webPrivateEphemeralKey(curve, V, Q, d) → {Promise.<{secretKey: Uint8Array, sharedKey: Uint8Array}>}

Generate ECDHE secret from private key and public part of ephemeral key using webCrypto

##### Parameters:

Name | Type | Description
--- | --- | ---
`curve` | CurveWithOID | Elliptic curve object
`V` | Uint8Array | Public part of ephemeral key
`Q` | Uint8Array | Recipient public key
`d` | Uint8Array | Recipient private key

Source:
  - crypto/public_key/elliptic/ecdh.js, line 240

##### Returns:

Type
  Promise.<{secretKey: Uint8Array, sharedKey: Uint8Array}>

#### (async, inner) webPublicEphemeralKey(curve, Q) → {Promise.<{publicKey: Uint8Array, sharedKey: Uint8Array}>}

Generate ECDHE ephemeral key and secret from public key using webCrypto

##### Parameters:

Name | Type | Description
--- | --- | ---
`curve` | CurveWithOID | Elliptic curve object
`Q` | Uint8Array | Recipient public key

Source:
  - crypto/public_key/elliptic/ecdh.js, line 291

##### Returns:

Type
  Promise.<{publicKey: Uint8Array, sharedKey: Uint8Array}>