Completed
Pull Request — master (#758)
by thomas
22:04
created

SchnorrSignature   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 20
ccs 0
cts 16
cp 0
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBuffer() 0 7 2
A __construct() 0 4 1
A getResource() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace BitWasp\Bitcoin\Crypto\EcAdapter\Impl\Secp256k1\Signature;
4
5
use BitWasp\Bitcoin\Serializable;
6
use BitWasp\Buffertools\Buffer;
7
use BitWasp\Buffertools\BufferInterface;
8
9
class SchnorrSignature extends Serializable implements SchnorrSignatureInterface
10
{
11
    private $context;
12
    private $schnorrSig;
13
    public function __construct($context, $schnorrSig)
14
    {
15
        $this->context = $context;
16
        $this->schnorrSig = $schnorrSig;
17
    }
18
    public function getResource()
19
    {
20
        return $this->schnorrSig;
21
    }
22
    public function getBuffer(): BufferInterface
23
    {
24
        $out = '';
25
        if (!secp256k1_schnorrsig_serialize($this->context, $out, $this->schnorrSig)) {
0 ignored issues
show
Bug introduced by
The function secp256k1_schnorrsig_serialize was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        if (!/** @scrutinizer ignore-call */ secp256k1_schnorrsig_serialize($this->context, $out, $this->schnorrSig)) {
Loading history...
26
            throw new \RuntimeException("failed to serialize schnorrsig");
27
        }
28
        return new Buffer($out);
29
    }
30
}