# PDPAuthHelper

Defined in: [packages/synapse-sdk/src/pdp/auth.ts:45](https://github.com/FilOzone/synapse-sdk/blob/1d6c4b9fe34534bf1087dfe41491b72be0b46858/packages/synapse-sdk/src/pdp/auth.ts#L45)

Helper class for creating EIP-712 typed signatures for PDP operations

This class provides methods to create cryptographic signatures required for
authenticating PDP (Proof of Data Possession) operations with service providers.
All signatures are EIP-712 compatible for improved security and UX.

Can be used standalone or through the Synapse SDK.

## Example

```typescript
// Direct instantiation with ethers signer
import { PDPAuthHelper } from '@filoz/synapse-sdk'
import { ethers } from 'ethers'

const wallet = new ethers.Wallet(privateKey, provider)
const auth = new PDPAuthHelper(contractAddress, wallet, BigInt(chainId))

// Or get from Synapse instance (convenience method)
const synapse = await Synapse.create({ privateKey, rpcURL })
const auth = synapse.getPDPAuthHelper()

// Sign operations for PDP service authentication
const createSig = await auth.signCreateDataSet(0, providerAddress, false)
const addPiecesSig = await auth.signAddPieces(0, 1, pieceDataArray)
```

## Constructors

### Constructor

```ts
new PDPAuthHelper(
   serviceContractAddress, 
   signer, 
   chainId): PDPAuthHelper;
```

Defined in: [packages/synapse-sdk/src/pdp/auth.ts:50](https://github.com/FilOzone/synapse-sdk/blob/1d6c4b9fe34534bf1087dfe41491b72be0b46858/packages/synapse-sdk/src/pdp/auth.ts#L50)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `serviceContractAddress` | `string` |
| `signer` | `Signer` |
| `chainId` | `bigint` |

#### Returns

`PDPAuthHelper`

## Properties

### WITH\_CDN\_METADATA

```ts
readonly WITH_CDN_METADATA: MetadataEntry;
```

Defined in: [packages/synapse-sdk/src/pdp/auth.ts:48](https://github.com/FilOzone/synapse-sdk/blob/1d6c4b9fe34534bf1087dfe41491b72be0b46858/packages/synapse-sdk/src/pdp/auth.ts#L48)

## Methods

### getSignerAddress()

```ts
getSignerAddress(): Promise<string>;
```

Defined in: [packages/synapse-sdk/src/pdp/auth.ts:503](https://github.com/FilOzone/synapse-sdk/blob/1d6c4b9fe34534bf1087dfe41491b72be0b46858/packages/synapse-sdk/src/pdp/auth.ts#L503)

Get the address of the signer

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<`string`\>

Promise resolving to the signer's Ethereum address

***

### signAddPieces()

```ts
signAddPieces(
   clientDataSetId, 
   nonce, 
   pieceDataArray, 
metadata): Promise<AuthSignature>;
```

Defined in: [packages/synapse-sdk/src/pdp/auth.ts:285](https://github.com/FilOzone/synapse-sdk/blob/1d6c4b9fe34534bf1087dfe41491b72be0b46858/packages/synapse-sdk/src/pdp/auth.ts#L285)

Create signature for adding pieces to a data set

This signature authorizes a service provider to add new data pieces
to an existing data set. Each piece represents aggregated data that
will be proven using PDP challenges.

#### Parameters

| Parameter | Type | Default value | Description |
| ------ | ------ | ------ | ------ |
| `clientDataSetId` | `bigint` | `undefined` | Client's dataset ID (same as used in createDataSet) |
| `nonce` | `bigint` | `undefined` | Random nonce for replay protection |
| `pieceDataArray` | `string`[] \| `PieceLink`[] | `undefined` | Array of piece data containing PieceCID CIDs and raw sizes |
| `metadata` | [`MetadataEntry`](/reference/filoz/synapse-sdk/synapse/type-aliases/metadataentry/)[][] | `[]` | - |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`AuthSignature`](/reference/filoz/synapse-sdk/synapse/interfaces/authsignature/)\>

Promise resolving to authentication signature for adding pieces

#### Example

```typescript
const auth = new PDPAuthHelper(contractAddress, signer, chainId)
const pieceData = [{
  cid: 'bafkzcibc...', // PieceCID of aggregated data
  rawSize: Number(SIZE_CONSTANTS.MiB)     // Raw size in bytes before padding
}]
const nonce = randU256() // Generate random nonce
const signature = await auth.signAddPieces(
  0,           // Same dataset ID as data set creation
  nonce,       // Random nonce for replay protection
  pieceData    // Array of pieces to add
)
```

***

### signCreateDataSet()

```ts
signCreateDataSet(
   clientDataSetId, 
   payee, 
metadata): Promise<AuthSignature>;
```

Defined in: [packages/synapse-sdk/src/pdp/auth.ts:206](https://github.com/FilOzone/synapse-sdk/blob/1d6c4b9fe34534bf1087dfe41491b72be0b46858/packages/synapse-sdk/src/pdp/auth.ts#L206)

Create signature for data set creation

This signature authorizes a service provider to create a new data set
on behalf of the client. The signature includes the client's dataset ID,
the service provider's payment address, and CDN preference.

#### Parameters

| Parameter | Type | Default value | Description |
| ------ | ------ | ------ | ------ |
| `clientDataSetId` | `bigint` | `undefined` | Unique dataset ID for the client (typically starts at 0 and increments) |
| `payee` | `string` | `undefined` | Service provider's address that will receive payments |
| `metadata` | [`MetadataEntry`](/reference/filoz/synapse-sdk/synapse/type-aliases/metadataentry/)[] | `[]` | Service parameters as key-value pairs |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`AuthSignature`](/reference/filoz/synapse-sdk/synapse/interfaces/authsignature/)\>

Promise resolving to authentication signature for data set creation

#### Example

```typescript
const auth = new PDPAuthHelper(contractAddress, signer, chainId)
const signature = await auth.signCreateDataSet(
  0,                                // First dataset for this client
  '0x1234...abcd',                  // Service provider address
  PDPAuthHelper.WITH_CDN_METADATA   // Enable CDN service
)
```

***

### signDeleteDataSet()

```ts
signDeleteDataSet(clientDataSetId): Promise<AuthSignature>;
```

Defined in: [packages/synapse-sdk/src/pdp/auth.ts:459](https://github.com/FilOzone/synapse-sdk/blob/1d6c4b9fe34534bf1087dfe41491b72be0b46858/packages/synapse-sdk/src/pdp/auth.ts#L459)

Create signature for data set deletion

This signature authorizes complete deletion of a data set and all
its associated data. This action is irreversible and will terminate
the storage service for this dataset.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `clientDataSetId` | `bigint` | Client's dataset ID to delete |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`AuthSignature`](/reference/filoz/synapse-sdk/synapse/interfaces/authsignature/)\>

Promise resolving to authentication signature for data set deletion

#### Example

```typescript
const auth = new PDPAuthHelper(contractAddress, signer, chainId)
const signature = await auth.signDeleteDataSet(
  0  // Dataset ID to delete
)
```

***

### signSchedulePieceRemovals()

```ts
signSchedulePieceRemovals(clientDataSetId, pieceIds): Promise<AuthSignature>;
```

Defined in: [packages/synapse-sdk/src/pdp/auth.ts:396](https://github.com/FilOzone/synapse-sdk/blob/1d6c4b9fe34534bf1087dfe41491b72be0b46858/packages/synapse-sdk/src/pdp/auth.ts#L396)

Create signature for scheduling piece removals

This signature authorizes a service provider to schedule specific pieces
for removal from the data set. Pieces are typically removed after the
next successful proof submission.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `clientDataSetId` | `bigint` | Client's dataset ID |
| `pieceIds` | `bigint`[] | Array of piece IDs to schedule for removal |

#### Returns

[`Promise`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[`AuthSignature`](/reference/filoz/synapse-sdk/synapse/interfaces/authsignature/)\>

Promise resolving to authentication signature for scheduling removals

#### Example

```typescript
const auth = new PDPAuthHelper(contractAddress, signer, chainId)
const signature = await auth.signSchedulePieceRemovals(
  0,           // Dataset ID
  [1, 2, 3]    // Piece IDs to remove
)
```