Skip to content

fix: scalar bytes for js secp256k1#220

Merged
amagyar-iohk merged 2 commits intomainfrom
fix/js-normalize-bytes
Apr 16, 2026
Merged

fix: scalar bytes for js secp256k1#220
amagyar-iohk merged 2 commits intomainfrom
fix/js-normalize-bytes

Conversation

@amagyar-iohk
Copy link
Copy Markdown
Contributor

@amagyar-iohk amagyar-iohk commented Apr 2, 2026

Description:

Found a bug in sdk-ts that randomly we would get 31 bytes instead 32 for secp256k1

KeyInitializationError: 181: Invalid byte size: 32 exptected, 31 given
      at new _Secp256k1PrivateKey (sdk-ts/packages/lib/sdk/src/apollo/utils/Secp256k1PrivateKey.ts:44:17)
      at _Secp256k1PrivateKey.derive (sdk-ts/packages/lib/sdk/src/apollo/utils/Secp256k1PrivateKey.ts:72:11)
      at _class7.createPrivateKey (sdk-ts/packages/lib/sdk/src/apollo/Apollo.ts:370:15)
      at CreatePrismDID.run (sdk-ts/packages/lib/sdk/src/edge-agent/didFunctions/CreatePrismDID.ts:35:33)
      at async Proxy.run (sdk-ts/packages/lib/sdk/src/utils/tasks.ts:65:35)
      at async sdk-ts/integration-tests/e2e-tests/src/workflow/EdgeAgentWorkflow.ts:236:11

This fix normalizes the bytes with 0 left padding

Checklist:

  • My PR follows the contribution guidelines of this project
  • My PR is free of third-party dependencies that don't comply with the Allowlist
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked the PR title to follow the conventional commit specification

Signed-off-by: Allain Magyar <allain.magyar@iohk.io>
@amagyar-iohk amagyar-iohk requested a review from a team as a code owner April 2, 2026 17:01
Copy link
Copy Markdown

@FabioPinheiro FabioPinheiro left a comment

Choose a reason for hiding this comment

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

LGTM but lets also ask @goncalo-frade-iohk

Signed-off-by: Allain Magyar <allain.magyar@iohk.io>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 2, 2026

@amagyar-iohk amagyar-iohk merged commit 227eb17 into main Apr 16, 2026
8 of 9 checks passed
@amagyar-iohk amagyar-iohk deleted the fix/js-normalize-bytes branch April 16, 2026 18:41
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.

3 participants