Skip to content

Commit

Permalink
Merge pull request #38 from mit-pdos/adtr-serv-sig
Browse files Browse the repository at this point in the history
adtr doesn't need to check server sig
  • Loading branch information
sanjit-bhat authored Oct 24, 2024
2 parents 5b767a3 + 04b22cb commit f3927f4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
22 changes: 7 additions & 15 deletions kt/auditor.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import (
)

type Auditor struct {
mu *sync.Mutex
sk cryptoffi.PrivateKey
servSigPk cryptoffi.PublicKey
keyMap *merkle.Tree
histInfo []*AdtrEpochInfo
mu *sync.Mutex
sk cryptoffi.PrivateKey
keyMap *merkle.Tree
histInfo []*AdtrEpochInfo
}

func (a *Auditor) checkOneUpd(nextEpoch uint64, mapLabel, mapVal []byte) bool {
Expand Down Expand Up @@ -59,17 +58,10 @@ func (a *Auditor) Update(proof *UpdateProof) bool {
}
a.applyUpd(proof.Updates)

// check dig sig.
// sign dig.
dig := a.keyMap.Digest()
preSig := &PreSigDig{Epoch: nextEpoch, Dig: dig}
preSigByt := PreSigDigEncode(make([]byte, 0), preSig)
ok0 := a.servSigPk.Verify(preSigByt, proof.Sig)
if !ok0 {
a.mu.Unlock()
return true
}

// sign dig.
sig := a.sk.Sign(preSigByt)
newInfo := &AdtrEpochInfo{Dig: dig, ServSig: proof.Sig, AdtrSig: sig}
a.histInfo = append(a.histInfo, newInfo)
Expand All @@ -92,9 +84,9 @@ func (a *Auditor) Get(epoch uint64) (*AdtrEpochInfo, bool) {
return info, false
}

func newAuditor(servPk cryptoffi.PublicKey) (*Auditor, cryptoffi.PublicKey) {
func newAuditor() (*Auditor, cryptoffi.PublicKey) {
mu := new(sync.Mutex)
pk, sk := cryptoffi.GenerateKey()
m := &merkle.Tree{}
return &Auditor{mu: mu, sk: sk, servSigPk: servPk, keyMap: m}, pk
return &Auditor{mu: mu, sk: sk, keyMap: m}, pk
}
2 changes: 1 addition & 1 deletion kt/basictest.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func setup(servAddr uint64, adtrAddrs []uint64) *setupParams {
servRpc.Serve(servAddr)
var adtrPks []cryptoffi.PublicKey
for _, adtrAddr := range adtrAddrs {
adtr, adtrPk := newAuditor(servSigPk)
adtr, adtrPk := newAuditor()
adtrRpc := newRpcAuditor(adtr)
adtrRpc.Serve(adtrAddr)
adtrPks = append(adtrPks, adtrPk)
Expand Down
4 changes: 2 additions & 2 deletions kt/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ func testAll(setup *setupParams) {
doAudits(bob.cli, setup.adtrAddrs, setup.adtrPks)

// final check. bob got the right key.
isReg, aliceKey := GetHist(alice.hist, bob.epoch)
isReg, alicePk := GetHist(alice.hist, bob.epoch)
primitive.Assert(isReg == bob.isReg)
if isReg {
primitive.Assert(std.BytesEqual(aliceKey, bob.alicePk))
primitive.Assert(std.BytesEqual(alicePk, bob.alicePk))
}
}

Expand Down

0 comments on commit f3927f4

Please sign in to comment.