Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sdk-lib-mpc): support DKLS DKG primitives #4281

Merged
merged 1 commit into from
Feb 16, 2024
Merged

Conversation

islamaminBitGo
Copy link
Contributor

@islamaminBitGo islamaminBitGo commented Feb 13, 2024

Ticket: HSM-267

  1. Provides a wrapper class + types that abstract memory handling with wasm, message handling, and creation of commitments.
  2. Provides functions and types to handle authenticated encryption between parties involved in the protocol.
    * Broadcast messages are only authenticated (signed with the sender's private gpg key).
    * P2P messages are authenticated using the sender's private gpg key and encrypted to the recipient's public gpg key).

Copy link

socket-security bot commented Feb 13, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@silencelaboratories/[email protected] eval, filesystem 0 636 kB sl-arm

View full report↗︎

Copy link

socket-security bot commented Feb 13, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

@islamaminBitGo islamaminBitGo marked this pull request as ready for review February 14, 2024 20:08
@islamaminBitGo islamaminBitGo requested review from a team as code owners February 14, 2024 20:08
* @param publicArmor public key to encrypt with
* @param privateArmor private key to sign with
*/
export async function encryptAndDetachSignText(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i recently added these openpgp utility functions but decided to move them to where they're actually needed plus change them to encrypt + decrypt and sign + verify binary data to be compatible with hsm.

Copy link
Contributor

@mmcshinsky-bitgo mmcshinsky-bitgo left a comment

Choose a reason for hiding this comment

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

removal of a publicly exported function is a breaking change. Commit needs to reflect that with BREAKING CHANGE: in the commit footer

export type SerializedP2PMessage = P2PMessage<string, string>;
export type DeserializedP2PMessage = P2PMessage<Uint8Array, Uint8Array>;
export type AuthEncP2PMessage = P2PMessage<AuthEncMessage, string>;
export type AuthBroadcastMessage = BroadcastMessage<AuthEncMessage>;
Copy link
Contributor

@zhongxishen zhongxishen Feb 15, 2024

Choose a reason for hiding this comment

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

AuthBroadcastMessage being parameterized to AuthEncMessage is a little confusing, maybe apart from AuthEncMessage, we need another type AuthMessage, with message and signature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

},
});
return {
encryptedMessage: data.toString('base64'),
Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment about adding AuthMessage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

* @param signedMessage message to verify
* @param publicArmor public key to verify signature with
*/
export async function verifySignedData(signedMessage: AuthEncMessage, publicArmor: string): Promise<boolean> {
Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment about adding AuthMessage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines +65 to +77
user.handleIncomingMessages({
p2pMessages: [],
broadcastMessages: bitgoRound4Messages.broadcastMessages.concat(backupRound4Messages.broadcastMessages),
});
bitgo.handleIncomingMessages({
p2pMessages: [],
broadcastMessages: backupRound4Messages.broadcastMessages.concat(userRound4Messages.broadcastMessages),
});
backup.handleIncomingMessages({
p2pMessages: [],
broadcastMessages: bitgoRound4Messages.broadcastMessages.concat(userRound4Messages.broadcastMessages),
});
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a check that all three parties get to the same public key in their keyshares.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Ticket: HSM-267

BREAKING CHANGE: moves and renames authenticated encryption utility functions to sdk-lib-mpc
Copy link
Contributor

@zhongxishen zhongxishen left a comment

Choose a reason for hiding this comment

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

LGTM

@islamaminBitGo islamaminBitGo merged commit 9a14c7d into master Feb 16, 2024
10 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.

3 participants