pps-php

Installation

Requirements

Requirement Version
PHP 8.1+
ext-sodium required
ext-gmp required
ext-hash required
ext-json required

Composer

composer require pps-protocol/pps-php

From Source

git clone https://github.com/pps-protocol/pps-php.git
cd pps-php
composer install

Verify Installation

<?php

require_once 'vendor/autoload.php';

$check = \Pps\PulseProof::checkRequirements();

if ($check['ok']) {
    echo "PPS-PHP is ready.\n";
} else {
    echo "Missing requirements: " . implode(', ', $check['missing']) . "\n";
}

Debian/Ubuntu

sudo apt install php8.1-sodium php8.1-gmp

macOS

brew install php libsodium gmp

---

## docs/quick-start.md

```markdown
# Quick Start

## 1. Registration

```php
use Pps\Client\RegistrationBuilder;
use Pps\Server\RegistrationHandler;
use Pps\Storage\InMemoryStorage;

$storage = new InMemoryStorage();
$handler = new RegistrationHandler($storage);
$challenge = $handler->createChallenge('example.com');

$builder = new RegistrationBuilder();
$registration = $builder
    ->rpId('example.com')
    ->nonce($challenge->nonceB64u)
    ->userHandle('user-123')
    ->withDuress(true)
    ->build();

$result = $handler->verify($registration['token'], 'example.com', $challenge->nonceB64u);

2. Authentication

use Pps\Client\AuthenticatorClient;
use Pps\Server\AuthenticationHandler;
use Pps\Server\ChallengeGenerator;

$challengeGen = new ChallengeGenerator();
$challenge = $challengeGen->create('example.com');

$client = new AuthenticatorClient($clientState);
$pulse = $client
    ->rpId('example.com')
    ->nonce($challenge->nonceB64u)
    ->createPulse();

$handler = new AuthenticationHandler($storage);
$result = $handler->verify($pulse['token'], 'example.com', $challenge->nonceB64u);

3. Transaction Signing

use Pps\Payload\TransactionObject;
use Pps\Payload\ContextObject;

$transaction = new TransactionObject(
    action: 'withdraw',
    amountMinor: 2500067,
    currency: 'IRR',
    recipient: 'IR820540102680020817909002'
);

$context = new ContextObject();
$context->txHash = $transaction->hash();

$pulse = $client
    ->rpId('example.com')
    ->nonce($nonce)
    ->context($context)
    ->amountMinor(2500067)
    ->createPulse();