Skip to content

Commit

Permalink
Update DidKey.php
Browse files Browse the repository at this point in the history
  • Loading branch information
puklipo committed Dec 2, 2024
1 parent 2a68627 commit 68add66
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Crypto/DidKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static function parse(string $didkey): array
// decode base58btc
$keyBytes = Multibase::decode($key);

$alg_prefix = Str::substr($keyBytes, start: 0, length: 2, encoding: '8bit');
$alg_prefix = substr($keyBytes, offset: 0, length: 2);

$alg = match ($alg_prefix) {
self::p256prefix() => 'ES256',
Expand All @@ -61,10 +61,10 @@ public static function parse(string $didkey): array
};

// remove alg prefix
$keyBytes = Str::substr($keyBytes, start: 2, encoding: '8bit');
$keyBytes = substr($keyBytes, offset: 2, length: null);

// compressed key length must be 33.
if (Str::length($keyBytes, encoding: '8bit') !== 33) {
if (strlen($keyBytes) !== 33) {
throw new InvalidArgumentException();
}

Expand Down

0 comments on commit 68add66

Please sign in to comment.