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

adtr doesn't need to check server sig #38

Merged
merged 1 commit into from
Oct 24, 2024
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
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