init
This commit is contained in:
+17
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
require_once __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
class ApiTest extends \PHPUnit\Framework\TestCase {
|
||||
public function test_should_instatiate_with_valid_curve_secp256k1() {
|
||||
$ec = new \Elliptic\EC('secp256k1');
|
||||
|
||||
$this->assertNotNull($ec);
|
||||
$this->assertInstanceOf(\Elliptic\EC::class, $ec);
|
||||
}
|
||||
|
||||
|
||||
public function test_should_throw_error_with_invalid_curve() {
|
||||
$this->expectException(\Exception::class);
|
||||
$ec = new \Elliptic\EC('nonexistent-curve');
|
||||
}
|
||||
}
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
require_once __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
use BN\BN;
|
||||
|
||||
class CurveTest extends \PHPUnit\Framework\TestCase {
|
||||
public function test_should_work_with_example_curve() {
|
||||
$curve = new \Elliptic\Curve\ShortCurve(array(
|
||||
"p" => '1d',
|
||||
"a" => '4',
|
||||
"b" => '14'
|
||||
));
|
||||
|
||||
$p = $curve->point('18', '16');
|
||||
$this->assertTrue($p->validate());
|
||||
$this->assertTrue($p->dbl()->validate());
|
||||
$this->assertTrue($p->dbl()->add($p)->validate());
|
||||
$this->assertTrue($p->dbl()->add($p->dbl())->validate());
|
||||
$this->assertTrue($p->dbl()->add($p->dbl())->eq($p->add($p)->add($p)->add($p)));
|
||||
}
|
||||
|
||||
public function test_should_work_with_secp112k1() {
|
||||
$curve = new \Elliptic\Curve\ShortCurve(array(
|
||||
"p" => 'db7c 2abf62e3 5e668076 bead208b',
|
||||
"a" => 'db7c 2abf62e3 5e668076 bead2088',
|
||||
"b" => '659e f8ba0439 16eede89 11702b22'
|
||||
));
|
||||
|
||||
$p = $curve->point(
|
||||
'0948 7239995a 5ee76b55 f9c2f098',
|
||||
'a89c e5af8724 c0a23e0e 0ff77500');
|
||||
$this->assertTrue($p->validate());
|
||||
$this->assertTrue($p->dbl()->validate());
|
||||
}
|
||||
|
||||
public function test_should_work_with_secp256k1() {
|
||||
$curve = new \Elliptic\Curve\ShortCurve(array(
|
||||
"p" => 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ' .
|
||||
'fffffc2f',
|
||||
"a" => '0',
|
||||
"b" => '7',
|
||||
"n" => 'ffffffff ffffffff ffffffff fffffffe ' .
|
||||
'baaedce6 af48a03b bfd25e8c d0364141',
|
||||
"g" => [
|
||||
'79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
|
||||
'483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8'
|
||||
]
|
||||
));
|
||||
|
||||
$p = $curve->point(
|
||||
'79be667e f9dcbbac 55a06295 ce870b07 029bfcdb 2dce28d9 59f2815b 16f81798',
|
||||
'483ada77 26a3c465 5da4fbfc 0e1108a8 fd17b448 a6855419 9c47d08f fb10d4b8'
|
||||
);
|
||||
$this->assertTrue($p->validate());
|
||||
$this->assertTrue($p->dbl()->validate());
|
||||
$this->assertTrue($p->toJ()->dbl()->toP()->validate());
|
||||
$this->assertTrue($p->mul(new BN('79be667e f9dcbbac 55a06295 ce870b07', 16))->validate());
|
||||
|
||||
$j = $p->toJ();
|
||||
$this->assertTrue($j->trpl()->eq($j->dbl()->add($j)));
|
||||
|
||||
// Endomorphism test
|
||||
$this->assertNotNull($curve->endo);
|
||||
$this->assertEquals(
|
||||
$curve->endo["beta"]->fromRed()->toString(16),
|
||||
'7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee');
|
||||
$this->assertEquals(
|
||||
$curve->endo["lambda"]->toString(16),
|
||||
'5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72');
|
||||
|
||||
$k = new BN('1234567890123456789012345678901234', 16);
|
||||
$split = $curve->_endoSplit($k);
|
||||
|
||||
$testK = $split["k1"]->add($split["k2"]->mul($curve->endo["lambda"]))->umod($curve->n);
|
||||
$this->assertEquals($testK->toString(16), $k->toString(16));
|
||||
}
|
||||
|
||||
public function test_should_compute_this_problematic_secp256k1_multiplication() {
|
||||
$curve = \Elliptic\Curves::getCurve("secp256k1")->curve;
|
||||
$g1 = $curve->g; // precomputed g
|
||||
$this->assertNotNull($g1->precomputed);
|
||||
$g2 = $curve->point($g1->getX(), $g1->getY()); // not precomputed g
|
||||
$this->assertNull($g2->precomputed);
|
||||
$a = new BN(
|
||||
'6d1229a6b24c2e775c062870ad26bc261051e0198c67203167273c7c62538846', 16);
|
||||
$p1 = $g1->mul($a);
|
||||
$p2 = $g2->mul($a);
|
||||
$this->assertTrue($p1->eq($p2));
|
||||
}
|
||||
|
||||
public function test_should_not_use_fixed_NAF_when_k_is_too_large() {
|
||||
$curve = \Elliptic\Curves::getCurve("secp256k1")->curve;
|
||||
$g1 = $curve->g; // precomputed g
|
||||
$this->assertNotNull($g1->precomputed);
|
||||
$g2 = $curve->point($g1->getX(), $g1->getY()); // not precomputed g
|
||||
$this->assertNull($g2->precomputed);
|
||||
|
||||
$a = new BN(
|
||||
'6d1229a6b24c2e775c062870ad26bc26' .
|
||||
'1051e0198c67203167273c7c6253884612345678',
|
||||
16);
|
||||
$p1 = $g1->mul($a);
|
||||
$p2 = $g2->mul($a);
|
||||
$this->assertTrue($p1->eq($p2));
|
||||
}
|
||||
|
||||
public function test_should_not_fail_on_secp256k1_regression() {
|
||||
$curve = \Elliptic\Curves::getCurve("secp256k1")->curve;
|
||||
$k1 = new BN(
|
||||
'32efeba414cd0c830aed727749e816a01c471831536fd2fce28c56b54f5a3bb1', 16);
|
||||
$k2 = new BN(
|
||||
'5f2e49b5d64e53f9811545434706cde4de528af97bfd49fde1f6cf792ee37a8c', 16);
|
||||
|
||||
$p1 = $curve->g->mul($k1);
|
||||
$p2 = $curve->g->mul($k2);
|
||||
|
||||
// 2 + 2 + 1 = 2 + 1 + 2
|
||||
$two = $p2->dbl();
|
||||
$five = $two->dbl()->add($p2);
|
||||
$three = $two->add($p2);
|
||||
$maybeFive = $three->add($two);
|
||||
|
||||
$this->assertTrue($maybeFive->eq($five));
|
||||
|
||||
$p1 = $p1->mul($k2);
|
||||
$p2 = $p2->mul($k1);
|
||||
|
||||
$this->assertTrue($p1->validate());
|
||||
$this->assertTrue($p2->validate());
|
||||
$this->assertTrue($p1->eq($p2));
|
||||
}
|
||||
|
||||
public function test_should_correctly_double_the_affine_point_on_secp256k1() {
|
||||
$bad = new ArrayObject(array(
|
||||
"x" => '026a2073b1ef6fab47ace18e60e728a05180a82755bbcec9a0abc08ad9f7a3d4',
|
||||
"y" => '9cd8cb48c3281596139f147c1364a3ede88d3f310fdb0eb98c924e599ca1b3c9',
|
||||
"z" => 'd78587ad45e4102f48b54b5d85598296e069ce6085002e169c6bad78ddc6d9bd'
|
||||
), ArrayObject::ARRAY_AS_PROPS);
|
||||
|
||||
$good = new ArrayObject(array(
|
||||
"x" => 'e7789226739ac2eb3c7ccb2a9a910066beeed86cdb4e0f8a7fee8eeb29dc7016',
|
||||
"y" => '4b76b191fd6d47d07828ea965e275b76d0e3e0196cd5056d38384fbb819f9fcb',
|
||||
"z" => 'cbf8d99056618ba132d6145b904eee1ce566e0feedb9595139c45f84e90cfa7d'
|
||||
), ArrayObject::ARRAY_AS_PROPS);
|
||||
|
||||
$curve = \Elliptic\Curves::getCurve("secp256k1")->curve;
|
||||
$bad = $curve->jpoint($bad->x, $bad->y, $bad->z);
|
||||
$good = $curve->jpoint($good->x, $good->y, $good->z);
|
||||
|
||||
// They are the same points
|
||||
$this->assertTrue($bad->add($good->neg())->isInfinity());
|
||||
|
||||
// But doubling borks them out
|
||||
$this->assertTrue($bad->dbl()->add($good->dbl()->neg())->isInfinity());
|
||||
}
|
||||
|
||||
public function test_should_store_precomputed_values_correctly_on_negation() {
|
||||
$curve = \Elliptic\Curves::getCurve("secp256k1")->curve;
|
||||
$p = $curve->g->mul('2');
|
||||
$p->precompute();
|
||||
$neg = $p->neg(true);
|
||||
$neg2 = $neg->neg(true);
|
||||
$this->assertTrue($p->eq($neg2));
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
require_once __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
class ECDHTest extends \PHPUnit\Framework\TestCase {
|
||||
public function test_should_work_with_secp256k1_curve() {
|
||||
$this->doTest('secp256k1');
|
||||
}
|
||||
|
||||
public function test_should_work_with_p256_curve() {
|
||||
$this->doTest('p256');
|
||||
}
|
||||
|
||||
public function test_should_work_with_curve25519_curve() {
|
||||
$this->doTest('curve25519');
|
||||
}
|
||||
|
||||
public function test_should_work_with_ed25519_curve() {
|
||||
$this->doTest('ed25519');
|
||||
}
|
||||
|
||||
function doTest($name) {
|
||||
$ecdh = new \Elliptic\EC($name);
|
||||
$s1 = $ecdh->genKeyPair();
|
||||
$s2 = $ecdh->genKeyPair();
|
||||
$sh1 = $s1->derive($s2->getPublic());
|
||||
$sh2 = $s2->derive($s1->getPublic());
|
||||
|
||||
$this->assertEquals($sh1->toString(16), $sh2->toString(16));
|
||||
|
||||
$sh1 = $s1->derive($ecdh->keyFromPublic($s2->getPublic('hex'), 'hex')
|
||||
->getPublic());
|
||||
$sh2 = $s2->derive($ecdh->keyFromPublic($s1->getPublic('hex'), 'hex')
|
||||
->getPublic());
|
||||
$this->assertEquals($sh1->toString(16), $sh2->toString(16));
|
||||
}
|
||||
}
|
||||
+321
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
require_once __DIR__ . "/../vendor/autoload.php";
|
||||
use BN\BN;
|
||||
|
||||
class ECDSATest extends \PHPUnit\Framework\TestCase {
|
||||
|
||||
function ECDSACurveNames() {
|
||||
return [
|
||||
['secp256k1']
|
||||
, ['ed25519']
|
||||
, ['p256']
|
||||
, ['p384']
|
||||
, ['p521']
|
||||
];
|
||||
}
|
||||
|
||||
static $entropy = [
|
||||
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
|
||||
];
|
||||
|
||||
static $msg = 'deadbeef';
|
||||
|
||||
protected $curve;
|
||||
protected $ecdsa;
|
||||
protected $keys;
|
||||
|
||||
public function prepare($name) {
|
||||
$this->curve = \Elliptic\Curves::getCurve($name);
|
||||
$this->assertNotNull($this->curve);
|
||||
|
||||
$this->ecdsa = new \Elliptic\EC($this->curve);
|
||||
$this->keys = $this->ecdsa->genKeyPair([ "entropy" => self::$entropy ]);
|
||||
return [$this->curve, $this->ecdsa, $this->keys];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_generate_proper_key_pair($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
$keylen = 64;
|
||||
if ($name == 'p384') {
|
||||
$keylen = 96;
|
||||
} else if ($name == 'p521') {
|
||||
$keylen = 132;
|
||||
}
|
||||
// Get keys out of pair
|
||||
$this->assertTrue( $keys->getPublic()->x && $keys->getPublic()->y );
|
||||
$this->assertTrue( $keys->getPrivate()->byteLength() > 0);
|
||||
$this->assertEquals( strlen($keys->getPrivate('hex')), $keylen);
|
||||
$this->assertTrue( strlen($keys->getPublic('hex')) > 0);
|
||||
$this->assertTrue( strlen($keys->getPrivate('hex')) > 0);
|
||||
$this->assertTrue( $keys->validate()["result"], 'key validate' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_sign_and_verify($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
$signature = $ecdsa->sign(self::$msg, $keys);
|
||||
$this->assertTrue($ecdsa->verify(self::$msg, $signature, $keys), 'Normal verify');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_sign_and_verify_using_keys_methods($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
$signature = $keys->sign(self::$msg);
|
||||
$this->assertTrue($keys->verify(self::$msg, $signature), 'On-key verify');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_load_private_key_from_the_hex_value($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
$copy = $ecdsa->keyFromPrivate($keys->getPrivate('hex'), 'hex');
|
||||
$signature = $ecdsa->sign(self::$msg, $copy);
|
||||
$this->assertTrue($ecdsa->verify(self::$msg, $signature, $copy), 'hex-private verify');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_have_signature_s_leq_keys_ec_nh($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
// key.sign(msg, options)
|
||||
$sign = $keys->sign('deadbeef', [ "canonical" => true ]);
|
||||
$this->assertTrue($sign->s->cmp($keys->ec->nh) <= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_support_options_k($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
$sign = $keys->sign(self::$msg, [
|
||||
"k" => function($iter) {
|
||||
$this->assertTrue($iter >= 0);
|
||||
return new BN(1358);
|
||||
}
|
||||
]);
|
||||
$this->assertTrue($ecdsa->verify(self::$msg, $sign, $keys), 'custom-k verify');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_have_another_signature_with_pers($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
$sign1 = $keys->sign(self::$msg);
|
||||
$sign2 = $keys->sign(self::$msg, [ "pers" => '1234', "persEnc" => 'hex' ]);
|
||||
$this->assertNotEquals($sign1->r->toString('hex') . $sign1->s->toString('hex'),
|
||||
$sign2->r->toString('hex') . $sign2->s->toString('hex'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_load_public_key_from_compact_hex_value($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
$pub = $keys->getPublic(true, 'hex');
|
||||
$copy = $ecdsa->keyFromPublic($pub, 'hex');
|
||||
$this->assertEquals($copy->getPublic(true, 'hex'), $pub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_load_public_key_from_hex_value($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
$pub = $keys->getPublic('hex');
|
||||
$copy = $ecdsa->keyFromPublic($pub, 'hex');
|
||||
$this->assertEquals($copy->getPublic('hex'), $pub);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_support_hex_DER_encoding_of_signatures($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
$signature = $ecdsa->sign(self::$msg, $keys);
|
||||
$dsign = $signature->toDER('hex');
|
||||
$this->assertTrue($ecdsa->verify(self::$msg, $dsign, $keys), 'hex-DER encoded verify');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_support_DER_encoding_of_signatures($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
$signature = $ecdsa->sign(self::$msg, $keys);
|
||||
$dsign = $signature->toDER();
|
||||
$this->assertTrue($ecdsa->verify(self::$msg, $dsign, $keys), 'DER encoded verify');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_not_verify_signature_with_wrong_public_key($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
$signature = $ecdsa->sign(self::$msg, $keys);
|
||||
|
||||
$wrong = $ecdsa->genKeyPair();
|
||||
$this->assertNotTrue($ecdsa->verify(self::$msg, $signature, $wrong), 'Wrong key verify');
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider ECDSACurveNames
|
||||
*/
|
||||
public function test_should_not_verify_signature_with_wrong_private_key($name) {
|
||||
list($curve, $ecdsa, $keys) = $this->prepare($name);
|
||||
$signature = $ecdsa->sign(self::$msg, $keys);
|
||||
|
||||
$wrong = $ecdsa->keyFromPrivate($keys->getPrivate('hex') .
|
||||
$keys->getPrivate('hex'), 'hex');
|
||||
$this->assertNotTrue($ecdsa->verify(self::$msg, $signature, $wrong), 'Wrong key verify');
|
||||
}
|
||||
|
||||
|
||||
// TODO: Implement RFC6979 vectors test
|
||||
|
||||
|
||||
function MaxwellsTrickVector() {
|
||||
$p256 = \Elliptic\Curves::getCurve("p256");
|
||||
$p384 = \Elliptic\Curves::getCurve("p384");
|
||||
$msg = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855';
|
||||
return [
|
||||
[[
|
||||
"curve" => $p256,
|
||||
"pub" => '041548fc88953e06cd34d4b300804c5322cb48c24aaaa4d0' .
|
||||
'7a541b0f0ccfeedeb0ae4991b90519ea405588bdf699f5e6' .
|
||||
'd0c6b2d5217a5c16e8371062737aa1dae1',
|
||||
"message" => $msg,
|
||||
"sig" => '3006020106020104',
|
||||
"result" => true
|
||||
]],
|
||||
[[
|
||||
"curve" => $p256,
|
||||
"pub" => '04ad8f60e4ec1ebdb6a260b559cb55b1e9d2c5ddd43a41a2' .
|
||||
'd11b0741ef2567d84e166737664104ebbc337af3d861d352' .
|
||||
'4cfbc761c12edae974a0759750c8324f9a',
|
||||
"message" => $msg,
|
||||
"sig" => '3006020106020104',
|
||||
"result" => true
|
||||
]],
|
||||
[[
|
||||
"curve" => $p256,
|
||||
"pub" => '0445bd879143a64af5746e2e82aa65fd2ea07bba4e355940' .
|
||||
'95a981b59984dacb219d59697387ac721b1f1eccf4b11f43' .
|
||||
'ddc39e8367147abab3084142ed3ea170e4',
|
||||
"message" => $msg,
|
||||
"sig" => '301502104319055358e8617b0c46353d039cdaae020104',
|
||||
"result" => true
|
||||
]],
|
||||
[[
|
||||
"curve" => $p256,
|
||||
"pub" => '040feb5df4cc78b35ec9c180cc0de5842f75f088b4845697' .
|
||||
'8ffa98e716d94883e1e6500b2a1f6c1d9d493428d7ae7d9a' .
|
||||
'8a560fff30a3d14aa160be0c5e7edcd887',
|
||||
"message" => $msg,
|
||||
"sig" => '301502104319055358e8617b0c46353d039cdaae020104',
|
||||
"result" => false
|
||||
]],
|
||||
[[
|
||||
"curve" => $p384,
|
||||
"pub" => '0425e299eea9927b39fa92417705391bf17e8110b4615e9e' .
|
||||
'b5da471b57be0c30e7d89dbdc3e5da4eae029b300344d385' .
|
||||
'1548b59ed8be668813905105e673319d59d32f574e180568' .
|
||||
'463c6186864888f6c0b67b304441f82aab031279e48f047c31',
|
||||
"message" => $msg,
|
||||
"sig" => '3006020103020104',
|
||||
"result" => true
|
||||
]],
|
||||
[[
|
||||
"curve" => $p384,
|
||||
"pub" => '04a328f65c22307188b4af65779c1d2ec821c6748c6bd8dc' .
|
||||
'0e6a008135f048f832df501f7f3f79966b03d5bef2f187ec' .
|
||||
'34d85f6a934af465656fb4eea8dd9176ab80fbb4a27a649f' .
|
||||
'526a7dfe616091b78d293552bc093dfde9b31cae69d51d3afb',
|
||||
"message" => $msg,
|
||||
"sig" => '3006020103020104',
|
||||
"result" => true
|
||||
]],
|
||||
[[
|
||||
"curve" => $p384,
|
||||
"pub" => '04242e8585eaa7a28cc6062cab4c9c5fd536f46b17be1728' .
|
||||
'288a2cda5951df4941aed1d712defda023d10aca1c5ee014' .
|
||||
'43e8beacd821f7efa27847418ab95ce2c514b2b6b395ee73' .
|
||||
'417c83dbcad631421f360d84d64658c98a62d685b220f5aad4',
|
||||
"message" => $msg,
|
||||
"sig" => '301d0218389cb27e0bc8d21fa7e5f24cb74f58851313e696333ad68e020104',
|
||||
"result" => true
|
||||
]],
|
||||
[[
|
||||
"curve" => $p384,
|
||||
"pub" => '04cdf865dd743fe1c23757ec5e65fd5e4038b472ded2af26' .
|
||||
'1e3d8343c595c8b69147df46379c7ca40e60e80170d34a11' .
|
||||
'88dbb2b6f7d3934c23d2f78cfb0db3f3219959fad63c9b61' .
|
||||
'2ef2f20d679777b84192ce86e781c14b1bbb77eacd6e0520e2',
|
||||
"message" => $msg,
|
||||
"sig" => '301d0218389cb27e0bc8d21fa7e5f24cb74f58851313e696333ad68e020104',
|
||||
"result" => false
|
||||
]]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider MaxwellsTrickVector
|
||||
*/
|
||||
public function test_should_pass_on_Maxwells_trick_vectors($vector) {
|
||||
$ecdsa = new \Elliptic\EC($vector["curve"]);
|
||||
$key = $ecdsa->keyFromPublic($vector["pub"], 'hex');
|
||||
$msg = $vector["message"];
|
||||
$sig = $vector["sig"];
|
||||
|
||||
$actual = $ecdsa->verify($msg, $sig, $key);
|
||||
$this->assertEquals($actual, $vector["result"]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function test_should_deterministically_generate_private_key() {
|
||||
$curve = \Elliptic\Curves::getCurve("secp256k1");
|
||||
$this->assertNotNull($curve);
|
||||
|
||||
$ecdsa = new \Elliptic\EC($curve);
|
||||
$keys = $ecdsa->genKeyPair(array(
|
||||
"pers" => 'my.pers.string',
|
||||
"entropy" => hash('sha256', 'hello world', true)
|
||||
));
|
||||
$this->assertEquals(
|
||||
$keys->getPrivate('hex'),
|
||||
'6160edb2b218b7f1394b9ca8eb65a72831032a1f2f3dc2d99291c2f7950ed887');
|
||||
}
|
||||
|
||||
public function test_should_recover_the_public_key_from_a_signature() {
|
||||
$ec = new \Elliptic\EC('secp256k1');
|
||||
$key = $ec->genKeyPair();
|
||||
$msg = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ];
|
||||
$signature = $key->sign($msg);
|
||||
$recid = $ec->getKeyRecoveryParam($msg, $signature, $key->getPublic());
|
||||
$r = $ec->recoverPubKey($msg, $signature, $recid);
|
||||
$this->assertTrue($key->getPublic()->eq($r), 'the keys should match');
|
||||
}
|
||||
|
||||
public function test_should_fail_to_recover_key_when_no_quadratic_residue_available() {
|
||||
$ec = new \Elliptic\EC('secp256k1');
|
||||
$message =
|
||||
'f75c6b18a72fabc0f0b888c3da58e004f0af1fe14f7ca5d8c897fe164925d5e9';
|
||||
|
||||
$this->expectException(\Exception::class);
|
||||
$ec->recoverPubKey($message, [
|
||||
"r" => 'fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140',
|
||||
"s" => '8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3'
|
||||
], 0);
|
||||
}
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
require_once __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
use \Elliptic\EdDSA;
|
||||
use \Elliptic\Utils;
|
||||
|
||||
function toHex($arg) { return strtoupper(Utils::toHex($arg)); }
|
||||
|
||||
class ED25519Test extends \PHPUnit\Framework\TestCase {
|
||||
public function derivations() {
|
||||
$data = json_decode( file_get_contents(__DIR__ . "/fixtures/derivation-fixtures"), true);
|
||||
$data = array_slice($data, 0, 50);
|
||||
return array_map(function($set) { return [$set]; }, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider derivations
|
||||
*/
|
||||
public function test_derivations_can_compute_correct_a_and_A_from_secret($test) {
|
||||
$ed25519 = new EdDSA("ed25519");
|
||||
$secret = Utils::toArray($test["secret_hex"], 'hex');
|
||||
$key = $ed25519->keyFromSecret($secret);
|
||||
$this->assertEquals( toHex($key->privBytes()), $test["a_hex"] );
|
||||
$xRecovered = toHex( $ed25519->encodeInt(
|
||||
$ed25519->decodePoint( $key->pubBytes() )->getX()) );
|
||||
$this->assertEquals( $xRecovered, $test["A_P"]["x"] );
|
||||
$this->assertEquals( toHex( $key->pubBytes() ), $test["A_hex"] );
|
||||
}
|
||||
|
||||
public function signLines() {
|
||||
$data = file_get_contents(__DIR__ . "/fixtures/sign.input");
|
||||
$lines = array_filter( explode("\n", $data), function($line) { return strlen($line) > 0; });
|
||||
$lines = array_slice($lines, 0, 50);
|
||||
return array_map(function($line) { return [$line]; }, $lines);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider signLines
|
||||
*/
|
||||
public function test_sign_input_test_vectors($line) {
|
||||
$split = explode(':', strtoupper($line));
|
||||
$ed25519 = new EdDSA("ed25519");
|
||||
$key = $ed25519->keyFromSecret(substr($split[0], 0, 64));
|
||||
$expectedPk = substr($split[0], 64);
|
||||
$this->assertEquals( toHex($key->pubBytes()), $expectedPk);
|
||||
|
||||
$msg = Utils::toArray($split[2], 'hex');
|
||||
$sig = $key->sign($msg)->toHex();
|
||||
$sigR = substr($sig, 0, 64);
|
||||
$sigS = substr($sig, 64);
|
||||
|
||||
$this->assertEquals($sigR, substr($split[3], 0, 64));
|
||||
$this->assertEquals($sigS, substr($split[3], 64, 64));
|
||||
$this->assertTrue($key->verify($msg, $sig));
|
||||
|
||||
if (count($msg) == 0) {
|
||||
$forged = [ 0x78 ] /* ord('x') */;
|
||||
} else {
|
||||
$forged = $msg;
|
||||
$forged[count($msg) - 1] = ($msg[count($msg) - 1] + 1) % 256;
|
||||
}
|
||||
|
||||
$this->assertNotTrue($key->verify($forged, $sig));
|
||||
}
|
||||
|
||||
public function test_eddsa_has_encodingLength_of_32() {
|
||||
$ed25519 = new EdDSA("ed25519");
|
||||
$this->assertEquals(32, $ed25519->encodingLength);
|
||||
}
|
||||
|
||||
public function test_eddsa_can_sign_and_verify_messages() {
|
||||
$ed25519 = new EdDSA("ed25519");
|
||||
$secret = array_fill(0, 32, 0);
|
||||
$msg = [ 0xB, 0xE, 0xE, 0xF ];
|
||||
$key = $ed25519->keyFromSecret($secret);
|
||||
$sig = $key->sign($msg)->toHex();
|
||||
|
||||
$R = '8F1B9A7FDB22BCD2C15D4695B1CE2B063CBFAEC9B00BE360427BAC9533943F6C';
|
||||
$S = '5F0B380FD7F2E43B70AB2FA29F6C6E3FFC1012710E174786814012324BF19B0C';
|
||||
|
||||
$this->assertEquals(substr($sig, 0, 64), $R);
|
||||
$this->assertEquals(substr($sig, 64), $S);
|
||||
|
||||
$this->assertTrue($key->verify($msg, $sig));
|
||||
}
|
||||
|
||||
static $secret = '0000000000000000000000000000000000000000000000000000000000000000';
|
||||
public function test_eddsa_keypair_can_be_created_with_keyFromSecret_or_keyFromPublic() {
|
||||
$ed25519 = new EdDSA("ed25519");
|
||||
$pair = $ed25519->keyFromSecret(self::$secret);
|
||||
$pubKey = $ed25519->keyFromPublic( toHex($pair->pubBytes()) );
|
||||
$this->assertTrue( is_a($pubKey->pub(), $ed25519->pointClass) );
|
||||
$this->assertTrue( $pubKey->pub()->eq($pair->pub()));
|
||||
}
|
||||
|
||||
public function test_eddsa_keypair_getSecret_returns_bytes_with_optional_encoding() {
|
||||
$ed25519 = new EdDSA("ed25519");
|
||||
$pair = $ed25519->keyFromSecret(self::$secret);
|
||||
$this->assertTrue( is_array($pair->getSecret()) );
|
||||
$this->assertTrue( $pair->getSecret('hex') == self::$secret);
|
||||
}
|
||||
|
||||
public function test_eddsa_keypair_getPub_returns_bytes_with_optional_encoding() {
|
||||
$ed25519 = new EdDSA("ed25519");
|
||||
$pair = $ed25519->keyFromSecret(self::$secret);
|
||||
$this->assertTrue( is_array($pair->getPublic()) );
|
||||
$this->assertEquals( $pair->getPublic('hex'),
|
||||
'3b6a27bcceb6a42d62a3a8d02a6f0d73653215771de243a63ac048a18b59da29');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
require_once __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
class HmacDRBGTest extends \PHPUnit\Framework\TestCase {
|
||||
|
||||
public function test_should_support_hmac_drbg_sha256() {
|
||||
function doDrbg($opt) {
|
||||
$drbg = new \Elliptic\HmacDRBG([
|
||||
"hash" => ["algo" => 'sha256', 'outSize' => 256, 'hmacStrength' => 192],//hash.sha256,
|
||||
"entropy" => $opt["entropy"],
|
||||
"nonce" => $opt["nonce"],
|
||||
"pers" => $opt["pers"]
|
||||
]);
|
||||
return $drbg->generate($opt["size"], 'hex');
|
||||
}
|
||||
|
||||
$test = [
|
||||
[
|
||||
"entropy" => 'totally random0123456789',
|
||||
"nonce" => 'secret nonce',
|
||||
"pers" => 'my drbg',
|
||||
"size" => 32,
|
||||
"res" => '018ec5f8e08c41e5ac974eb129ac297c5388ee1864324fa13d9b15cf98d9a157'
|
||||
],
|
||||
[
|
||||
"entropy" => 'totally random0123456789',
|
||||
"nonce" => 'secret nonce',
|
||||
"pers" => null,
|
||||
"size" => 32,
|
||||
"res" => 'ed5d61ecf0ef38258e62f03bbb49f19f2cd07ba5145a840d83b134d5963b3633'
|
||||
]
|
||||
];
|
||||
for ($i = 0; $i < count($test); $i++)
|
||||
$this->assertEquals(doDrbg($test[$i]), $test[$i]["res"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider NISTVector
|
||||
*/
|
||||
public function test_should_not_fail_at_NIST_vector($opt) {
|
||||
$drbg = new \Elliptic\HmacDRBG([
|
||||
"hash" => ["algo" => 'sha256', 'outSize' => 256, 'hmacStrength' => 192],//hash.sha256,
|
||||
"entropy" => $opt["entropy"],
|
||||
"entropyEnc" => 'hex',
|
||||
"nonce" => $opt["nonce"],
|
||||
"nonceEnc" => 'hex',
|
||||
"pers" => $opt["pers"],
|
||||
"persEnc" => 'hex'
|
||||
]);
|
||||
|
||||
for ($i = 0; $i < count($opt["add"]); $i++) {
|
||||
$last = $drbg->generate(strlen($opt["expected"]) / 2,
|
||||
'hex',
|
||||
$opt["add"][$i],
|
||||
'hex');
|
||||
}
|
||||
$this->assertEquals($last, $opt["expected"]);
|
||||
}
|
||||
|
||||
function NISTVector() {
|
||||
$data = json_decode(file_get_contents(__DIR__."/fixtures/hmac-drbg-nist.json"), true);
|
||||
$cases = array();
|
||||
for($i = 0; $i < count($data); ++$i) {
|
||||
$cases[ $data[$i]["name"] ] = [ $data[$i] ];
|
||||
}
|
||||
return $cases;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
require_once __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
class PointCodecTest extends \PHPUnit\Framework\TestCase {
|
||||
function makeShortTest($definition) {
|
||||
$curve = \Elliptic\Curves::getCurve("secp256k1")->curve;
|
||||
|
||||
return function() use($curve, $definition) {
|
||||
$co = $definition["coordinates"];
|
||||
$p = $curve->point($co["x"], $co["y"]);
|
||||
|
||||
// Encodes as expected
|
||||
$this->assertEquals($p->encode('hex'), $definition["encoded"]);
|
||||
$this->assertEquals($p->encodeCompressed('hex'), $definition["compactEncoded"]);
|
||||
|
||||
// Decodes as expected
|
||||
$this->assertTrue($curve->decodePoint($definition["encoded"], 'hex')->eq($p));
|
||||
$this->assertTrue($curve->decodePoint($definition["compactEncoded"], 'hex')->eq($p));
|
||||
$this->assertTrue($curve->decodePoint($definition["hybrid"], 'hex')->eq($p));
|
||||
};
|
||||
}
|
||||
|
||||
function makeMontTest($definition) {
|
||||
$curve = \Elliptic\Curves::getCurve("curve25519")->curve;
|
||||
return function() use ($definition, $curve) {
|
||||
$co = $definition["coordinates"];
|
||||
$p = $curve->point($co["x"], $co["z"]);
|
||||
$encoded = $p->encode('hex');
|
||||
$decoded = $curve->decodePoint($encoded, 'hex');
|
||||
$this->assertTrue($decoded->eq($p));
|
||||
$this->assertEquals($encoded, $definition["encoded"]);
|
||||
};
|
||||
}
|
||||
|
||||
static $shortPointEvenY;
|
||||
static $shortPointOddY;
|
||||
|
||||
public function test_should_throw_when_trying_to_decode_random_bytes() {
|
||||
$this->expectException(\Exception::class);
|
||||
\Elliptic\Curves::getCurve("secp256k1")->curve->decodePoint(
|
||||
'05' .
|
||||
'79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798');
|
||||
}
|
||||
|
||||
public function test_should_be_able_to_encode_and_decode_a_short_curve_point_with_even_Y() {
|
||||
$f = $this->makeShortTest(self::$shortPointEvenY);
|
||||
$f();
|
||||
}
|
||||
|
||||
public function test_should_be_able_to_encode_and_decode_a_short_curve_point_with_odd_Y() {
|
||||
$f = $this->makeShortTest(self::$shortPointOddY);
|
||||
$f();
|
||||
}
|
||||
|
||||
public function test_should_be_able_to_encode_and_decode_a_mont_curve_point() {
|
||||
$f = $this->makeMontTest([
|
||||
"coordinates" => [
|
||||
// curve25519.curve.g.mul(new BN('6')).getX().toString(16, 2)
|
||||
"x" => '26954ccdc99ebf34f8f1dde5e6bb080685fec73640494c28f9fe0bfa8c794531',
|
||||
"z" => '1'
|
||||
],
|
||||
"encoded" =>
|
||||
'26954ccdc99ebf34f8f1dde5e6bb080685fec73640494c28f9fe0bfa8c794531'
|
||||
]);
|
||||
$f();
|
||||
}
|
||||
}
|
||||
|
||||
PointCodecTest::$shortPointEvenY = [
|
||||
"coordinates" => [
|
||||
"x" => '79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
|
||||
"y" => '483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8'
|
||||
],
|
||||
"compactEncoded" =>
|
||||
'02' .
|
||||
'79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
|
||||
"encoded" =>
|
||||
'04' .
|
||||
'79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798' .
|
||||
'483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
|
||||
"hybrid" =>
|
||||
'06' .
|
||||
'79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798' .
|
||||
'483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8'
|
||||
];
|
||||
|
||||
|
||||
PointCodecTest::$shortPointOddY = [
|
||||
"coordinates" => [
|
||||
"x" => 'fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556',
|
||||
"y" => 'ae12777aacfbb620f3be96017f45c560de80f0f6518fe4a03c870c36b075f297'
|
||||
],
|
||||
"compactEncoded" =>
|
||||
'03' .
|
||||
'fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556',
|
||||
"encoded" =>
|
||||
'04' .
|
||||
'fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556' .
|
||||
'ae12777aacfbb620f3be96017f45c560de80f0f6518fe4a03c870c36b075f297',
|
||||
"hybrid" =>
|
||||
'07' .
|
||||
'fff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556' .
|
||||
'ae12777aacfbb620f3be96017f45c560de80f0f6518fe4a03c870c36b075f297'
|
||||
];
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,332 @@
|
||||
[
|
||||
{
|
||||
"name": "0",
|
||||
"entropy": "ca851911349384bffe89de1cbdc46e6831e44d34a4fb935ee285dd14b71a7488",
|
||||
"nonce": "659ba96c601dc69fc902940805ec0ca8",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "e528e9abf2dece54d47c7e75e5fe302149f817ea9fb4bee6f4199697d04d5b89d54fbb978a15b5c443c9ec21036d2460b6f73ebad0dc2aba6e624abf07745bc107694bb7547bb0995f70de25d6b29e2d3011bb19d27676c07162c8b5ccde0668961df86803482cb37ed6d5c0bb8d50cf1f50d476aa0458bdaba806f48be9dcb8"
|
||||
},
|
||||
{
|
||||
"name": "1",
|
||||
"entropy": "79737479ba4e7642a221fcfd1b820b134e9e3540a35bb48ffae29c20f5418ea3",
|
||||
"nonce": "3593259c092bef4129bc2c6c9e19f343",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "cf5ad5984f9e43917aa9087380dac46e410ddc8a7731859c84e9d0f31bd43655b924159413e2293b17610f211e09f770f172b8fb693a35b85d3b9e5e63b1dc252ac0e115002e9bedfb4b5b6fd43f33b8e0eafb2d072e1a6fee1f159df9b51e6c8da737e60d5032dd30544ec51558c6f080bdbdab1de8a939e961e06b5f1aca37"
|
||||
},
|
||||
{
|
||||
"name": "2",
|
||||
"entropy": "b340907445b97a8b589264de4a17c0bea11bb53ad72f9f33297f05d2879d898d",
|
||||
"nonce": "65cb27735d83c0708f72684ea58f7ee5",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "75183aaaf3574bc68003352ad655d0e9ce9dd17552723b47fab0e84ef903694a32987eeddbdc48efd24195dbdac8a46ba2d972f5808f23a869e71343140361f58b243e62722088fe10a98e43372d252b144e00c89c215a76a121734bdc485486f65c0b16b8963524a3a70e6f38f169c12f6cbdd169dd48fe4421a235847a23ff"
|
||||
},
|
||||
{
|
||||
"name": "3",
|
||||
"entropy": "8e159f60060a7d6a7e6fe7c9f769c30b98acb1240b25e7ee33f1da834c0858e7",
|
||||
"nonce": "c39d35052201bdcce4e127a04f04d644",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "62910a77213967ea93d6457e255af51fc79d49629af2fccd81840cdfbb4910991f50a477cbd29edd8a47c4fec9d141f50dfde7c4d8fcab473eff3cc2ee9e7cc90871f180777a97841597b0dd7e779eff9784b9cc33689fd7d48c0dcd341515ac8fecf5c55a6327aea8d58f97220b7462373e84e3b7417a57e80ce946d6120db5"
|
||||
},
|
||||
{
|
||||
"name": "4",
|
||||
"entropy": "74755f196305f7fb6689b2fe6835dc1d81484fc481a6b8087f649a1952f4df6a",
|
||||
"nonce": "c36387a544a5f2b78007651a7b74b749",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "b2896f3af4375dab67e8062d82c1a005ef4ed119d13a9f18371b1b873774418684805fd659bfd69964f83a5cfe08667ddad672cafd16befffa9faed49865214f703951b443e6dca22edb636f3308380144b9333de4bcb0735710e4d9266786342fc53babe7bdbe3c01a3addb7f23c63ce2834729fabbd419b47beceb4a460236"
|
||||
},
|
||||
{
|
||||
"name": "5",
|
||||
"entropy": "4b222718f56a3260b3c2625a4cf80950b7d6c1250f170bd5c28b118abdf23b2f",
|
||||
"nonce": "7aed52d0016fcaef0b6492bc40bbe0e9",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "a6da029b3665cd39fd50a54c553f99fed3626f4902ffe322dc51f0670dfe8742ed48415cf04bbad5ed3b23b18b7892d170a7dcf3ef8052d5717cb0c1a8b3010d9a9ea5de70ae5356249c0e098946030c46d9d3d209864539444374d8fbcae068e1d6548fa59e6562e6b2d1acbda8da0318c23752ebc9be0c1c1c5b3cf66dd967"
|
||||
},
|
||||
{
|
||||
"name": "6",
|
||||
"entropy": "b512633f27fb182a076917e39888ba3ff35d23c3742eb8f3c635a044163768e0",
|
||||
"nonce": "e2c39b84629a3de5c301db5643af1c21",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "fb931d0d0194a97b48d5d4c231fdad5c61aedf1c3a55ac24983ecbf38487b1c93396c6b86ff3920cfa8c77e0146de835ea5809676e702dee6a78100da9aa43d8ec0bf5720befa71f82193205ac2ea403e8d7e0e6270b366dc4200be26afd9f63b7e79286a35c688c57cbff55ac747d4c28bb80a2b2097b3b62ea439950d75dff"
|
||||
},
|
||||
{
|
||||
"name": "7",
|
||||
"entropy": "aae3ffc8605a975befefcea0a7a286642bc3b95fb37bd0eb0585a4cabf8b3d1e",
|
||||
"nonce": "9504c3c0c4310c1c0746a036c91d9034",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "2819bd3b0d216dad59ddd6c354c4518153a2b04374b07c49e64a8e4d055575dfbc9a8fcde68bd257ff1ba5c6000564b46d6dd7ecd9c5d684fd757df62d85211575d3562d7814008ab5c8bc00e7b5a649eae2318665b55d762de36eba00c2906c0e0ec8706edb493e51ca5eb4b9f015dc932f262f52a86b11c41e9a6d5b3bd431"
|
||||
},
|
||||
{
|
||||
"name": "8",
|
||||
"entropy": "b9475210b79b87180e746df704b3cbc7bf8424750e416a7fbb5ce3ef25a82cc6",
|
||||
"nonce": "24baf03599c10df6ef44065d715a93f7",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "ae12d784f796183c50db5a1a283aa35ed9a2b685dacea97c596ff8c294906d1b1305ba1f80254eb062b874a8dfffa3378c809ab2869aa51a4e6a489692284a25038908a347342175c38401193b8afc498077e10522bec5c70882b7f760ea5946870bd9fc72961eedbe8bff4fd58c7cc1589bb4f369ed0d3bf26c5bbc62e0b2b2"
|
||||
},
|
||||
{
|
||||
"name": "9",
|
||||
"entropy": "27838eb44ceccb4e36210703ebf38f659bc39dd3277cd76b7a9bcd6bc964b628",
|
||||
"nonce": "39cfe0210db2e7b0eb52a387476e7ea1",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "e5e72a53605d2aaa67832f97536445ab774dd9bff7f13a0d11fd27bf6593bfb52309f2d4f09d147192199ea584503181de87002f4ee085c7dc18bf32ce5315647a3708e6f404d6588c92b2dda599c131aa350d18c747b33dc8eda15cf40e95263d1231e1b4b68f8d829f86054d49cfdb1b8d96ab0465110569c8583a424a099a"
|
||||
},
|
||||
{
|
||||
"name": "10",
|
||||
"entropy": "d7129e4f47008ad60c9b5d081ff4ca8eb821a6e4deb91608bf4e2647835373a5",
|
||||
"nonce": "a72882773f78c2fc4878295840a53012",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "0cbf48585c5de9183b7ff76557f8fc9ebcfdfde07e588a8641156f61b7952725bbee954f87e9b937513b16bba0f2e523d095114658e00f0f3772175acfcb3240a01de631c19c5a834c94cc58d04a6837f0d2782fa53d2f9f65178ee9c837222494c799e64c60406069bd319549b889fa00a0032dd7ba5b1cc9edbf58de82bfcd"
|
||||
},
|
||||
{
|
||||
"name": "11",
|
||||
"entropy": "67fe5e300c513371976c80de4b20d4473889c9f1214bce718bc32d1da3ab7532",
|
||||
"nonce": "e256d88497738a33923aa003a8d7845c",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "b44660d64ef7bcebc7a1ab71f8407a02285c7592d755ae6766059e894f694373ed9c776c0cfc8594413eefb400ed427e158d687e28da3ecc205e0f7370fb089676bbb0fa591ec8d916c3d5f18a3eb4a417120705f3e2198154cd60648dbfcfc901242e15711cacd501b2c2826abe870ba32da785ed6f1fdc68f203d1ab43a64f"
|
||||
},
|
||||
{
|
||||
"name": "12",
|
||||
"entropy": "de8142541255c46d66efc6173b0fe3ffaf5936c897a3ce2e9d5835616aafa2cb",
|
||||
"nonce": "d01f9002c407127bc3297a561d89b81d",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "64d1020929d74716446d8a4e17205d0756b5264867811aa24d0d0da8644db25d5cde474143c57d12482f6bf0f31d10af9d1da4eb6d701bdd605a8db74fb4e77f79aaa9e450afda50b18d19fae68f03db1d7b5f1738d2fdce9ad3ee9461b58ee242daf7a1d72c45c9213eca34e14810a9fca5208d5c56d8066bab1586f1513de7"
|
||||
},
|
||||
{
|
||||
"name": "13",
|
||||
"entropy": "4a8e0bd90bdb12f7748ad5f147b115d7385bb1b06aee7d8b76136a25d779bcb7",
|
||||
"nonce": "7f3cce4af8c8ce3c45bdf23c6b181a00",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "320c7ca4bbeb7af977bc054f604b5086a3f237aa5501658112f3e7a33d2231f5536d2c85c1dad9d9b0bf7f619c81be4854661626839c8c10ae7fdc0c0b571be34b58d66da553676167b00e7d8e49f416aacb2926c6eb2c66ec98bffae20864cf92496db15e3b09e530b7b9648be8d3916b3c20a3a779bec7d66da63396849aaf"
|
||||
},
|
||||
{
|
||||
"name": "14",
|
||||
"entropy": "451ed024bc4b95f1025b14ec3616f5e42e80824541dc795a2f07500f92adc665",
|
||||
"nonce": "2f28e6ee8de5879db1eccd58c994e5f0",
|
||||
"pers": null,
|
||||
"add": [
|
||||
null,
|
||||
null
|
||||
],
|
||||
"expected": "3fb637085ab75f4e95655faae95885166a5fbb423bb03dbf0543be063bcd48799c4f05d4e522634d9275fe02e1edd920e26d9accd43709cb0d8f6e50aa54a5f3bdd618be23cf73ef736ed0ef7524b0d14d5bef8c8aec1cf1ed3e1c38a808b35e61a44078127c7cb3a8fd7addfa50fcf3ff3bc6d6bc355d5436fe9b71eb44f7fd"
|
||||
},
|
||||
{
|
||||
"name": "0 with additional data",
|
||||
"entropy": "d3cc4d1acf3dde0c4bd2290d262337042dc632948223d3a2eaab87da44295fbd",
|
||||
"nonce": "0109b0e729f457328aa18569a9224921",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"3c311848183c9a212a26f27f8c6647e40375e466a0857cc39c4e47575d53f1f6",
|
||||
"fcb9abd19ccfbccef88c9c39bfb3dd7b1c12266c9808992e305bc3cff566e4e4"
|
||||
],
|
||||
"expected": "9c7b758b212cd0fcecd5daa489821712e3cdea4467b560ef5ddc24ab47749a1f1ffdbbb118f4e62fcfca3371b8fbfc5b0646b83e06bfbbab5fac30ea09ea2bc76f1ea568c9be0444b2cc90517b20ca825f2d0eccd88e7175538b85d90ab390183ca6395535d34473af6b5a5b88f5a59ee7561573337ea819da0dcc3573a22974"
|
||||
},
|
||||
{
|
||||
"name": "1 with additional data",
|
||||
"entropy": "f97a3cfd91faa046b9e61b9493d436c4931f604b22f1081521b3419151e8ff06",
|
||||
"nonce": "11f3a7d43595357d58120bd1e2dd8aed",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"517289afe444a0fe5ed1a41dbbb5eb17150079bdd31e29cf2ff30034d8268e3b",
|
||||
"88028d29ef80b4e6f0fe12f91d7449fe75062682e89c571440c0c9b52c42a6e0"
|
||||
],
|
||||
"expected": "c6871cff0824fe55ea7689a52229886730450e5d362da5bf590dcf9acd67fed4cb32107df5d03969a66b1f6494fdf5d63d5b4d0d34ea7399a07d0116126d0d518c7c55ba46e12f62efc8fe28a51c9d428e6d371d7397ab319fc73ded4722e5b4f30004032a6128df5e7497ecf82ca7b0a50e867ef6728a4f509a8c859087039c"
|
||||
},
|
||||
{
|
||||
"name": "2 with additional data",
|
||||
"entropy": "0f2f23d64f481cabec7abb01db3aabf125c3173a044b9bf26844300b69dcac8b",
|
||||
"nonce": "9a5ae13232b43aa19cfe8d7958b4b590",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"ec4c7a62acab73385f567da10e892ff395a0929f959231a5628188ce0c26e818",
|
||||
"6b97b8c6b6bb8935e676c410c17caa8042aa3145f856d0a32b641e4ae5298648"
|
||||
],
|
||||
"expected": "7480a361058bd9afa3db82c9d7586e42269102013f6ec5c269b6d05f17987847748684766b44918fd4b65e1648622fc0e0954178b0279dfc9fa99b66c6f53e51c4860131e9e0644287a4afe4ca8e480417e070db68008a97c3397e4b320b5d1a1d7e1d18a95cfedd7d1e74997052bf649d132deb9ec53aae7dafdab55e6dae93"
|
||||
},
|
||||
{
|
||||
"name": "3 with additional data",
|
||||
"entropy": "53c56660c78481be9c63284e005fcc14fbc7fb27732c9bf1366d01a426765a31",
|
||||
"nonce": "dc7a14d0eb5b0b3534e717a0b3c64614",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"3aa848706ecb877f5bedf4ffc332d57c22e08747a47e75cff6f0fd1316861c95",
|
||||
"9a401afa739b8f752fddacd291e0b854f5eff4a55b515e20cb319852189d3722"
|
||||
],
|
||||
"expected": "5c0eb420e0bf41ce9323e815310e4e8303cd677a8a8b023f31f0d79f0ca15aeb636099a369fd074d69889865eac1b72ab3cbfebdb8cf460b00072802e2ec648b1349a5303be4ccaadd729f1a9ea17482fd026aaeb93f1602bc1404b9853adde40d6c34b844cf148bc088941ecfc1642c8c0b9778e45f3b07e06e21ee2c9e0300"
|
||||
},
|
||||
{
|
||||
"name": "4 with additional data",
|
||||
"entropy": "f63c804404902db334c54bb298fc271a21d7acd9f770278e089775710bf4fdd7",
|
||||
"nonce": "3e45009ea9cb2a36ba1aa4bf39178200",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"d165a13dc8cc43f3f0952c3f5d3de4136954d983683d4a3e6d2dc4c89bf23423",
|
||||
"75106bc86d0336df85097f6af8e80e2da59046a03fa65b06706b8bbc7ffc6785"
|
||||
],
|
||||
"expected": "6363139bba32c22a0f5cd23ca6d437b5669b7d432f786b8af445471bee0b2d24c9d5f2f93717cbe00d1f010cc3b9c515fc9f7336d53d4d26ba5c0d76a90186663c8582eb739c7b6578a3328bf68dc2cec2cd89b3a90201f6993adcc854df0f5c6974d0f5570765a15fe03dbce28942dd2fd16ba2027e68abac83926969349af8"
|
||||
},
|
||||
{
|
||||
"name": "5 with additional data",
|
||||
"entropy": "2aaca9147da66c176615726b69e3e851cc3537f5f279fe7344233d8e44cfc99d",
|
||||
"nonce": "4e171f080af9a6081bee9f183ac9e340",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"d75a2a6eb66c3833e50f5ec3d2e434cf791448d618026d0c360806d120ded669",
|
||||
"b643b74c15b37612e6577ed7ca2a4c67a78d560af9eb50a4108fca742e87b8d6"
|
||||
],
|
||||
"expected": "501dcdc977f4ba856f24eaa4968b374bebb3166b280334cb510232c31ebffde10fa47b7840ef3fe3b77725c2272d3a1d4219baf23e0290c622271edcced58838cf428f0517425d2e19e0d8c89377eecfc378245f283236fafa466c914b99672ceafab369e8889a0c866d8bd639db9fb797254262c6fd44cfa9045ad6340a60ef"
|
||||
},
|
||||
{
|
||||
"name": "6 with additional data",
|
||||
"entropy": "a2e4cd48a5cf918d6f55942d95fcb4e8465cdc4f77b7c52b6fae5b16a25ca306",
|
||||
"nonce": "bef036716440db6e6d333d9d760b7ca8",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"bfa591c7287f3f931168f95e38869441d1f9a11035ad8ea625bb61b9ea17591c",
|
||||
"c00c735463bca215adc372cb892b05e939bf669583341c06d4e31d0e5b363a37"
|
||||
],
|
||||
"expected": "e7d136af69926a5421d4266ee0420fd729f2a4f7c295d3c966bdfa05268180b508b8a2852d1b3a06fd2ab3e13c54005123ef319f42d0c6d3a575e6e7e1496cb28aacadbcf83740fba8f35fcee04bb2ed8a51db3d3362b01094a62fb57e33c99a432f29fce6676cffbbcc05107e794e75e44a02d5e6d9d748c5fbff00a0178d65"
|
||||
},
|
||||
{
|
||||
"name": "7 with additional data",
|
||||
"entropy": "95a67771cba69011a79776e713145d309edae56fad5fd6d41d83eaff89df6e5e",
|
||||
"nonce": "be5b5164e31ecc51ba6f7c3c5199eb33",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"065f693b229a7c4fd373cd15b3807552dd9bf98c5485cef361949d4e7d774b53",
|
||||
"9afb62406f0e812c4f156d58b19a656c904813c1b4a45a0029ae7f50731f8014"
|
||||
],
|
||||
"expected": "f61b61a6e79a41183e8ed6647899d2dc85cdaf5c3abf5c7f3bf37685946dc28f4923dc842f2d4326bd6ce0d50a84cb3ba869d72a36e246910eba6512ba36cd7ed3a5437c9245b00a344308c792b668b458d3c3e16dee2fbec41867da31084d46d8ec168de2148ef64fc5b72069abf5a6ada1ead2b7146bb793ff1c9c3690fa56"
|
||||
},
|
||||
{
|
||||
"name": "8 with additional data",
|
||||
"entropy": "a459e1815cbca4514ec8094d5ab2414a557ba6fe10e613c345338d0521e4bf90",
|
||||
"nonce": "62221392e2552e76cd0d36df6e6068eb",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"0a3642b02b23b3ef62c701a63401124022f5b896de86dab6e6c7451497aa1dcc",
|
||||
"c80514865901371c45ba92d9f95d50bb7c9dd1768cb3dfbc45b968da94965c6e"
|
||||
],
|
||||
"expected": "464e6977b8adaef307c9623e41c357013249c9ffd77f405f3925cebb69f151ce8fbb6a277164002aee7858fc224f6499042aa1e6322deee9a5d133c31d640e12a7487c731ba03ad866a24675badb1d79220c40be689f79c2a0be93cb4dada3e0eac4ab140cb91998b6f11953e68f2319b050c40f71c34de9905ae41b2de1c2f6"
|
||||
},
|
||||
{
|
||||
"name": "9 with additional data",
|
||||
"entropy": "252c2cad613e002478162861880979ee4e323025eebb6fb2e0aa9f200e28e0a1",
|
||||
"nonce": "d001bc9a8f2c8c242e4369df0c191989",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"9bcfc61cb2bc000034bb3db980eb47c76fb5ecdd40553eff113368d639b947fd",
|
||||
"8b0565c767c2610ee0014582e9fbecb96e173005b60e9581503a6dca5637a26e"
|
||||
],
|
||||
"expected": "e96c15fe8a60692b0a7d67171e0195ff6e1c87aab844221e71700d1bbee75feea695f6a740c9760bbe0e812ecf4061d8f0955bc0195e18c4fd1516ebca50ba6a6db86881737dbab8321707675479b87611db6af2c97ea361a5484555ead454defb1a64335de964fc803d40f3a6f057893d2afc25725754f4f00abc51920743dc"
|
||||
},
|
||||
{
|
||||
"name": "10 with additional data",
|
||||
"entropy": "8be0ca6adc8b3870c9d69d6021bc1f1d8eb9e649073d35ee6c5aa0b7e56ad8a5",
|
||||
"nonce": "9d1265f7d51fdb65377f1e6edd6ae0e4",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"da86167ac997c406bb7979f423986a84ec6614d6caa7afc10aff0699a9b2cf7f",
|
||||
"e4baa3c555950b53e2bfdba480cb4c94b59381bac1e33947e0c22e838a9534cf"
|
||||
],
|
||||
"expected": "64384ecc4ea6b458efc227ca697eac5510092265520c0a0d8a0ccf9ed3ca9d58074671188c6a7ad16d0b050cdc072c125d7298d3a31d9f044a9ee40da0089a84fea28cc7f05f1716db952fad29a0e779635cb7a912a959be67be2f0a4170aace2981802e2ff6467e5b46f0ffbff3b42ba5935fd553c82482ac266acf1cd247d7"
|
||||
},
|
||||
{
|
||||
"name": "11 with additional data",
|
||||
"entropy": "d43a75b6adf26d60322284cb12ac38327792442aa8f040f60a2f331b33ac4a8f",
|
||||
"nonce": "0682f8b091f811afacaacaec9b04d279",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"7fd3b8f512940da7de5d80199d9a7b42670c04a945775a3dba869546cbb9bc65",
|
||||
"2575db20bc7aafc2a90a5dabab760db851d754777bc9f05616af1858b24ff3da"
|
||||
],
|
||||
"expected": "0da7a8dc73c163014bf0841913d3067806456bbca6d5de92b85534c6545467313648d71ef17c923d090dc92cff8d4d1a9a2bb63e001dc2e8ab1a597999be3d6cf70ff63fee9985801395fbd4f4990430c4259fcae4fa1fcd73dc3187ccc102d04af7c07532885e5a226fc42809c48f22eecf4f6ab996ae4fcb144786957d9f41"
|
||||
},
|
||||
{
|
||||
"name": "12 with additional data",
|
||||
"entropy": "64352f236af5d32067a529a8fd05ba00a338c9de306371a0b00c36e610a48d18",
|
||||
"nonce": "df99ed2c7608c870624b962a5dc68acd",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"da416335e7aaf60cf3d06fb438735ce796aad09034f8969c8f8c3f81e32fef24",
|
||||
"a28c07c21a2297311adf172c19e83ca0a87731bdffb80548978d2d1cd82cf8a3"
|
||||
],
|
||||
"expected": "132b9f25868729e3853d3c51f99a3b5fae6d4204bea70890daf62e042b776a526c8fb831b80a6d5d3f153237df1fd39b6fd9137963f5516d9cdd4e3f9195c46e9972c15d3edc6606e3368bde1594977fb88d0ca6e6f5f3d057ccadc7d7dab77dfc42658a1e972aa446b20d418286386a52dfc1c714d2ac548713268b0b709729"
|
||||
},
|
||||
{
|
||||
"name": "13 with additional data",
|
||||
"entropy": "282f4d2e05a2cd30e9087f5633089389449f04bac11df718c90bb351cd3653a5",
|
||||
"nonce": "90a7daf3c0de9ea286081efc4a684dfb",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"2630b4ccc7271cc379cb580b0aaede3d3aa8c1c7ba002cf791f0752c3d739007",
|
||||
"c31d69de499f1017be44e3d4fa77ecebc6a9b9934749fcf136f267b29115d2cc"
|
||||
],
|
||||
"expected": "c899094520e0197c37b91dd50778e20a5b950decfb308d39f1db709447ae48f6101d9abe63a783fbb830eec1d359a5f61a2013728966d349213ee96382614aa4135058a967627183810c6622a2158cababe3b8ab99169c89e362108bf5955b4ffc47440f87e4bad0d36bc738e737e072e64d8842e7619f1be0af1141f05afe2d"
|
||||
},
|
||||
{
|
||||
"name": "14 with additional data",
|
||||
"entropy": "13c752b9e745ce77bbc7c0dbda982313d3fe66f903e83ebd8dbe4ff0c11380e9",
|
||||
"nonce": "f1a533095d6174164bd7c82532464ae7",
|
||||
"pers": null,
|
||||
"add": [
|
||||
"4f53db89b9ba7fc00767bc751fb8f3c103fe0f76acd6d5c7891ab15b2b7cf67c",
|
||||
"582c2a7d34679088cca6bd28723c99aac07db46c332dc0153d1673256903b446"
|
||||
],
|
||||
"expected": "6311f4c0c4cd1f86bd48349abb9eb930d4f63df5e5f7217d1d1b91a71d8a6938b0ad2b3e897bd7e3d8703db125fab30e03464fad41e5ddf5bf9aeeb5161b244468cfb26a9d956931a5412c97d64188b0da1bd907819c686f39af82e91cfeef0cbffb5d1e229e383bed26d06412988640706815a6e820796876f416653e464961"
|
||||
}
|
||||
]
|
||||
+1024
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user