# Secp256k1

WASM implementations of deterministic Secp256k1 primitives.

This provider is opt-in because its embedded libsecp256k1 artifact is larger
than the modules installed by [`Engine.install`](/api/Engine/install).

## Examples

```ts twoslash
// @noErrors
import { Engine } from 'ox'
import { Secp256k1 } from 'ox/wasm'

await Engine.install({ Secp256k1: Secp256k1.engine() })

Secp256k1.getPublicKey({ privateKey: '0x...' })
```

## Functions

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Secp256k1.createKeyPair`](/wasm/crypto/Secp256k1/createKeyPair) | Creates a new secp256k1 ECDSA key pair consisting of a private key and its corresponding public key. |
| [`Secp256k1.engine`](/wasm/crypto/Secp256k1/engine) | Compiles WASM implementations of deterministic [`Secp256k1`](/api/Secp256k1) primitives, without installing them. |
| [`Secp256k1.getPublicKey`](/wasm/crypto/Secp256k1/getPublicKey) | Computes the secp256k1 ECDSA public key from a provided private key. |
| [`Secp256k1.getSharedSecret`](/wasm/crypto/Secp256k1/getSharedSecret) | Computes a shared secret using ECDH (Elliptic Curve Diffie-Hellman) between a private key and a public key. |
| [`Secp256k1.randomPrivateKey`](/wasm/crypto/Secp256k1/randomPrivateKey) | Generates a random ECDSA private key on the secp256k1 curve. |
| [`Secp256k1.recoverAddress`](/wasm/crypto/Secp256k1/recoverAddress) | Recovers the signing address from the signed payload and signature. |
| [`Secp256k1.recoverPublicKey`](/wasm/crypto/Secp256k1/recoverPublicKey) | Recovers the signing public key from the signed payload and signature. |
| [`Secp256k1.sign`](/wasm/crypto/Secp256k1/sign) | Signs the payload with the provided private key. |
| [`Secp256k1.verify`](/wasm/crypto/Secp256k1/verify) | Verifies a payload was signed by the provided address. |

## Errors

| Name                | Description                         |
| ------------------- | ----------------------------------- |
| [`Secp256k1.InvalidInputError`](/wasm/crypto/Secp256k1/errors#secp256k1invalidinputerror) | Thrown when libsecp256k1 rejects a key or recovered signature. |
| [`Secp256k1.MemoryError`](/wasm/crypto/Secp256k1/errors#secp256k1memoryerror) | Thrown when a WASM module cannot grow its memory to the required size. |
