Skip to content

Commit 962383a

Browse files
support for endorsed values #200
1 parent db4f46a commit 962383a

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

coserv/quads.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ type RefValQuad struct {
1010
RVTriple *comid.ValueTriple `cbor:"2,keyasint"`
1111
}
1212

13+
// EndorsedValQuad represents an endorsed-values result quad as per CoSERV
14+
// It mirrors RefValQuad but carries endorsed values instead of reference values
15+
type EndorsedValQuad struct {
16+
Authorities *[]comid.CryptoKey `cbor:"1,keyasint"`
17+
EVTriple *comid.ValueTriple `cbor:"2,keyasint"`
18+
}
19+
1320
type AKQuad struct {
1421
Authorities *[]comid.CryptoKey `cbor:"1,keyasint"`
1522
AKTriple *comid.KeyTriple `cbor:"2,keyasint"`

coserv/resultset.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
)
1212

1313
type ResultSet struct {
14-
RVQ *[]RefValQuad `cbor:"0,keyasint,omitempty"`
15-
AKQ *[]AKQuad `cbor:"3,keyasint,omitempty"`
16-
// TODO(tho) add endorsed values
14+
RVQ *[]RefValQuad `cbor:"0,keyasint,omitempty"`
15+
EVQ *[]EndorsedValQuad `cbor:"1,keyasint,omitempty"`
16+
AKQ *[]AKQuad `cbor:"3,keyasint,omitempty"`
1717
// TODO(tho) add CoTS
1818
Expiry *time.Time `cbor:"10,keyasint"`
1919
SourceArtifacts *[]cmw.CMW `cbor:"11,keyasint,omitempty"`
@@ -35,6 +35,17 @@ func (o *ResultSet) AddReferenceValues(v RefValQuad) *ResultSet {
3535
return o
3636
}
3737

38+
// AddEndorsedValues adds the supplied endorsed-values quad to the target ResultSet
39+
func (o *ResultSet) AddEndorsedValues(v EndorsedValQuad) *ResultSet {
40+
if o.EVQ == nil {
41+
o.EVQ = new([]EndorsedValQuad)
42+
}
43+
44+
*o.EVQ = append(*o.EVQ, v)
45+
46+
return o
47+
}
48+
3849
// AddAttestationKeys adds the supplied ak quad to the target ResultSet
3950
func (o *ResultSet) AddAttestationKeys(v AKQuad) *ResultSet {
4051
if o.AKQ == nil {
@@ -68,6 +79,7 @@ func (o ResultSet) Valid() error {
6879
if o.Expiry == nil {
6980
return errors.New("missing mandatory expiry")
7081
}
82+
// Nothing else to validate structurally here; combinations are checked at Coserv level
7183
// The coherency between query and results must be checked by the Coserv's
7284
// Valid()
7385
return nil

0 commit comments

Comments
 (0)