Skip to content

PDPAuthHelper

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

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:50

ParameterType
serviceContractAddressstring
signerSigner
chainIdbigint

PDPAuthHelper

readonly WITH_CDN_METADATA: MetadataEntry;

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

getSignerAddress(): Promise<string>;

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

Get the address of the signer

Promise<string>

Promise resolving to the signer’s Ethereum address


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

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

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
clientDataSetIdbigintundefinedClient’s dataset ID (same as used in createDataSet)
noncebigintundefinedRandom nonce for replay protection
pieceDataArraystring[] | 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 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(
clientDataSetId,
payee,
metadata): Promise<AuthSignature>;

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

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
clientDataSetIdbigintundefinedUnique dataset ID for the client (typically starts at 0 and increments)
payeestringundefinedService provider’s address that will receive payments
metadataMetadataEntry[][]Service parameters as key-value pairs

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
PDPAuthHelper.WITH_CDN_METADATA // Enable CDN service
)

signDeleteDataSet(clientDataSetId): Promise<AuthSignature>;

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

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
clientDataSetIdbigintClient’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:396

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
clientDataSetIdbigintClient’s dataset ID
pieceIdsbigint[]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
)