Skip to content

Commit

Permalink
style(crypto): rename imports from uint8arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieusieben committed Feb 22, 2024
1 parent 1195635 commit 49766e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions packages/crypto/src/p256/keypair.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -33,7 +36,7 @@ export class P256Keypair implements Keypair {
): Promise<P256Keypair> {
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)
}

Expand All @@ -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 {
Expand Down
9 changes: 6 additions & 3 deletions packages/crypto/src/secp256k1/keypair.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -33,7 +36,7 @@ export class Secp256k1Keypair implements Keypair {
): Promise<Secp256k1Keypair> {
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)
}

Expand All @@ -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 {
Expand Down

0 comments on commit 49766e3

Please sign in to comment.