Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replaced stablelib with noble libs #216

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

ganchoradkov
Copy link
Member

@ganchoradkov ganchoradkov commented Jan 7, 2025

Based on #185, opened new PR due to conflicts in the initial PR
Replaced

  • aes-js -> @noble/ciphers
  • hash.js -> @noble/hashes
  • @stablelib/x25519 -> @noble/curves
  • @stablelib/ed25519 -> @noble/curves
  • randombytes -> @noble/hashes

Canaries

Copy link
Contributor

@devceline devceline left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM since it's validated by the PR in the monorepo

Comment on lines 3 to 5
export function randomBytes(length: number): Uint8Array {
const buf = crypto.randomBytes(length);
return bufferToArray(buf);
return rb(length);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this method anymore

Comment on lines 23 to 33
export function fallbackSha256(msg: Uint8Array): Uint8Array {
const result = hash.sha256().update(msg).digest(HEX_ENC);
return hexToArray(result);
return sha256(msg);
}

export function fallbackSha512(msg: Uint8Array): Uint8Array {
const result = hash.sha512().update(msg).digest(HEX_ENC);
return hexToArray(result);
return sha512(msg);
}

export function fallbackRipemd160(msg: Uint8Array): Uint8Array {
const result = hash.ripemd160().update(msg).digest(HEX_ENC);
return hexToArray(result);
return ripemd160(msg);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These methods are no longer needed

Copy link
Contributor

@Cali93 Cali93 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see the reduction in boilerplate code

@ganchoradkov ganchoradkov merged commit 23f3ac0 into master Jan 20, 2025
23 checks passed
@ganchoradkov ganchoradkov deleted the refactor/noble-libs branch January 20, 2025 07:24
@paulmillr
Copy link

@ganchoradkov I suggest to use newly released 1.7.1 and 1.2.1. These will be used in ethereum-cryptoraphy so you will benefit from deduplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants