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

make auditEpoch stateless #43

Merged
merged 1 commit into from
Nov 14, 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
18 changes: 7 additions & 11 deletions kt/client.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package kt

import (
"github.com/goose-lang/primitive"
"github.com/goose-lang/std"
"github.com/mit-pdos/pav/advrpc"
"github.com/mit-pdos/pav/cryptoffi"
Expand Down Expand Up @@ -190,27 +189,24 @@ func (c *Client) SelfMon() (uint64, *clientErr) {
}

// auditEpoch checks a single epoch against an auditor, and evid / error on fail.
// pre-cond: we've seen this epoch.
func (c *Client) auditEpoch(epoch uint64, adtrCli *advrpc.Client, adtrPk cryptoffi.PublicKey) *clientErr {
func auditEpoch(seenDig *SigDig, servSigPk []byte, adtrCli *advrpc.Client, adtrPk cryptoffi.PublicKey) *clientErr {
stdErr := &clientErr{err: true}
adtrInfo, err0 := callAdtrGet(adtrCli, epoch)
adtrInfo, err0 := callAdtrGet(adtrCli, seenDig.Epoch)
if err0 {
return stdErr
}

// check sigs.
servDig := &SigDig{Epoch: epoch, Dig: adtrInfo.Dig, Sig: adtrInfo.ServSig}
adtrDig := &SigDig{Epoch: epoch, Dig: adtrInfo.Dig, Sig: adtrInfo.AdtrSig}
if CheckSigDig(servDig, c.servSigPk) {
servDig := &SigDig{Epoch: seenDig.Epoch, Dig: adtrInfo.Dig, Sig: adtrInfo.ServSig}
adtrDig := &SigDig{Epoch: seenDig.Epoch, Dig: adtrInfo.Dig, Sig: adtrInfo.AdtrSig}
if CheckSigDig(servDig, servSigPk) {
return stdErr
}
if CheckSigDig(adtrDig, adtrPk) {
return stdErr
}

// compare against our dig.
seenDig, ok0 := c.seenDigs[epoch]
primitive.Assert(ok0)
if !std.BytesEqual(adtrInfo.Dig, seenDig.Dig) {
evid := &Evid{sigDig0: servDig, sigDig1: seenDig}
return &clientErr{evid: evid, err: true}
Expand All @@ -222,8 +218,8 @@ func (c *Client) Audit(adtrAddr uint64, adtrPk cryptoffi.PublicKey) *clientErr {
adtrCli := advrpc.Dial(adtrAddr)
// check all epochs that we've seen before.
var err0 = &clientErr{err: false}
for ep := range c.seenDigs {
err1 := c.auditEpoch(ep, adtrCli, adtrPk)
for _, dig := range c.seenDigs {
err1 := auditEpoch(dig, c.servSigPk, adtrCli, adtrPk)
if err1.err {
err0 = err1
}
Expand Down