Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion mixing/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const (
// MaxPeers is the maximum number of peers allowed together in a
// single mix session. This restricts the maximum dimensions of the
// slot reservation and XOR DC-net matrices and the maximum number of
// previous messages that may be referenced by mix messages.
// previous messages that may be referenced by non-KE mix messages.
MaxPeers = 64

// MaxMcount is the maximum number of mixed messages that any single
Expand Down
17 changes: 17 additions & 0 deletions mixing/mixclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,23 @@ func (c *Client) epochTicker(ctx context.Context) error {
c.logf("Have %d compatible/%d local PRs waiting for pairing %x",
len(prs), len(localPeers), p.pairing)

// Limit initial PR set to the higher wire max peer
// limit.
if len(prs) > wire.MaxMixPeers {
// Place local peers first, then others, and
// trim length.
keptPRs := make([]*wire.MsgMixPairReq, 0, len(prs))
for _, p := range localPeers {
keptPRs = append(keptPRs, p.pr)
}
for _, pr := range prs {
if _, ok := localPeers[pr.Identity]; !ok {
keptPRs = append(keptPRs, pr)
}
}
prs = keptPRs[:wire.MaxMixPeers]
}

// pairSession calls pairingWG.Done once the session
// is formed and the selected peers have been removed
// from then pending pairing.
Expand Down
9 changes: 0 additions & 9 deletions mixing/mixpool/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,6 @@ func checkPRLimits(pr *wire.MsgMixPairReq) error {
return nil
}

func checkKELimits(ke *wire.MsgMixKeyExchange) error {
if len(ke.SeenPRs) > mixing.MaxPeers {
return ruleError(fmt.Errorf("%d referenced PRs exceeds max peers %d",
len(ke.SeenPRs), mixing.MaxPeers))
}

return nil
}

func checkCTLimits(ct *wire.MsgMixCiphertexts) error {
if len(ct.Ciphertexts) > mixing.MaxPeers {
return ruleError(fmt.Errorf("%d ciphertexts exceeds max peers %d",
Expand Down
4 changes: 0 additions & 4 deletions mixing/mixpool/mixpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -1667,10 +1667,6 @@ func validateOwnerProofP2PKHv0(extractFunc func([]byte) []byte, pkscript, pubkey
}

func (p *Pool) checkAcceptKE(ke *wire.MsgMixKeyExchange) error {
if err := checkKELimits(ke); err != nil {
return err
}

// Validate PR order and session ID.
if err := mixing.ValidateSession(ke); err != nil {
return ruleError(err)
Expand Down
Loading