Skip to content

feat(sdk-core): add EdDSA MPCv2 offline signing helper utils#8793

Open
vibhavgo wants to merge 1 commit into
masterfrom
WCI-386/eddsa-util-helper
Open

feat(sdk-core): add EdDSA MPCv2 offline signing helper utils#8793
vibhavgo wants to merge 1 commit into
masterfrom
WCI-386/eddsa-util-helper

Conversation

@vibhavgo
Copy link
Copy Markdown
Contributor

Adds shared private utility methods to EddsaMPCv2Utils that will be used across all three createOfflineRound1/2/3Share methods. These are prerequisite helpers that centralize transaction payload extraction, GPG key handling, and authenticated data validation to prevent code duplication.

  • Add domain-separator constant MPS_DSG_SIGNING_USER_GPG_KEY for adata prefixes
  • Add getSignableHexAndDerivationPath() to extract signableHex and derivationPath from txRequest
  • Add getBitgoAndUserGpgKeys() to decrypt user GPG keys with v1 (SJCL) and v2 (Argon2id) envelope support
  • Add validateAdata() to validate authenticated data matches cyphertext adata
  • Import isV2Envelope from baseTypes for envelope version detection
  • Add comprehensive test coverage for all three helper methods in createKeychains.ts

Ticket: WCI-386

@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 18, 2026

WCI-386

@vibhavgo vibhavgo changed the title feat(sdk-core): add EdDSA MPCv2 offline signing helper infrastructure feat(sdk-core): add EdDSA MPCv2 offline signing helper util May 18, 2026
@vibhavgo vibhavgo changed the title feat(sdk-core): add EdDSA MPCv2 offline signing helper util feat(sdk-core): add EdDSA MPCv2 offline signing helper utils May 18, 2026
@vibhavgo vibhavgo force-pushed the WCI-386/eddsa-util-helper branch from 73179bb to f4ebbae Compare May 18, 2026 10:40
@vibhavgo vibhavgo marked this pull request as ready for review May 18, 2026 11:04
@vibhavgo vibhavgo requested review from a team as code owners May 18, 2026 11:04
@vibhavgo vibhavgo requested review from Marzooqa and bdesoky May 18, 2026 11:04
Comment thread modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsaMPCv2.ts Outdated
Comment thread modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsaMPCv2.ts Outdated
Comment thread modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsaMPCv2.ts Outdated
Comment thread modules/sdk-core/src/bitgo/utils/tss/eddsa/eddsaMPCv2.ts Outdated
* @returns void
* @throws {Error} if the adata or cyphertext is invalid
*/
private validateAdata(adata: string, cyphertext: string, roundDomainSeparator: string): void {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is byte-for-byte identical to EcdsaMPCv2Utils.validateAdata. Both classes share the same baseTSSUtils<KeyShare> ancestor, so this should be lifted there to eliminate the duplication. This is the most straightforward extraction — same signature, same body, no ECDSA/EdDSA differences.

Comment thread modules/bitgo/test/v2/unit/internal/tssUtils/eddsaMPCv2/createKeychains.ts Outdated
@vibhavgo vibhavgo force-pushed the WCI-386/eddsa-util-helper branch from f4ebbae to 2188290 Compare May 19, 2026 10:10
@vibhavgo vibhavgo requested a review from Marzooqa May 19, 2026 10:10
Comment thread modules/bitgo/test/v2/unit/internal/tssUtils/eddsaMPCv2/createKeychains.ts Outdated
@vibhavgo vibhavgo force-pushed the WCI-386/eddsa-util-helper branch from 2188290 to 6340d35 Compare May 19, 2026 15:48
@vibhavgo vibhavgo requested a review from Marzooqa May 19, 2026 15:49
});
});

describe('External Signing Helpers', function () {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These utility helper tests (getSignableHexAndDerivationPath, validateAdata, getBitgoAndUserGpgKeys) do not belong in createKeychains.ts — this file is for testing the keychain creation flow.

More importantly, these methods now live on baseTSSUtils in sdk-core, so they should be tested there, not through an EdDSA subclass in the bitgo module. The right place is a new dedicated file: modules/sdk-core/test/unit/bitgo/utils/tss/baseTSSUtils.ts, consistent with how addressVerification.ts, ecdsaMPCv2.ts, and eddsaMPCv2.ts each have their own focused files in that directory.

Comment thread modules/sdk-core/src/bitgo/utils/tss/ecdsa/ecdsaMPCv2.ts
@vibhavgo vibhavgo force-pushed the WCI-386/eddsa-util-helper branch from 6340d35 to 2facaea Compare May 20, 2026 12:16
Ticket: WCI-386

Centralizes shared MPCv2 helper logic in BaseTssUtils for reuse across
ECDSA and EdDSA, and moves misplaced helper tests from the EdDSA keychain
creation test to a dedicated BaseTssUtils test file in sdk-core.

- Move getSignableHexAndDerivationPath() into BaseTssUtils for shared
  ECDSA and EdDSA MPCv2 transaction extraction
- Move validateAdata() into BaseTssUtils to eliminate duplicated
  authenticated data validation
- Move getBitgoAndUserGpgKeys() into BaseTssUtils with v1 (SJCL)
  and v2 (Argon2id) envelope support; accepts a userGpgKeyDomainSeparator arg
- Remove redundant private getBitgoAndUserGpgKeys() from EcdsaMPCv2Utils
  and EddsaMPCv2Utils; delegate to base class
- Remove unused MPS_DSG_SIGNING_USER_GPG_KEY constant and isV2Envelope
  import from EddsaMPCv2Utils
- Remove misplaced External Signing Helpers tests from createKeychains.ts
- Add sdk-core/test/unit/bitgo/utils/tss/baseTSSUtils.ts with lean,
  strictly typed tests for all extracted helpers and ECDSA delegation

Co-authored-by: Cursor <cursoragent@cursor.com>
@vibhavgo vibhavgo force-pushed the WCI-386/eddsa-util-helper branch from 2facaea to 53a09b0 Compare May 20, 2026 12:33
@vibhavgo vibhavgo requested a review from Marzooqa May 20, 2026 12:38
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