HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/quadcode/vendor/starkbank/ecdsa/src/signature.php
<?php

namespace EllipticCurve;

use EllipticCurve\Utils\Der;
use EllipticCurve\Utils\Binary;
use EllipticCurve\Utils\DerFieldType;


class Signature
{
    public $r, $s;
    public $recoveryId;

    function __construct($r, $s, $recoveryId=null)
    {
        $this->r = $r;
        $this->s = $s;
        $this->recoveryId = $recoveryId;
    }

    function toDer($withRecoveryId=false)
    {
        $hexadecimal = $this->_toString();
        $encodedSequence = Binary::byteStringFromHex($hexadecimal);
        if (!$withRecoveryId)
            return $encodedSequence;
        return chr(27 + $this->recoveryId) . $encodedSequence;
    }

    function toBase64($withRecoveryId=false)
    {
        return Binary::base64FromByteString($this->toDer($withRecoveryId));
    }

    static function fromDer($string, $recoveryByte=false)
    {
        $recoveryId = null;
        if ($recoveryByte) {
            $recoveryId = is_int($string[0]) ? $string[0] : ord($string[0]);
            $recoveryId -= 27;
            $string = substr($string, 1);
        }

        $hexadecimal = Binary::hexFromByteString($string);
        return Signature::_fromString($hexadecimal, $recoveryId);
    }

    static function fromBase64($string, $recoveryByte=false)
    {
        $der = Binary::byteStringFromBase64($string);
        return Signature::fromDer($der, $recoveryByte);
    }

    function _toString()
    {
        return Der::encodeConstructed(
            Der::encodePrimitive(DerFieldType::$integer, $this->r),
            Der::encodePrimitive(DerFieldType::$integer, $this->s)
        );
    }

    static function _fromString($string, $recoveryId=null)
    {
        list($r, $s) = Der::parse($string)[0];
        return new Signature($r, $s, $recoveryId);
    }
}