Skip to content

CSHLD-1444: Add RedPallas DKG to @bitgo/sdk-lib-mpc - #9469

Merged
Ranjna-G merged 1 commit into
masterfrom
CSHLD-1444-add-redpallas-dkg
Aug 12, 2026
Merged

CSHLD-1444: Add RedPallas DKG to @bitgo/sdk-lib-mpc#9469
Ranjna-G merged 1 commit into
masterfrom
CSHLD-1444-add-redpallas-dkg

Conversation

@Ranjna-G

Copy link
Copy Markdown
Contributor

Summary

Expose a TypeScript RedPallas (Pallas/Orchard FROST) DKG wrapper in @bitgo/sdk-lib-mpc on top of @bitgo/wasm-mps, so OVC and tests can run the user/backup sides of a 2-of-3 keygen ceremony.

Linear: CSHLD-1444

Changes

  • Bump @bitgo/wasm-mps to 1.11.0 (adds redpallas_dkg_* bindings)
  • Add src/tss/redpallas-mps/ with RedPallasDKG class — initDkggetFirstMessagehandleIncomingMessagesgetKeyShare / getSharePublicKey / getReducedKeyShare; session export/restore
  • Add types and message serialization helpers
  • Export from tss/index.ts
  • Add unit tests (protocol, per-round state, seeds, reduced shares, session)

Test Plan

  • Unit tests covering full DKG protocol, per-round state transitions, seed determinism, reduced key shares, and session export/restore

CLOSES TICKET: CSHLD-1444

@linear-code

linear-code Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

CSHLD-1444

@Ranjna-G
Ranjna-G force-pushed the CSHLD-1444-add-redpallas-dkg branch from df7a94f to c7d2a1a Compare August 11, 2026 10:44
Expose a TypeScript RedPallas (Pallas/Orchard FROST) DKG wrapper
on top of @bitgo/wasm-mps so OVC and tests can run the user/backup
sides of a 2-of-3 keygen ceremony. Bumps wasm-mps to 1.11.0.

Ticket: CSHLD-1444
@Ranjna-G
Ranjna-G force-pushed the CSHLD-1444-add-redpallas-dkg branch from c7d2a1a to 73c1177 Compare August 11, 2026 10:46
@Ranjna-G

Copy link
Copy Markdown
Contributor Author

@claude review

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Claude finished @Ranjna-G's task —— View job


PR Review: CSHLD-1444 Add RedPallas DKG

Reviewing the RedPallas DKG implementation for @bitgo/sdk-lib-mpc.

Todo List:

  • Read repository guidelines (CLAUDE.md)
  • Examine main DKG implementation
  • Review type definitions and utilities
  • Check test coverage and quality
  • Verify package dependencies
  • Provide comprehensive review feedback

Code Review Summary

This PR adds a well-structured RedPallas (Zcash Ironwood) DKG implementation that follows the established patterns in the codebase. The implementation is comprehensive with excellent test coverage and proper TypeScript typing.

✅ Strengths

Architecture & Design

  • Consistent with existing patterns: Mirrors the structure of the EdDSA MPS DKG class in modules/sdk-lib-mpc/src/tss/redpallas-mps/dkg.ts:13, maintaining codebase consistency
  • Clear state management: Well-defined state transitions through RedPallasDkgState enum with explicit validation
  • Proper abstraction: Clean separation between WASM bindings and TypeScript wrapper

Security & Error Handling

  • Input validation: Comprehensive validation of key sizes, party counts, and parameters in modules/sdk-lib-mpc/src/tss/redpallas-mps/dkg.ts:101-109
  • Proper error wrapping: WASM errors are caught and re-thrown with contextual information
  • Secure random generation: Uses crypto.randomBytes(32) for seed generation when not provided
  • State protection: Prevents operations in invalid states (e.g., exporting completed sessions)

Type Safety

  • Strong typing: Excellent use of TypeScript with proper interfaces and type guards
  • Runtime validation: Uses io-ts for runtime type checking of deserialized data in modules/sdk-lib-mpc/src/tss/redpallas-mps/types.ts:62-68
  • No any types: Follows repository guidelines by avoiding any type usage

Test Coverage

  • Comprehensive testing: 379 lines of well-structured unit tests covering all major scenarios
  • Edge case coverage: Tests error conditions, invalid inputs, and state transitions
  • Deterministic testing: Supports seed-based testing for reproducible results
  • Session persistence: Tests export/restore functionality

🔍 Areas for Improvement

Minor Issues

  1. Inconsistent error messages (modules/sdk-lib-mpc/src/tss/redpallas-mps/dkg.ts:218,228):

    // Current: generic "DKG session not initialized"
    throw Error('DKG session not initialized');
    
    // Better: specific context
    throw Error('KeyShare not available: DKG session not completed');
    throw Error('SharePublicKey not available: DKG session not completed');
  2. Magic number documentation (modules/sdk-lib-mpc/src/tss/redpallas-mps/dkg.ts:101,104):

    // Could benefit from constants with explanations
    const X25519_KEY_SIZE = 32; // X25519 private/public key size
    const DERIVATION_SEED_SIZE = 32; // RedPallas derivation seed size
  3. Session validation (modules/sdk-lib-mpc/src/tss/redpallas-mps/dkg.ts:273-279):
    Consider validating the session JSON structure before attempting to restore.

Suggestions

  1. Documentation: Consider adding JSDoc examples for the utility functions in util.ts
  2. Browser compatibility: The environment detection logic in modules/sdk-lib-mpc/src/tss/redpallas-mps/dkg.ts:62-67 is solid but could benefit from a comment explaining the Electron process check
  3. Performance: Consider caching the WASM module loading across instances if multiple DKG sessions are expected

📦 Dependencies & Integration

  • Appropriate version bump: @bitgo/wasm-mps updated to 1.11.0 to support RedPallas bindings
  • Clean exports: Properly exported from tss/index.ts maintaining module structure
  • No breaking changes: Additive changes only, maintaining backward compatibility

✅ Recommendations

  1. Approve with minor suggestions: The code is production-ready as-is
  2. Consider adding constants for magic numbers to improve maintainability
  3. The test coverage is excellent and demonstrates thorough understanding of the protocol

This is a high-quality implementation that follows BitGoJS conventions and provides a solid foundation for RedPallas operations in the MPC library.


View workflow run |

@Ranjna-G
Ranjna-G marked this pull request as ready for review August 11, 2026 12:01
@Ranjna-G
Ranjna-G requested review from a team as code owners August 11, 2026 12:01
@Ranjna-G
Ranjna-G merged commit 3f3a8d9 into master Aug 12, 2026
25 checks passed
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