Skip to content

Commit

Permalink
re-order checkDig checks
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjit-bhat committed Nov 19, 2024
1 parent 8a601f0 commit 4403fb0
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions kt/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,21 @@ type ClientErr struct {

func checkDig(servSigPk []byte, seenDigs map[uint64]*SigDig, dig *SigDig) *ClientErr {
stdErr := &ClientErr{Err: true}
// check sig.
// sig.
err0 := CheckSigDig(dig, servSigPk)
if err0 {
return stdErr
}
// ret early if we've already seen this epoch before.
seenDig, ok0 := seenDigs[dig.Epoch]
if ok0 {
if !std.BytesEqual(seenDig.Dig, dig.Dig) {
evid := &Evid{sigDig0: dig, sigDig1: seenDig}
return &ClientErr{Evid: evid, Err: true}
} else {
return &ClientErr{Err: false}
}
}
// check epoch not too high, which would overflow c.nextEpoch.
// epoch not too high, which would overflow c.nextEpoch.
if dig.Epoch+1 == 0 {
return stdErr
}
// agrees with prior digs.
seenDig, ok0 := seenDigs[dig.Epoch]
if ok0 && !std.BytesEqual(seenDig.Dig, dig.Dig) {
evid := &Evid{sigDig0: dig, sigDig1: seenDig}
return &ClientErr{Evid: evid, Err: true}
}
return &ClientErr{Err: false}
}

Expand Down

0 comments on commit 4403fb0

Please sign in to comment.