Crypto/Transaction/Digest.pm

filter: Statementstmt 99.4% 173 / 174 Branchbran 91.6% 44 / 48 Conditioncond 90.6% 29 / 32 MC/DCmcdc 80.0% 16 / 20 Subroutinesub 100% 16 / 16 Podpod 0.0% 0 / 1 totaltotal 95.5% 278 / 291 CC 39 SCAR 22.7
CC
39
Cov
97%
_get_digest_taproot
15.1
_get_digest_default
13.0
_get_digest_segwit
10.0
CRAP 9.7
« Crypto/Helpers.pm ↑ Summary Crypto/Script/Recognition.pm »
1 package Bitcoin::Crypto::Transaction::Digest;
2 38 $Bitcoin::Crypto::Transaction::Digest::VERSION = '4.006';
3 38 ▶use v5.14;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 38 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 38 ▶use Mooish::Base -standard;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 38 ▶use Crypt::Digest::SHA256 qw(sha256);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 38 ▶use Bitcoin::Crypto::Helpers qw(ensure_length check_sighash);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 38 ▶use Bitcoin::Crypto::Util::Internal qw(hash256 pack_compactsize);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 38 ▶use Bitcoin::Crypto::Types -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 38 ▶use Bitcoin::Crypto::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 38 ▶use Bitcoin::Crypto::Constants qw(:sighash);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 38 ▶use Bitcoin::Crypto::Transaction::Digest::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 38 ▶use Bitcoin::Crypto::Transaction::Digest::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 38 has param 'transaction' => (
18 isa => InstanceOf ['Bitcoin::Crypto::Transaction'],
19 weak_ref => 1,
20 );
21  
22 38 has field 'config' => (
23 coerce => (InstanceOf ['Bitcoin::Crypto::Transaction::Digest::Config'])
24 ->plus_coercions(HashRef, q{Bitcoin::Crypto::Transaction::Digest::Config->new($_)}),
25 writer => 1,
26 handles => [
27 qw(
28 signing_index
29 signing_subscript
30 sighash
31 _default_sighash
32 taproot_ext_flag
33 taproot_ext
34 taproot_annex
35 )
36 ],
37 );
38  
39 has field '_cache' => (
40 isa => HashRef,
41 131 ▶ default => sub { {} },
Subroutine __ANON__: called CC=1 SCAR=0.0
42 38 );
43  
44 sub get_digest
45 260 ▶{
Subroutine get_digest: called CC=4 SCAR=13.9
Pod undocumented
46 260 my ($self) = @_;
47 260 my $input = $self->transaction->inputs->[$self->signing_index];
48  
49 260 ▶ Bitcoin::Crypto::Exception::Transaction->raise(
Branch: 1 branch
BranchTrueFalseTotal
unless $input 0 260 260
50 "can't find input with index " . $self->signing_index
51 ) unless $input;
52  
53 260 my $procedure = '_get_digest_default';
54 260 ▶ if ($input->is_taproot) {
Branch: 2 branches
BranchTrueFalseTotal
if ($input->is_taproot) { } 75 185 260
elsif ($input->is_segwit) { } 101 84 185
55 75 $procedure = '_get_digest_taproot';
56 }
57 elsif ($input->is_segwit) {
58 101 $procedure = '_get_digest_segwit';
59 }
60  
61 260 return $self->$procedure();
62 }
63  
64 sub _get_digest_default
65 84 ▶{
Subroutine _get_digest_default: called CC=13 SCAR=25.6
66 84 my ($self) = @_;
67  
68 84 my $sighash = $self->_default_sighash(SIGHASH_ALL);
69  
70 84 my $sighash_type = $sighash & 31;
71 84 my $anyonecanpay = $sighash & SIGHASH_ANYONECANPAY;
72  
73 84 my $transaction = $self->transaction;
74 84 my $tx_copy = $transaction->clone;
75  
76 84 my $signing_index = $self->signing_index;
77 84 my $inputs = $transaction->inputs;
78 84 my $copy_inputs = $tx_copy->inputs;
79 84 @{$copy_inputs} = ();
80  
81 84 foreach my $input_ind (keys @{$inputs}) {
82  
83 # no other inputs if anyonecanpay - skip cloning and all other work
84 144 ▶ next if $anyonecanpay && $input_ind != $signing_index;
Branch: 1 branch
BranchTrueFalseTotal
if $anyonecanpay and $input_ind != $signing_index 2 142 144
Condition100%3/3
$anyonecanpay and $input_ind != $signing_index
!ll&&!rl&&r
13932
MC/DC100%2/2
$anyonecanpay and $input_ind != $signing_index
$anyonecanpay $input_ind != $signing_index
Truth table100%3/3
A and B
A= $anyonecanpayB= $input_ind != $signing_index
ABresult
0X0
100
111
85  
86 142 my $input = $inputs->[$input_ind]->clone;
87  
88 142 ▶ if ($input_ind == $signing_index) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input_ind == $signing_index) { } 84 58 142
89 84 my $subscript = $self->signing_subscript;
90 84 ▶ if (!$subscript) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($subscript) 4 80 84
91 4 ▶ Bitcoin::Crypto::Exception::Transaction->raise(
Branch: 1 branch
BranchTrueFalseTotal
unless $input->utxo->output->is_standard 0 4 4
92 "can't guess the subscript from a non-standard transaction"
93 ) unless $input->utxo->output->is_standard;
94  
95 4 $subscript = $input->script_base;
96 }
97  
98 84 $input->set_signature_script($subscript);
99 }
100 else {
101 58 $input->set_signature_script('');
102 58 ▶ $input->set_sequence_no(0)
Branch: 1 branch
BranchTrueFalseTotal
if $sighash_type == 2 or $sighash_type == 3 27 31 58
Condition100%3/3
$sighash_type == 2 or $sighash_type == 3
l!l&&r!l&&!r
141331
MC/DC100%2/2
$sighash_type == 2 or $sighash_type == 3
$sighash_type == 2 $sighash_type == 3
Truth table100%3/3
A or B
A= $sighash_type == 2B= $sighash_type == 3
ABresult
1X1
011
000
103 if $sighash_type == SIGHASH_NONE
104 || $sighash_type == SIGHASH_SINGLE;
105 }
106  
107 142 push @{$copy_inputs}, $input;
108 }
109  
110 # Handle output work for sighashes
111 84 ▶ if ($sighash_type == SIGHASH_NONE) {
Branch: 2 branches
BranchTrueFalseTotal
if ($sighash_type == 2) { } 10 74 84
elsif ($sighash_type == 3) { } 9 65 74
112 10 @{$tx_copy->outputs} = ();
113 }
114 elsif ($sighash_type == SIGHASH_SINGLE) {
115 9 my $outputs = $transaction->outputs;
116 9 my $copy_outputs = $tx_copy->outputs;
117 9 @{$copy_outputs} = ();
118  
119 9 ▶ if ($signing_index >= @{$outputs}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($signing_index >= @{$outputs;}) 4 5 9
120  
121 # this should verify with constant digest (without hashing)
122 4 return Bitcoin::Crypto::Transaction::Digest::Result->new(
123 hash => scalar reverse ensure_length("\x01", 32),
124 );
125 }
126  
127 5 foreach my $output (@{$outputs}[0 .. $signing_index - 1]) {
128 1 my $output_copy = $output->clone;
129 1 $output_copy->set_locking_script('');
130 1 $output_copy->set_max_value;
131 1 push @{$copy_outputs}, $output_copy;
132 }
133  
134 5 push @{$copy_outputs}, $outputs->[$signing_index];
135 }
136  
137 80 my $serialized = $tx_copy->to_serialized(witness => 0);
138 80 $serialized .= pack 'V', $sighash;
139  
140 80 return Bitcoin::Crypto::Transaction::Digest::Result->new(preimage => $serialized);
141 }
142  
143 sub _get_digest_segwit
144 101 ▶{
Subroutine _get_digest_segwit: called CC=10 SCAR=23.0
145 101 my ($self) = @_;
146  
147 101 my $sighash = $self->_default_sighash(SIGHASH_ALL);
148  
149 101 my $sighash_type = $sighash & 31;
150 101 my $anyonecanpay = $sighash & SIGHASH_ANYONECANPAY;
151  
152 101 my $signing_index = $self->signing_index;
153 101 my $transaction = $self->transaction;
154 101 my @inputs = @{$transaction->inputs};
155 101 my $this_input = $inputs[$signing_index]->clone;
156 101 $inputs[$signing_index] = $this_input;
157  
158 101 my $empty_hash = "\x00" x 32;
159 101 my $single = $sighash_type == SIGHASH_SINGLE;
160 101 my $none = $sighash_type == SIGHASH_NONE;
161  
162 # NOTE: sets witness for proper behavior of _script_code in
163 # Bitcoin::Crypto::Transaction::Input for P2WSH
164 101 ▶ $this_input->set_witness([$self->signing_subscript])
Branch: 1 branch
BranchTrueFalseTotal
if $self->signing_subscript 99 2 101
165 if $self->signing_subscript;
166  
167 # According to https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki
168 # Double SHA256 of the serialization of:
169 # 1. nVersion of the transaction (4-byte little endian)
170 # 2. hashPrevouts (32-byte hash)
171 # 3. hashSequence (32-byte hash)
172 # 4. outpoint (32-byte hash + 4-byte little endian)
173 # 5. scriptCode of the input (serialized as scripts inside CTxOuts)
174 # 6. value of the output spent by this input (8-byte little endian)
175 # 7. nSequence of the input (4-byte little endian)
176 # 8. hashOutputs (32-byte hash)
177 # 9. nLocktime of the transaction (4-byte little endian)
178 # 10. sighash type of the signature (4-byte little endian)
179  
180 101 my $serialized = '';
181 101 $serialized .= pack 'V', $transaction->version;
182  
183 # handle prevouts
184 $serialized .= $anyonecanpay
185 ? $empty_hash
186 101 ▶ : hash256(join '', map { $_->prevout } @inputs)
Branch: 1 branch
BranchTrueFalseTotal
$anyonecanpay ? : 19 82 101
187 ;
188  
189 # handle sequences
190 $serialized .= $anyonecanpay || $single || $none
191 ? $empty_hash
192 101 ▶ : hash256(join '', map { pack 'V', $_->sequence_no } @inputs)
Branch: 1 branch
BranchTrueFalseTotal
$anyonecanpay || $single || $none ? : 35 66 101
Condition100%6/6
$anyonecanpay or $single or $none
l!l&&r!l&&!r
28766
$anyonecanpay or $single
l!l&&r!l&&!r
19973
MC/DC100%3/3
$anyonecanpay or $single or $none
$anyonecanpay $single $none
Truth table100%4/4
A or B or C
A= $anyonecanpayB= $singleC= $none
ABCresult
1XX1
01X1
0011
0000
193 ;
194  
195 101 $serialized .= $this_input->prevout;
196  
197 101 my $script_base = $this_input->script_base->to_serialized;
198 101 $serialized .= pack_compactsize(length $script_base);
199 101 $serialized .= $script_base;
200  
201 101 $serialized .= $this_input->utxo->output->value_serialized;
202 101 $serialized .= pack 'V', $this_input->sequence_no;
203  
204 # handle outputs
205 101 ▶ if (!$single && !$none) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $single || $none) { } 77 24 101
elsif ($single and $signing_index < @{$transaction->outputs;}) { } 12 12 24
Condition100%3/3
$single || $none
l!l&&r!l&&!r
141077
MC/DC100%2/2
$single || $none
$single $none
Truth table100%3/3
A || B
A= $singleB= $none
ABresult
1X1
011
000
206 77 $serialized .= hash256(join '', map { $_->to_serialized } @{$transaction->outputs});
207 }
208 14 ▶ elsif ($single && $signing_index < @{$transaction->outputs}) {
Condition100%3/3
$single and $signing_index < @{$transaction->outputs;}
!ll&&!rl&&r
10212
MC/DC100%2/2
$single and $signing_index < @{$transaction->outputs;}
$single $signing_index < @{$transaction->outputs;}
Truth table100%3/3
A and B
A= $singleB= $signing_index < @{$transaction->outputs;}
ABresult
0X0
100
111
209 12 $serialized .= hash256($transaction->outputs->[$signing_index]->to_serialized);
210 }
211 else {
212 12 $serialized .= $empty_hash;
213 }
214  
215 101 $serialized .= pack 'VV', $transaction->locktime, $sighash;
216  
217 101 return Bitcoin::Crypto::Transaction::Digest::Result->new(preimage => $serialized);
218 }
219  
220 sub _get_digest_taproot
221 75 ▶{
Subroutine _get_digest_taproot: called CC=15 SCAR=27.2
222 75 my ($self) = @_;
223  
224 75 my $sighash = $self->_default_sighash(SIGHASH_DEFAULT);
225  
226 75 my $sighash_type = $sighash & 3;
227 75 my $anyonecanpay = $sighash & SIGHASH_ANYONECANPAY;
228 75 my $single = $sighash_type == SIGHASH_SINGLE;
229 75 my $none = $sighash_type == SIGHASH_NONE;
230  
231 75 my $signing_index = $self->signing_index;
232 75 my $transaction = $self->transaction;
233 75 my $this_input = $transaction->inputs->[$signing_index];
234 75 my $annex = $self->taproot_annex;
235 75 my $ext_flag = $self->taproot_ext_flag;
236  
237 # allow sighash default (full sighash, not sighash_type) explicitly.
238 # check_sighash helper does not take SIGHASH_DEFAULT into account
239 75 ▶ Bitcoin::Crypto::Exception::Transaction->raise(
Branch: 1 branch
BranchTrueFalseTotal
if $sighash != 0 and not check_sighash($sighash) 1 74 75
Condition100%3/3
$sighash != 0 and not check_sighash($sighash)
!ll&&!rl&&r
36381
MC/DC100%2/2
$sighash != 0 and not check_sighash($sighash)
$sighash != 0 not check_sighash($sighash)
Truth table100%3/3
A and not(B)
A= $sighash != 0B= not check_sighash($sighash)
ABresult
0X0
100
111
240 "can't digest taproot transaction with unknown sighash"
241 ) if $sighash != SIGHASH_DEFAULT && !check_sighash($sighash);
242  
243 # According to https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki
244 # SHA256 of the serialization of:
245 # hash_type (1).
246 # nVersion (4): the nVersion of the transaction.
247 # nLockTime (4): the nLockTime of the transaction.
248 # If the hash_type & 0x80 does not equal SIGHASH_ANYONECANPAY:
249 # - sha_prevouts (32): the SHA256 of the serialization of all input outpoints.
250 # - sha_amounts (32): the SHA256 of the serialization of all input amounts.
251 # - sha_scriptpubkeys (32): the SHA256 of all spent outputs' scriptPubKeys, serialized as script inside CTxOut.
252 # - sha_sequences (32): the SHA256 of the serialization of all input nSequence.
253 # If hash_type & 3 does not equal SIGHASH_NONE or SIGHASH_SINGLE:
254 # - sha_outputs (32): the SHA256 of the serialization of all outputs in CTxOut format.
255 # spend_type (1): equal to (ext_flag * 2) + annex_present, where annex_present is 0 if no annex is present, or 1 otherwise (the original witness stack has two or more witness elements, and the first byte of the last element is 0x50)
256 # If hash_type & 0x80 equals SIGHASH_ANYONECANPAY:
257 # - outpoint (36): the COutPoint of this input (32-byte hash + 4-byte little-endian).
258 # - amount (8): value of the previous output spent by this input.
259 # - scriptPubKey (35): scriptPubKey of the previous output spent by this input, serialized as script inside CTxOut. Its size is always 35 bytes.
260 # - nSequence (4): nSequence of this input.
261 # If hash_type & 0x80 does not equal SIGHASH_ANYONECANPAY:
262 # - input_index (4): index of this input in the transaction input vector. Index of the first input is 0.
263 # If an annex is present (the lowest bit of spend_type is set):
264 # - sha_annex (32): the SHA256 of (compact_size(size of annex) || annex), where annex includes the mandatory 0x50 prefix.
265 # If hash_type & 3 equals SIGHASH_SINGLE:
266 # - sha_single_output (32): the SHA256 of the corresponding output in CTxOut format.
267  
268 # zero is sighash epoch
269 74 my $serialized = pack 'CCVV', 0, $sighash, $transaction->version, $transaction->locktime;
270  
271 74 ▶ if (!$anyonecanpay) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($anyonecanpay) 60 14 74
272 60 ▶ $serialized .= $self->_cache->{taproot_common_tx_data} //= do {
Condition66%2/3
$self->_cache->{"taproot_common_tx_data"} //= do { my(@prevouts, @amounts); my @pubkeys; my @sequences; foreach my $input (@{$transaction->inputs;}) { my $utxo_output = $input->utxo->output; my $pubkey = $utxo_output->locking_script->to_serialized; push @prevouts, $input->prevout; push @amounts, $utxo_output->value_serialized; push @pubkeys, pack_compactsize(length $pubkey) . $pubkey; push @sequences, pack("V", $input->sequence_no); } ; sha256(join("", @prevouts)) . sha256(join("", @amounts)) . sha256(join("", @pubkeys)) . sha256(join("", @sequences)) }
l!l&&r!l&&!r
30300
MC/DC0%0/2
$self->_cache->{"taproot_common_tx_data"} //= do { my(@prevouts, @amounts); my @pubkeys; my @sequences; foreach my $input (@{$transaction->inputs;}) { my $utxo_output = $input->utxo->output; my $pubkey = $utxo_output->locking_script->to_serialized; push @prevouts, $input->prevout; push @amounts, $utxo_output->value_serialized; push @pubkeys, pack_compactsize(length $pubkey) . $pubkey; push @sequences, pack("V", $input->sequence_no); } ; sha256(join("", @prevouts)) . sha256(join("", @amounts)) . sha256(join("", @pubkeys)) . sha256(join("", @sequences)) }
$self->_cache->{"taproot_common_tx_data"} do { my(@prevouts, @amounts); my @pubkeys; my @sequences; foreach my $input (@{$transaction->inputs;}) { my $utxo_output = $input->utxo->output; my $pubkey = $utxo_output->locking_script->to_serialized; push @prevouts, $input->prevout; push @amounts, $utxo_output->value_serialized; push @pubkeys, pack_compactsize(length $pubkey) . $pubkey; push @sequences, pack("V", $input->sequence_no); } ; sha256(join("", @prevouts)) . sha256(join("", @amounts)) . sha256(join("", @pubkeys)) . sha256(join("", @sequences)) }
Truth table66%2/3
A //= B
A= $self->_cache->{"taproot_common_tx_data"}B= do { my(@prevouts, @amounts); my @pubkeys; my @sequences; foreach my $input (@{$transaction->inputs;}) { my $utxo_output = $input->utxo->output; my $pubkey = $utxo_output->locking_script->to_serialized; push @prevouts, $input->prevout; push @amounts, $utxo_output->value_serialized; push @pubkeys, pack_compactsize(length $pubkey) . $pubkey; push @sequences, pack("V", $input->sequence_no); } ; sha256(join("", @prevouts)) . sha256(join("", @amounts)) . sha256(join("", @pubkeys)) . sha256(join("", @sequences)) }
ABresult
1X1
011
000
273 30 my @prevouts;
274 my @amounts;
275 30 my @pubkeys;
276 30 my @sequences;
277 30 foreach my $input (@{$transaction->inputs}) {
278 92 my $utxo_output = $input->utxo->output;
279 92 my $pubkey = $utxo_output->locking_script->to_serialized;
280  
281 92 push @prevouts, $input->prevout;
282 92 push @amounts, $utxo_output->value_serialized;
283 92 push @pubkeys, pack_compactsize(length $pubkey) . $pubkey;
284 92 push @sequences, pack 'V', $input->sequence_no;
285 }
286  
287 30 sha256(join '', @prevouts)
288 . sha256(join '', @amounts)
289 . sha256(join '', @pubkeys)
290 . sha256(join '', @sequences);
291 };
292 }
293  
294 my $outputs = $self->_cache->{taproot_outputs} //= [
295 74 ▶ map { $_->to_serialized } @{$transaction->outputs}
Condition100%2/2
$self->_cache->{"taproot_outputs"} //= [map({$_->to_serialized;} @{$transaction->outputs;})]
l!l
4034
MC/DC100%1/1
$self->_cache->{"taproot_outputs"} //= [map({$_->to_serialized;} @{$transaction->outputs;})]
$self->_cache->{"taproot_outputs"}
Truth table100%2/2
A
A= $self->_cache->{"taproot_outputs"}
Aresult
11
00
296 ];
297  
298 74 ▶ if (!$none && !$single) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($none or $single) 60 14 74
Condition100%3/3
$none or $single
l!l&&r!l&&!r
6860
MC/DC100%2/2
$none or $single
$none $single
Truth table100%3/3
A or B
A= $noneB= $single
ABresult
1X1
011
000
299 60 $serialized .= sha256(join '', @$outputs);
300 }
301  
302 74 $serialized .= pack 'C', $ext_flag * 2 + defined $annex;
303  
304 74 ▶ if ($anyonecanpay) {
Branch: 1 branch
BranchTrueFalseTotal
if ($anyonecanpay) { } 14 60 74
305 14 my $utxo_output = $this_input->utxo->output;
306 14 my $pubkey = $utxo_output->locking_script->to_serialized;
307  
308 14 $serialized .= join '',
309 $this_input->prevout,
310 $utxo_output->value_serialized,
311 pack_compactsize(length $pubkey),
312 $pubkey,
313 pack 'V', $this_input->sequence_no;
314 }
315 else {
316 60 $serialized .= pack 'V', $signing_index;
317 }
318  
319 74 ▶ if (defined $annex) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $annex) 0 74 74
320 0 $serialized .= sha256(pack_compactsize(length $annex) . $annex);
321 }
322  
323 74 ▶ if ($single) {
Branch: 1 branch
BranchTrueFalseTotal
if ($single) 8 66 74
324 8 ▶ Bitcoin::Crypto::Exception::Transaction->raise(
Branch: 1 branch
BranchTrueFalseTotal
unless $signing_index < @$outputs 0 8 8
325 "can't digest taproot transaction with SIGHASH_SINGLE without corresponding output"
326 ) unless $signing_index < @$outputs;
327  
328 8 $serialized .= sha256($outputs->[$self->signing_index]);
329 }
330  
331 # BIP342 extension
332 74 ▶ if ($ext_flag == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ext_flag == 1) 26 48 74
333 26 ▶ $serialized .= $self->taproot_ext
Condition33%1/3
$self->taproot_ext // "Bitcoin::Crypto::Exception::Transaction"->raise("missing taproot extension for ext_flag=1")
l!l&&r!l&&!r
2600
MC/DC0%0/2
$self->taproot_ext // "Bitcoin::Crypto::Exception::Transaction"->raise("missing taproot extension for ext_flag=1")
$self->taproot_ext "Bitcoin::Crypto::Exception::Transaction"->raise("missing taproot extension for ext_flag=1")
Truth table33%1/3
A // B
A= $self->taproot_extB= "Bitcoin::Crypto::Exception::Transaction"->raise("missing taproot extension for ext_flag=1")
ABresult
1X1
011
000
334 // Bitcoin::Crypto::Exception::Transaction->raise('missing taproot extension for ext_flag=1');
335 }
336  
337 74 return Bitcoin::Crypto::Transaction::Digest::Result->new(
338 taproot => !!1,
339 preimage => $serialized,
340 );
341 }
342  
343 38 1;
344  
« Crypto/Helpers.pm ↑ Summary Crypto/Script/Recognition.pm »