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

mixclient: Use newest (fewest-PR) KEs to form alt sessions #3404

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions mixing/mixclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1908,17 +1908,17 @@ func (c *Client) alternateSession(pairing []byte, prs []*wire.MsgMixPairReq, d *
kes := c.mixpool.ReceiveKEsByPairing(pairing, unixEpoch)

// Sort KEs by identity first (just to group these together) followed
// by the total referenced PR counts in decreasing order.
// When ranging over KEs below, this will allow us to consider the
// order in which other peers created their KEs, and how they are
// forming their sessions.
// by the total referenced PR counts in increasing order (most recent
// KEs first). When ranging over KEs below, this will allow us to
// consider the order in which other peers created their KEs, and how
// they are forming their sessions.
sort.Slice(kes, func(i, j int) bool {
a := kes[i]
b := kes[j]
if bytes.Compare(a.Identity[:], b.Identity[:]) == -1 {
return true
}
if len(a.SeenPRs) > len(b.SeenPRs) {
if len(a.SeenPRs) < len(b.SeenPRs) {
return true
}
return false
Expand All @@ -1931,7 +1931,7 @@ func (c *Client) alternateSession(pairing []byte, prs []*wire.MsgMixPairReq, d *
prHashByIdentity[pr.Identity] = pr.Hash()
}

// Only one KE per peer identity (the KE that references the most PR
// Only one KE per peer identity (the KE that references the least PR
// hashes) is used for determining session agreement.
type peerMsgs struct {
pr *wire.MsgMixPairReq
Expand Down
Loading