diff --git a/packages/crypto/src/p256/keypair.ts b/packages/crypto/src/p256/keypair.ts index 4bc5a5c5e74..a858fd77093 100644 --- a/packages/crypto/src/p256/keypair.ts +++ b/packages/crypto/src/p256/keypair.ts @@ -1,7 +1,10 @@ import { p256 } from '@noble/curves/p256' import { sha256 } from '@noble/hashes/sha256' import { SupportedEncodings } from 'uint8arrays/to-string' -import { fromString, toString } from 'uint8arrays' +import { + fromString as ui8FromString, + toString as ui8ToString, +} from 'uint8arrays' import * as did from '../did' import { P256_JWT_ALG } from '../const' @@ -33,7 +36,7 @@ export class P256Keypair implements Keypair { ): Promise { const { exportable = false } = opts || {} const privKeyBytes = - typeof privKey === 'string' ? fromString(privKey, 'hex') : privKey + typeof privKey === 'string' ? ui8FromString(privKey, 'hex') : privKey return new P256Keypair(privKeyBytes, exportable) } @@ -42,7 +45,7 @@ export class P256Keypair implements Keypair { } publicKeyStr(encoding: SupportedEncodings = 'base64pad'): string { - return toString(this.publicKey, encoding) + return ui8ToString(this.publicKey, encoding) } did(): string { diff --git a/packages/crypto/src/secp256k1/keypair.ts b/packages/crypto/src/secp256k1/keypair.ts index 4fc2b10515f..4391e01add9 100644 --- a/packages/crypto/src/secp256k1/keypair.ts +++ b/packages/crypto/src/secp256k1/keypair.ts @@ -1,6 +1,9 @@ import { secp256k1 as k256 } from '@noble/curves/secp256k1' import { sha256 } from '@noble/hashes/sha256' -import { fromString, toString } from 'uint8arrays' +import { + fromString as ui8FromString, + toString as ui8ToString, +} from 'uint8arrays' import { SupportedEncodings } from 'uint8arrays/to-string' import { SECP256K1_JWT_ALG } from '../const' @@ -33,7 +36,7 @@ export class Secp256k1Keypair implements Keypair { ): Promise { const { exportable = false } = opts || {} const privKeyBytes = - typeof privKey === 'string' ? fromString(privKey, 'hex') : privKey + typeof privKey === 'string' ? ui8FromString(privKey, 'hex') : privKey return new Secp256k1Keypair(privKeyBytes, exportable) } @@ -42,7 +45,7 @@ export class Secp256k1Keypair implements Keypair { } publicKeyStr(encoding: SupportedEncodings = 'base64pad'): string { - return toString(this.publicKey, encoding) + return ui8ToString(this.publicKey, encoding) } did(): string {