-
Notifications
You must be signed in to change notification settings - Fork 5
Payments: PHP validation
Diogo edited this page Nov 5, 2018
·
4 revisions
To validate the signature belongs to the signing address, we can create a class Signature that will call the method personalEcRecover from Ethereum\EcRecover:
<?php
namespace Signature;
use Ethereum\EcRecover;
use Ethereum\DataType\EthD;
/**
* Class that validates sender signature
*
*/
class Signature
{
/**
* @dataProvider ecRecover
*
* @param $address
* @param $transaction
* @param $signature
*
* @returns bool
*
* @throws \Exception
*/
public function checkMatch($address, $transaction, $signature)
{
$recoveredAddr = Ethereum::personalEcRecover($transaction, new EthD($signature) );
$isEqual = $address == $recoveredAddr;
return $isEqual;
}
}
?>