Skip to content

Commit

Permalink
fix: fix types and changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
twhy committed Jun 7, 2024
1 parent 12cbbf7 commit d17df9e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .changeset/gorgeous-yaks-notice.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"@ckb-lumos/hd": minor
---

replace node crypto methods with @noble/hashes and @noble/ciphers
refactor: replace node crypto methods with @noble/hashes and @noble/ciphers
22 changes: 14 additions & 8 deletions packages/hd/src/keystore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,33 @@ export class InvalidKeystore extends Error {
const CIPHER = "aes-128-ctr";
const CKB_CLI_ORIGIN = "ckb-cli";

interface CipherParams {
type CipherParams = {
iv: HexStringWithoutPrefix;
}
};

interface KdfParams {
type KdfParams = {
dklen: number;
n: number;
r: number;
p: number;
salt: HexStringWithoutPrefix;
}
};

interface Crypto {
type Crypto = {
cipher: string;
cipherparams: CipherParams;
ciphertext: HexStringWithoutPrefix;
kdf: string;
kdfparams: KdfParams;
mac: HexStringWithoutPrefix;
}
};

type ScryptOptions = {
N: number;
r: number;
p: number;
maxmem: number;
};

// The parameter r ("blockSize")
// specifies the block size.
Expand Down Expand Up @@ -225,8 +232,7 @@ export default class Keystore {
return Buffer.from(hash).toString("hex");
}

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
static scryptOptions(kdfparams: KdfParams) {
static scryptOptions(kdfparams: KdfParams): ScryptOptions {
return {
N: kdfparams.n,
r: kdfparams.r,
Expand Down

0 comments on commit d17df9e

Please sign in to comment.