Skip to content

Commit

Permalink
use native uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
d4mr committed Feb 22, 2025
1 parent 1ec133d commit 3624147
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib/keystore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
createDecipheriv,
scryptSync,
timingSafeEqual,
} from "crypto";
import { v4 as uuidv4 } from "uuid";
randomUUID,
} from "node:crypto";
import { keccak256 } from "ox/Hash";
import { Hex } from "ox";

Expand Down Expand Up @@ -42,7 +42,7 @@ function normalizeHexString(hex: string): Buffer {

function ensureBuffer(
value: Buffer | string,
encoding: BufferEncoding = "hex",
encoding: BufferEncoding = "hex"
): Buffer {
if (Buffer.isBuffer(value)) return value;
return Buffer.from(value, encoding);
Expand Down Expand Up @@ -81,7 +81,7 @@ function generateKeystore(privateKey: string, password: string): Keystore {
// Create keystore object with proper hex encoding
const keystore: Keystore = {
version: 3,
id: uuidv4(),
id: randomUUID().toString(),
crypto: {
cipher: "aes-128-ctr",
ciphertext: ciphertext.toString("hex"),
Expand Down Expand Up @@ -110,7 +110,7 @@ function generateKeystore(privateKey: string, password: string): Keystore {

function decryptKeystore(
keystoreData: string | Keystore,
password: string,
password: string
): string {
if (!password || typeof password !== "string") {
throw new Error("Password must be a non-empty string");
Expand Down Expand Up @@ -155,7 +155,7 @@ function decryptKeystore(
const decipher = createDecipheriv(
"aes-128-ctr",
derivedKey.slice(0, 16),
ivBuffer,
ivBuffer
);

const privateKey = Buffer.concat([
Expand Down

0 comments on commit 3624147

Please sign in to comment.