-
Notifications
You must be signed in to change notification settings - Fork 37
/
secp256k1_ec_pubkey_tweak_add_basic.phpt
55 lines (45 loc) · 1.36 KB
/
secp256k1_ec_pubkey_tweak_add_basic.phpt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
--TEST--
secp256k1_ec_pubkey_tweak_add works
--SKIPIF--
<?php
if (!extension_loaded("secp256k1")) print "skip extension not loaded";
?>
--FILE--
<?php
$context = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
$secKeyOne = str_repeat("\x00", 31) . "\x01";
$secKeyFour = str_repeat("\x00", 31) . "\x04";
/** @var resource $pubKey */
$pubKey = null;
$serKey = '';
$cmpKey = null;
$serCmp = '';
$result = secp256k1_ec_pubkey_create($context, $pubKey, $secKeyOne);
echo $result . PHP_EOL;
// 1
$result = secp256k1_ec_pubkey_tweak_add($context, $pubKey, $secKeyOne);
echo $result . PHP_EOL;
$result = secp256k1_ec_pubkey_tweak_add($context, $pubKey, $secKeyOne);
echo $result . PHP_EOL;
$result = secp256k1_ec_pubkey_tweak_add($context, $pubKey, $secKeyOne);
echo $result . PHP_EOL;
// 4
$result = secp256k1_ec_pubkey_serialize($context, $serKey, $pubKey, SECP256K1_EC_COMPRESSED);
echo $result . PHP_EOL;
echo unpack("H*", $serKey)[1] . PHP_EOL;
$result = secp256k1_ec_pubkey_create($context, $cmpKey, $secKeyFour);
echo $result . PHP_EOL;
$result = secp256k1_ec_pubkey_serialize($context, $serCmp, $cmpKey, SECP256K1_EC_COMPRESSED);
echo $result . PHP_EOL;
echo unpack("H*", $serCmp)[1] . PHP_EOL;
?>
--EXPECT--
1
1
1
1
1
02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13
1
1
02e493dbf1c10d80f3581e4904930b1404cc6c13900ee0758474fa94abe8c4cd13