Skip to content

Cmp protocol#7

Open
jonathanMweiss wants to merge 52 commits into
mainfrom
cmp-prot
Open

Cmp protocol#7
jonathanMweiss wants to merge 52 commits into
mainfrom
cmp-prot

Conversation

@jonathanMweiss

Copy link
Copy Markdown

this PR adjusts the cmp protocol from tauros to match the xlabs apis.

…he following:

commit 0f99555
Author: Jonathan <jonathan.weiss1@mail.huji.ac.il>
Date:   Tue Aug 19 09:49:36 2025 +0300

    pk marshalled as (pk.x<<1| parity) (#4)

    * pk marshalled as (pk.x<<1| parity)

    * PR fixes

commit 3841be3
Author: Jonathan <jonathan.weiss1@mail.huji.ac.il>
Date:   Thu Aug 7 15:57:12 2025 +0300

    Audit fixes (#2)

    * fx: exponent unmarshal panic with short data

    * ensure phii degree == threshold (as created in round 1)

    * fix: Secp256k1Scalar.Act normalizes the point first

    * change to challenge

    * changed deriveHashKeyContext

    * fix: tuple B in round2 should've included the index of each party

    * static marshal size

    * supporting new Unmarshal of exponentPoly in keygen

    * tweak

    * Unmarshal points/scalars removed without the context of their group

commit fad331e
Author: Jonathan <jonathan.weiss1@mail.huji.ac.il>
Date:   Fri Jun 27 08:48:51 2025 +0300

    update tss-common

commit 41fe152
Author: Jonathan <jonathan.weiss1@mail.huji.ac.il>
Date:   Wed Jun 25 12:51:28 2025 +0300

    upgrading tss-common dependency + msg.ToParsed() fix

commit 77c3534
Author: Jonathan Weiss <jonathan.weiss1@mail.huji.ac.il>
Date:   Thu Jun 19 14:21:53 2025 +0300

    curve.Point clone method

commit c1cbdc3
Author: Jonathan Weiss <jonathan.weiss1@mail.huji.ac.il>
Date:   Thu Jun 19 08:50:40 2025 +0300

    upgrade tss-common dependency

commit b006488
Author: Jonathan <jonathan.weiss1@mail.huji.ac.il>
Date:   Wed Jun 18 15:33:04 2025 +0300

    Frost for ecrecover and tss-lib (#1)

    * changed gomod, upgrade go  ver

    * removed-non-frost

    * not-yet working

    * fix: keygen finilize issue due to self not stored

    * adding proto messages

    * upgrade gomod

    * moving round to be an exported package

    * made the eth one public

    * added func: to contract Bytes

    * marshalling frostsig

    * README note change

    * removed unused hash

    * nits and removed unused packages

    * crypto readability fix + securly setting nonce=0

    * readability and comments, moved unused func into tests

    * clearer challenge func name

    * refactor frost/types.go

    * refreshed common-tss version. added protocol type to msgs

    * dropping bnb-tss old partyID style

    * comment improve

    * fix: broadcast creation funcs names

    * fix test helper

    * upgrade tss-common

    * branch in round3 moved code

    * refactor
@jonathanMweiss jonathanMweiss self-assigned this Sep 1, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates the multi-party signature protocol implementation from the tauros framework to the xlabs APIs. The migration involves updating import paths, modifying message structures to use protocol buffers, and adjusting protocol implementations to match the xlabs API conventions.

  • Updates all import paths from github.com/taurusgroup/multi-party-sig to github.com/xlabs/multi-party-sig
  • Migrates protocol message structures to use protocol buffer definitions with serialization helpers
  • Adapts FROST and CMP signing protocols to work with xlabs' round management and tracking systems

Reviewed Changes

Copilot reviewed 178 out of 181 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
protocols/frost/sign/types.go Removes old signature types and verification logic
protocols/frost/sign/signature.go Adds new EVM-compatible signature implementation with contract support
protocols/frost/sign/sign_test.go Updates tests with xlabs imports and adds contract signature testing
protocols/frost/sign/sign.go Updates imports and adds tracking ID support
protocols/frost/sign/round3.go Migrates to protobuf messages and xlabs round handling
protocols/frost/sign/round2.go Updates message handling and adds EVM-compatible challenge generation
protocols/frost/sign/round1.go Updates imports and adds CanFinalize method
protocols/frost/sign/messages.go Adds protobuf message creation and validation helpers
protocols/frost/sign/frost-signing.pb.go Generated protobuf code for FROST signing messages
protocols/frost/keygen/*.go Migrates keygen protocol to xlabs APIs with protobuf messages
protocols/frost/frost.go Updates main FROST interface with xlabs imports
protocols/cmp/sign/*.go Migrates CMP signing protocol to xlabs message structures
protocols/doerner/*.go Removes deprecated Doerner protocol implementation
protocols/example/*.go Removes example XOR protocol implementation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

// Verify checks if a signature equation actually holds.
//
// Note that m is the hash of a message, and not the message itself.
func (sig Signature) Verify(public curve.Point, m []byte) error {

Copilot AI Sep 1, 2025

Copy link

Choose a reason for hiding this comment

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

The Verify method returns an error instead of a boolean, which is inconsistent with the original implementation. This breaking change could confuse API consumers who expect a boolean return value from signature verification.

Copilot uses AI. Check for mistakes.
Comment thread protocols/frost/sign/round2.go
Comment thread protocols/frost/sign/round1.go
Comment thread protocols/frost/sign/signature.go
Comment thread protocols/cmp/sign/round2.go Outdated
Comment on lines +86 to +87
// TODO: this assumes we've received Broadcast2 before we reach this point.
// (r.K[from] is nil and will FAIL to verify this proof). Consider how to handle this when Broadcast2 is not yet received.

Copilot AI Sep 1, 2025

Copy link

Choose a reason for hiding this comment

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

The TODO comment indicates a potential race condition where message verification depends on broadcast message order. This could lead to verification failures if messages arrive out of order.

Copilot uses AI. Check for mistakes.
Comment thread pkg/zk/affg/affg.go Outdated
Comment thread pkg/zk/affg/affg.go Outdated
Comment thread pkg/zk/marshal/marshal.go Outdated
return err
}

if len(b) > math.MaxUint16 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This may be an issue because MarshalBinary could allocate more than 2^16B memory and only after that will it be filtered (e.g., this may allow someone to allocate enough memory to trigger a crash). It's better if MarshalBinary would return an error if it needs to allocate more than 2^16 B.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

How do you enforce that on marshalBinary?

Comment thread pkg/zk/marshal/marshal.go Outdated
}

func sum(sizes []int) int {
total := 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could this overflow?
(if len(sizes) is larger than 2^15)

@jonathanMweiss jonathanMweiss Sep 7, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've added a check on the number of items , ensuring smaller than 2^16 list

Comment thread pkg/zk/marshal/marshal.go Outdated
}

sizes := make([]int, numItems)
for i := 0; i < numItems; i++ {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is this correct? shouldn't it skip sizes[i] worth of data bytes?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No that's okay.
i first encode the size of all items, then put them one after the other on a single buffer.

Comment thread protocols/cmp/keygen/round4.go
Comment thread protocols/cmp/keygen/round5.go
Comment thread protocols/cmp/cmp.go
return false
}

if len(b.Di) == 0 || len(b.Di) > 33 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should 33 be a global const? Also, is the check accurate?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I hadn't change this frost file. not sure why it shows it in the diff. locally it doesn't seem to show any git diff.

body, ok := msg.Content.(*broadcast2)
if !ok || body == nil {
body, ok := msg.Content.(*Broadcast2)
if !ok || !body.ValidateBasic() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ValidateBasic also checks whether the receiver is nil?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes.

@jonathanMweiss jonathanMweiss marked this pull request as ready for review October 23, 2025 08:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 65 out of 66 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread pkg/pool/pool.go
Comment on lines 34 to +38
type command struct {
search bool
// This counter indicates the number of results that still need to be produced.
ctr *int64
// This channel is used to signal that the counter was modified
ctrChanged chan<- struct{}
// This is the index we evaluate our function at, when not searching
// also used to store results in search mode.
ctr *atomic.Int64

Copilot AI Oct 23, 2025

Copy link

Choose a reason for hiding this comment

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

The comment on line 37 is confusing as it mentions 'also used to store results in search mode', but ctr is a counter, not a storage mechanism for results. The results are stored in the results field. Consider clarifying that ctr tracks the number of remaining results to produce.

Copilot uses AI. Check for mistakes.
Comment thread pkg/pool/pool.go

// keep searching while we still need results
for c.ctr.Load() > 0 {
// using 0 as dummy values, since search functions don't use the index

Copilot AI Oct 23, 2025

Copy link

Choose a reason for hiding this comment

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

The comment 'using 0 as dummy values' should be 'using 0 as a dummy value' (singular) since only one value is being passed.

Suggested change
// using 0 as dummy values, since search functions don't use the index
// using 0 as a dummy value, since search functions don't use the index

Copilot uses AI. Check for mistakes.
newChainKey = c.ChainKey
}
if len(newChainKey) != params.SecBytes {
return nil, fmt.Errorf("expecte %d bytes for chain key, found %d", params.SecBytes, len(newChainKey))

Copilot AI Oct 23, 2025

Copy link

Choose a reason for hiding this comment

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

Corrected spelling of 'expecte' to 'expected'.

Suggested change
return nil, fmt.Errorf("expecte %d bytes for chain key, found %d", params.SecBytes, len(newChainKey))
return nil, fmt.Errorf("expected %d bytes for chain key, found %d", params.SecBytes, len(newChainKey))

Copilot uses AI. Check for mistakes.
@jonathanMweiss jonathanMweiss force-pushed the cmp-prot branch 2 times, most recently from 312157e to bb53773 Compare November 3, 2025 12:16
Comment thread pkg/ecdsa/signature.go

// get a signature in ethereum format
func (sig *Signature) SigEthereum() ([]byte, error) {
IsOverHalfOrder := sig.S.IsOverHalfOrder() // s-values greater than secp256k1n/2 are considered invalid

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this is only for FROST, right?

@@ -0,0 +1,105 @@
package marshal

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is this file a variant of something?

return
}

return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: no op return

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

go compilation demands this return, indicating there is value (see signature)

func makeBroadcast3(
// RID = RIDᵢ
RID types.RID,
C types.RID, //chainkey RID

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: the comments should say what RID means, and what is chainkey

func (body *Broadcast3) unmarshalVssExpoly(crv curve.Curve, threshold int, vssConstant bool) (*polynomial.Exponent, error) {
vssSize := threshold + 1
if vssConstant {
// polynomial[0] is not sent in refresh mode ( due to it being the identity point ) as optimization.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is supporting resharing necessary? (or is it used in the protocol?)

Comment thread protocols/cmp/keygen/messages.go Outdated
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