Skip to content

fix: replace deprecated @noble/curves and @noble/hashes APIs#386

Merged
marc0olo merged 4 commits intomainfrom
fix/noble-deprecations
Apr 22, 2026
Merged

fix: replace deprecated @noble/curves and @noble/hashes APIs#386
marc0olo merged 4 commits intomainfrom
fix/noble-deprecations

Conversation

@marc0olo
Copy link
Copy Markdown
Member

Summary

  • Replace all deprecated @noble/curves APIs in utils.ts:
    • ProjPointTypeWeierstrassPoint (exported G1Point/G2Point types)
    • @noble/hashes/sha256@noble/hashes/sha2
    • randomPrivateKey()randomSecretKey()
    • toRawBytes(true)toBytes(true) (7 sites)
    • G1/G2.ProjectivePointG1/G2.Point (all occurrences)
    • Point.fromPrivateKey(sk)Point.BASE.multiply(Point.Fn.fromBytes(sk))
    • G1.normPrivateKeyToScalar()G1.Point.Fn.fromBytes()
    • verifyShortSignature()shortSignatures.hash() + shortSignatures.verify()
    • G2.CURVE.htfDefaults + manual hash_to_field()G2.hashToScalar()
  • Remove stale JSDoc @example blocks on KeyManager and EncryptedMaps (wrong types, non-existent methods) and the IBE usage example in src/index.ts
  • Fix three method-level JSDoc examples using snake_case canister names instead of the camelCase TypeScript wrappers (get_user_rightsgetUserRights, remove_userremoveUser)

Test plan

  • pnpm run build passes
  • pnpm run lint passes

🤖 Generated with Claude Code

marc0olo and others added 3 commits April 22, 2026 17:42
Drop class-level @example blocks on KeyManager and EncryptedMaps (strings
passed where Uint8Array required, wrong method names) and the IBE usage
example in src/index.ts (references EncryptedKey and deriveKey which do
not exist, and uses the old ic_vetkd_sdk_utils package name).

Fix three method-level examples that called snake_case canister method
names directly instead of the camelCase TypeScript wrappers:
  get_user_rights  → getUserRights  (key_manager, encrypted_maps)
  remove_user      → removeUser     (encrypted_maps)
- ProjPointType → WeierstrassPoint
- @noble/hashes/sha256 → @noble/hashes/sha2
- randomPrivateKey() → randomSecretKey()
- toRawBytes(true) → toBytes(true) (7 sites)
- G1/G2.ProjectivePoint → G1/G2.Point (all occurrences)
- Point.fromPrivateKey(sk) → Point.BASE.multiply(Point.Fn.fromBytes(sk))
- G1.normPrivateKeyToScalar() → G1.Point.Fn.fromBytes()
- verifyShortSignature() → shortSignatures.hash() + shortSignatures.verify()
- G2.CURVE.htfDefaults + manual hash_to_field() → G2.hashToScalar()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marc0olo marc0olo force-pushed the fix/noble-deprecations branch from 4e02c19 to ae33563 Compare April 22, 2026 16:35
@marc0olo
Copy link
Copy Markdown
Member Author

Note on package-lock.json: The lock file in the repo root was stale — it was missing @icp-sdk/core@5.3.0 and had @noble/curves@1.9.6 instead of 1.9.7. This caused CI to resolve different package versions than local, leading to inconsistent prettier/ESLint behavior. The lock file update here is a prerequisite to get a reproducible lint result; it has no effect on the published library.

@marc0olo marc0olo requested a review from randombit April 22, 2026 17:01
Copy link
Copy Markdown
Contributor

@randombit randombit left a comment

Choose a reason for hiding this comment

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

lgtm

@marc0olo marc0olo merged commit a291986 into main Apr 22, 2026
9 checks passed
@marc0olo marc0olo deleted the fix/noble-deprecations branch April 22, 2026 18:18
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.

2 participants