Skip to content

fix: replace noble/curves by metadata-helpers#180

Merged
chaitanyapotti merged 3 commits intomasterfrom
fix/replace-noble/curves-helper-by-metadat-helper
Mar 5, 2026
Merged

fix: replace noble/curves by metadata-helpers#180
chaitanyapotti merged 3 commits intomasterfrom
fix/replace-noble/curves-helper-by-metadat-helper

Conversation

@hieu-w
Copy link
Contributor

@hieu-w hieu-w commented Mar 5, 2026

Jira Link

N/A

Description

Replaces direct imports from @noble/curves with utilities re-exported by @toruslabs/metadata-helpers, consolidating cryptographic utility usage across the codebase.

Changes:

  • package.json — Removed @noble/curves from direct dependencies (it remains a transitive dependency via metadata-helpers).
  • src/helpers/common.ts — Replaced nobleHexToBytes, nobleBytesToHex, and nobleConcatBytes (from @noble/curves/utils.js) with hexToBytes, bytesToHex, and concatBytes from @toruslabs/metadata-helpers. Removed the manual concatBytes re-export alias. concatBytes is now imported and re-exported directly from metadata-helpers.
  • src/helpers/keyUtils.ts — Replaced import { mod } from "@noble/curves/abstract/modular.js" and import { hexToBytes } from "@noble/curves/utils.js" with imports from @toruslabs/metadata-helpers.
  • src/helpers/metadataUtils.ts — Updated concatBytes call sites from variadic args (concatBytes(a, b)) to the array-based API (concatBytes([a, b])) to match the metadata-helpers signature.
  • src/interfaces.ts — Replaced import type { AffinePoint as AffinePointCurve } from "@noble/curves/abstract/curve.js" with the AffinePoint type from @toruslabs/metadata-helpers. Removed the local type alias.

How has this been tested?

  • Ran existing unit and integration test suites (npm test) against sapphire devnet, testnet, and onekey test files.
  • Verified ECIES encode/decode round-trip consistency (encParamsBufToHex / encParamsHexToBuf) with metadata-helpers' bytesToHex and hexToBytes.

Screenshots (if appropriate)

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • My code follows the code style of this project. (run lint)
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Note

Medium Risk
Touches cryptographic byte/hex conversion and signature/ECIES serialization paths; behavior should be equivalent but small encoding differences could break interoperability. Test-timeout changes are low risk but may mask new hangs.

Overview
Switches crypto helpers over to @toruslabs/metadata-helpers and drops direct @noble/curves usage. common.ts, keyUtils.ts, and interfaces.ts now import/re-export hexToBytes, bytesToHex, concatBytes, mod, and AffinePoint from metadata-helpers, and ECIES encode/decode helpers use these conversions.

Updates metadata signing concatenation and test config. metadataUtils.ts updates concatBytes calls to the array-based API, .mocharc.yaml is removed, Vitest node testTimeout is increased to 60s and per-test timeouts are removed, and the package version bumps to 17.1.1 while removing @noble/curves from dependencies (lockfile updated).

Written by Cursor Bugbot for commit f099ad1. This will update automatically on new commits. Configure here.

@hieu-w hieu-w requested a review from chaitanyapotti March 5, 2026 10:39
chaitanyapotti
chaitanyapotti previously approved these changes Mar 5, 2026
chaitanyapotti
chaitanyapotti previously approved these changes Mar 5, 2026
lwin-kyaw
lwin-kyaw previously approved these changes Mar 5, 2026
@chaitanyapotti chaitanyapotti dismissed stale reviews from lwin-kyaw and themself via f099ad1 March 5, 2026 11:01
Copy link
Contributor

@arch1995 arch1995 left a comment

Choose a reason for hiding this comment

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

lgtm

@chaitanyapotti chaitanyapotti merged commit c5c3864 into master Mar 5, 2026
5 checks passed
@chaitanyapotti chaitanyapotti deleted the fix/replace-noble/curves-helper-by-metadat-helper branch March 5, 2026 11:02
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