PHP code example of symbiotic / btc-puzzle

1. Go to this page and download the library: Download symbiotic/btc-puzzle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

symbiotic / btc-puzzle example snippets


$config = new \Symbiotic\BtcPuzzle\Config(
    [
        // your secret phrase for generating signatures
        'secret' => 'efjiej34f9349gj4309hg4349tfh3044f3',
        // authorization token for generating a range signature
        'token' => 'Aich45vbdghbds'
    ]
);

$controller = new \Symbiotic\BtcPuzzle\SignatureController($config, $_GET);

echo $controller->dispatch();

Example:

// Verification address generator
$generator = new \Symbiotic\BtcPuzzle\SignatureGenerator($config->getToken(), $config->getSecret()); 

// Puzzle Range 
$sector = new \Symbiotic\BtcPuzzle\Sector($puzzleId, $sectorNumber);

// Create a verification address for the user
$address = $generator->generateSectorAddress($token, $sector, $user_id);

// hash of the sector for subsequent authentication of the issuance by the user's server
$sectorHash = $generator->getSectorHash($puzzleId, $sectorNumber);

$signature = $generator->generateSectorSignature($token, $sector, $user_id);

echo json_encode([
    'sectorHash' => $signature['sectorHash'],
    'userSectorHash' => $signature['userSectorHash']
    'signatureBlowfish' => $signature['signatureBlowfish']
    'address' => $signature['address']/*we give only the address without the private key*/
 ]);