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

workaround goose struct nil init bug #42

Merged
merged 1 commit into from
Nov 11, 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
24 changes: 12 additions & 12 deletions kt/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type clientErr struct {

// checkDig checks for freshness and prior vals, and evid / err on fail.
func (c *Client) checkDig(dig *SigDig) *clientErr {
stdErr := &clientErr{evid: nil, err: true}
stdErr := &clientErr{err: true}
// check sig.
err0 := CheckSigDig(dig, c.servSigPk)
if err0 {
Expand All @@ -42,7 +42,7 @@ func (c *Client) checkDig(dig *SigDig) *clientErr {
evid := &Evid{sigDig0: dig, sigDig1: seenDig}
return &clientErr{evid: evid, err: true}
} else {
return &clientErr{evid: nil, err: false}
return &clientErr{err: false}
}
}
// check for freshness.
Expand All @@ -55,7 +55,7 @@ func (c *Client) checkDig(dig *SigDig) *clientErr {
}
c.seenDigs[dig.Epoch] = dig
c.nextEpoch = dig.Epoch + 1
return &clientErr{evid: nil, err: false}
return &clientErr{err: false}
}

// checkVrfProof errors on fail.
Expand Down Expand Up @@ -105,7 +105,7 @@ func (c *Client) checkNonMemb(uid uint64, ver uint64, dig []byte, nonMemb *NonMe

// Put rets the epoch at which the key was put, and evid / error on fail.
func (c *Client) Put(pk []byte) (uint64, *clientErr) {
stdErr := &clientErr{evid: nil, err: true}
stdErr := &clientErr{err: true}
dig, latest, bound, err0 := callServPut(c.servCli, c.uid, pk)
if err0 {
return 0, stdErr
Expand All @@ -129,7 +129,7 @@ func (c *Client) Put(pk []byte) (uint64, *clientErr) {
return 0, stdErr
}
c.nextVer += 1
return dig.Epoch, &clientErr{evid: nil, err: false}
return dig.Epoch, &clientErr{err: false}
}

// Get returns if the pk was registered, the pk, and the epoch
Expand All @@ -138,7 +138,7 @@ func (c *Client) Put(pk []byte) (uint64, *clientErr) {
// e.g., if don't track vers properly, bound could be off.
// e.g., if don't check isReg alignment with hist, could have fraud non-exis key.
func (c *Client) Get(uid uint64) (bool, []byte, uint64, *clientErr) {
stdErr := &clientErr{evid: nil, err: true}
stdErr := &clientErr{err: true}
dig, hist, isReg, latest, bound, err0 := callServGet(c.servCli, uid)
if err0 {
return false, nil, 0, stdErr
Expand Down Expand Up @@ -168,13 +168,13 @@ func (c *Client) Get(uid uint64) (bool, []byte, uint64, *clientErr) {
if c.checkNonMemb(uid, boundVer, dig.Dig, bound) {
return false, nil, 0, stdErr
}
return isReg, latest.CommOpen.Pk, dig.Epoch, &clientErr{evid: nil, err: false}
return isReg, latest.CommOpen.Pk, dig.Epoch, &clientErr{err: false}
}

// SelfMon self-monitors for the client's own key, and returns the epoch
// through which it succeeds, or evid / error on fail.
func (c *Client) SelfMon() (uint64, *clientErr) {
stdErr := &clientErr{evid: nil, err: true}
stdErr := &clientErr{err: true}
dig, bound, err0 := callServSelfMon(c.servCli, c.uid)
if err0 {
return 0, stdErr
Expand All @@ -186,13 +186,13 @@ func (c *Client) SelfMon() (uint64, *clientErr) {
if c.checkNonMemb(c.uid, c.nextVer, dig.Dig, bound) {
return 0, stdErr
}
return dig.Epoch, &clientErr{evid: nil, err: false}
return dig.Epoch, &clientErr{err: false}
}

// 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 {
stdErr := &clientErr{evid: nil, err: true}
stdErr := &clientErr{err: true}
adtrInfo, err0 := callAdtrGet(adtrCli, epoch)
if err0 {
return stdErr
Expand All @@ -215,13 +215,13 @@ func (c *Client) auditEpoch(epoch uint64, adtrCli *advrpc.Client, adtrPk cryptof
evid := &Evid{sigDig0: servDig, sigDig1: seenDig}
return &clientErr{evid: evid, err: true}
}
return &clientErr{evid: nil, err: false}
return &clientErr{err: false}
}

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{evid: nil, err: false}
var err0 = &clientErr{err: false}
for ep := range c.seenDigs {
err1 := c.auditEpoch(ep, adtrCli, adtrPk)
if err1.err {
Expand Down
4 changes: 2 additions & 2 deletions merkle/merkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (n *node) updateInteriorHash() {
// It'll be specialized after adding it to the tree.
func newGenericNode() *node {
c := make([]*node, numChildren)
return &node{val: nil, hash: nil, children: c}
return &node{children: c}
}

type Digest = []byte
Expand Down Expand Up @@ -296,7 +296,7 @@ func (t *Tree) Get(id Id) *GetReply {
digest := std.BytesClone(nodePath[0].getHash())
proof := getChildHashes(nodePath, id)
if lastNode == nil {
return &GetReply{Val: nil, Digest: digest, ProofTy: NonmembProofTy,
return &GetReply{Digest: digest, ProofTy: NonmembProofTy,
Proof: proof, Error: errNone}
} else {
val := std.BytesClone(lastNode.val)
Expand Down