Skip to content

PDPAuthHelper

Defined in: packages/synapse-sdk/src/pdp/auth.ts:73

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.

// 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)
new PDPAuthHelper(
serviceContractAddress,
signer,
chainId): PDPAuthHelper;

Defined in: packages/synapse-sdk/src/pdp/auth.ts:78

ParameterType
serviceContractAddressstring
signerSigner
chainIdbigint

PDPAuthHelper

readonly WITH_CDN_METADATA: MetadataEntry;

Defined in: packages/synapse-sdk/src/pdp/auth.ts:76

getSignerAddress(): Promise<string>;

Defined in: packages/synapse-sdk/src/pdp/auth.ts:551

Get the address of the signer

Promise<string>

Promise resolving to the signer’s Ethereum address


signAddPieces(
clientDataSetId,
firstPieceId,
pieceDataArray,
metadata): Promise<AuthSignature>;

Defined in: packages/synapse-sdk/src/pdp/auth.ts:317

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.

ParameterTypeDefault valueDescription
clientDataSetIdnumber | bigintundefinedClient’s dataset ID (same as used in createDataSet)
firstPieceIdnumber | bigintundefinedID of the first piece being added (sequential numbering)
pieceDataArray| string[] | PieceLink[]undefinedArray of piece data containing PieceCID CIDs and raw sizes
metadataMetadataEntry[][][]-

Promise<AuthSignature>

Promise resolving to authentication signature for adding pieces

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 signature = await auth.signAddPieces(
0, // Same dataset ID as data set creation
1, // First piece has ID 1 (0 reserved)
pieceData // Array of pieces to add
)

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

Defined in: packages/synapse-sdk/src/pdp/auth.ts:239

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.

ParameterTypeDefault valueDescription
clientDataSetIdnumber | bigintundefinedUnique dataset ID for the client (typically starts at 0 and increments)
payeestringundefinedService provider’s address that will receive payments
metadataMetadataEntry[][]-

Promise<AuthSignature>

Promise resolving to authentication signature for data set creation

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

signDeleteDataSet(clientDataSetId): Promise<AuthSignature>;

Defined in: packages/synapse-sdk/src/pdp/auth.ts:503

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.

ParameterTypeDescription
clientDataSetIdnumber | bigintClient’s dataset ID to delete

Promise<AuthSignature>

Promise resolving to authentication signature for data set deletion

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

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

Defined in: packages/synapse-sdk/src/pdp/auth.ts:428

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.

ParameterTypeDescription
clientDataSetIdnumber | bigintClient’s dataset ID
pieceIds(number | bigint)[]Array of piece IDs to schedule for removal

Promise<AuthSignature>

Promise resolving to authentication signature for scheduling removals

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