Skip to content

Commit 236e222

Browse files
committed
remove node fs dependency
1 parent 6232891 commit 236e222

File tree

1 file changed

+0
-18
lines changed

1 file changed

+0
-18
lines changed

src/crypto_utils.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import forge from 'node-forge'
22
import {BaseWallet, ethers, getBytes, SigningKey, solidityPackedKeccak256} from "ethers"
3-
import * as fs from "node:fs";
43

54
const BLOCK_SIZE = 16 // AES block size in bytes
65
const HEX_BASE = 16
@@ -204,23 +203,6 @@ export function generateAesKey(): string {
204203
return forge.random.getBytesSync(BLOCK_SIZE)
205204
}
206205

207-
export function loadAesKey(filePath: string): Buffer {
208-
const hexKey = fs.readFileSync(filePath, 'utf8').trim();
209-
const key = Buffer.from(hexKey, 'hex');
210-
if (key.length !== BLOCK_SIZE) {
211-
throw new Error(`Invalid key length: ${key.length} bytes, must be ${BLOCK_SIZE} bytes`);
212-
}
213-
return key;
214-
}
215-
216-
export function writeAesKey(filePath: string, key: Buffer): void {
217-
if (key.length !== BLOCK_SIZE) {
218-
throw new Error(`Invalid key length: ${key.length} bytes, must be ${BLOCK_SIZE} bytes`);
219-
}
220-
const hexKey = key.toString('hex');
221-
fs.writeFileSync(filePath, hexKey);
222-
}
223-
224206
export function encodeString(str: string): Uint8Array {
225207
return new Uint8Array([...str.split('').map((char) => parseInt(char.codePointAt(0)?.toString(HEX_BASE)!, HEX_BASE))])
226208
}

0 commit comments

Comments
 (0)