Skip to content

Commit

Permalink
no separate heap alloc for prngSeed
Browse files Browse the repository at this point in the history
  • Loading branch information
jrick committed Jun 19, 2024
1 parent 71fb3fa commit e821a53
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mixing/mixclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ type peer struct {
coinjoin *CoinJoin
kx *mixing.KX

prngSeed *[32]byte
prngSeed [32]byte
prng *chacha20prng.Reader

rs *wire.MsgMixSecrets
Expand Down Expand Up @@ -1094,7 +1094,6 @@ func (c *Client) run(ctx context.Context, ps *pairedSessions, madePairing *bool)

if sesRun.freshGen {
// Generate a new PRNG seed
p.prngSeed = new([32]byte)
rand.Read(p.prngSeed[:])
p.prng = chacha20prng.New(p.prngSeed[:], 0)

Expand Down Expand Up @@ -1137,7 +1136,7 @@ func (c *Client) run(ctx context.Context, ps *pairedSessions, madePairing *bool)
srMsgBytes[i] = p.srMsg[i].Bytes()
}
rs := wire.NewMsgMixSecrets(*p.id, sesRun.sid, 0,
*p.prngSeed, srMsgBytes, p.dcMsg)
p.prngSeed, srMsgBytes, p.dcMsg)
c.blake256HasherMu.Lock()
commitment := rs.Commitment(c.blake256Hasher)
c.blake256HasherMu.Unlock()
Expand Down

0 comments on commit e821a53

Please sign in to comment.