urban d63a4904f9 trxbot há 10 meses atrás
..
src d63a4904f9 trxbot há 10 meses atrás
test d63a4904f9 trxbot há 10 meses atrás
.coveralls.yml d63a4904f9 trxbot há 10 meses atrás
.gitignore d63a4904f9 trxbot há 10 meses atrás
.travis.yml d63a4904f9 trxbot há 10 meses atrás
LICENSE d63a4904f9 trxbot há 10 meses atrás
README.md d63a4904f9 trxbot há 10 meses atrás
composer.json d63a4904f9 trxbot há 10 meses atrás
composer.lock d63a4904f9 trxbot há 10 meses atrás
phpunit.xml.dist d63a4904f9 trxbot há 10 meses atrás

README.md

php-secp256k1 Build Status Coverage Status

$ composer require kornrunner/secp256k1

Usage

Sign a message:

<?php

require_once 'vendor/autoload.php';

use kornrunner\Secp256k1;
use kornrunner\Serializer\HexSignatureSerializer;

$secp256k1 = new Secp256k1();

// return signature contains r, s and recovery param (v).
// message and privateKey are hex strings
$signature = $secp256k1->sign($message, $privateKey);

// get r
$r = $signature->getR();

// get s
$s = $signature->getS();

// get recovery param
$v = $signature->getRecoveryParam();

// encode to hex
$serializer = new HexSignatureSerializer();
$signatureString = $serializer->serialize($signature);

// or you can call toHex
$signatureString = $signature->toHex();

Verify a message:

<?php

require_once 'vendor/autoload.php';

use kornrunner\Secp256k1;

$secp256k1 = new Secp256k1();

// signature was created by sign method
// hash and publicKey are hex strings
$isVerified = $secp256k1->verify($hash, $signature, $publicKey);

License

MIT

Crypto

ETH 0x9c7b7a00972121fb843af7af74526d7eb585b171