feat: ds
This commit is contained in:
@@ -72,6 +72,57 @@ class EthKeystoreTest extends TestCase
|
||||
$this->assertSame($phrase, $got);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function python_scrypt_high_n_roundtrip(): void
|
||||
{
|
||||
if (! EthKeystore::scryptReady()) {
|
||||
$this->markTestSkipped('python3 hashlib/pycryptodome scrypt is unavailable');
|
||||
}
|
||||
$phrase = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
|
||||
$password = random_bytes(32);
|
||||
$utc = EthKeystore::encrypt($phrase, $password, ['n' => 256, 'r' => 8, 'p' => 1]);
|
||||
$this->assertSame($phrase, EthKeystore::decrypt($utc, $password));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function aes_256_ctr_unlocks_with_walletcore_mac(): void
|
||||
{
|
||||
$phrase = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
|
||||
$password = 'trust-aes256';
|
||||
$salt = random_bytes(32);
|
||||
$iv = random_bytes(16);
|
||||
$derived = hash_pbkdf2('sha256', $password, $salt, 16, 32, true);
|
||||
$ciphertext = openssl_encrypt($phrase, 'aes-256-ctr', $derived, OPENSSL_RAW_DATA, $iv);
|
||||
$this->assertIsString($ciphertext);
|
||||
$utc = [
|
||||
'version' => 3,
|
||||
'crypto' => [
|
||||
'cipher' => 'aes-256-ctr',
|
||||
'cipherparams' => ['iv' => bin2hex($iv)],
|
||||
'ciphertext' => bin2hex($ciphertext),
|
||||
'kdf' => 'pbkdf2',
|
||||
'kdfparams' => [
|
||||
'c' => 16,
|
||||
'dklen' => 32,
|
||||
'prf' => 'hmac-sha256',
|
||||
'salt' => bin2hex($salt),
|
||||
],
|
||||
'mac' => bin2hex(hex2bin(\kornrunner\Keccak::hash($derived.$ciphertext, 256))),
|
||||
],
|
||||
];
|
||||
$this->assertSame($phrase, EthKeystore::decrypt($utc, $password));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function unlock_accepts_json_mnemonic_payload(): void
|
||||
{
|
||||
$phrase = 'abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about';
|
||||
$password = 'json-payload';
|
||||
$utc = EthKeystore::encrypt(json_encode(['mnemonic' => $phrase]), $password, ['n' => 16, 'r' => 1, 'p' => 1]);
|
||||
$decrypt = new DsKeystoreDecrypt;
|
||||
$this->assertSame($phrase, $decrypt->unlock($utc, [$password]));
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function bitpie_entropy_ascii_hex_unlocks_phrase(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user