Add methods to directly add Reference Values and Endorsed Values#142
Add methods to directly add Reference Values and Endorsed Values#142Priyanshuthapliyal2005 wants to merge 1 commit intoveraison:mainfrom
Conversation
Signed-off-by: Priyanshu Thapliyal <priyanshuthapliyal2005@gmail.com>
setrofim
left a comment
There was a problem hiding this comment.
In addition to other comments -- please fix the indentation be consistent with existing code -- use tabs rather spaces for inent in Go files.
|
|
||
| return o.Extensions.validComid(&o) | ||
| if err := o.TagIdentity.Valid(); err != nil { | ||
| return fmt.Errorf("tag-identity validation failed: %v", err) // Changed %w to %v |
There was a problem hiding this comment.
Why this change?
(also, remove the comments -- they don't make sense without historical context)
| } | ||
|
|
||
| // AddSimpleReferenceValue adds a reference value with a single measurement | ||
| func (o *Comid) AddSimpleReferenceValue(env Environment, measurement *Measurement) error { |
There was a problem hiding this comment.
I don't think "simple" is the right term for this. Perhaps something like AddReferenceValueFromMeasurement.
There was a problem hiding this comment.
This does not address #136, as this does not handle extensions, which is the intent of adding the helper methods.
Note that the issue says "without creating instances of measurements" -- where as this still requres a measurement instance. The reason is that extensions are registred with the collection, and are not propagated to the reference values (and then, through measurement, down to the Mval and the Flags) until the values are added to the collection, so its not possible to specify values for the extension fields until the reference value is in the collection.
The goal of #136 is to address that by adding a method that adds a reference/endorsement value from all raw inputs in asingle operation.
Another issue that, as of the latest CoRIM spec update, a reference value can contain multiple measurements, so the mothod would need to accomodate that as well....
Files Added/Modified:
comid/comid.go
comid/comid_test.go
comid/digests.go
comid/hashalg.go
comid/hashalg_test.go
comid/valuetriple.go
Issue Addressed:
This pull request closes #136 which highlights the difficulty in introducing Extensions for Reference Value Measurements using the current Extensions Interface.
###** Solution:**
New methods have been introduced to the CoMID struct to facilitate the addition of Reference Values without requiring the creation of instances for Measurement and ValueTriples. These methods include:
AddSimpleReferenceValue
AddDigestReferenceValue
AddRawReferenceValue
AddReferenceValueDirect
AddEndorsedValueDirect
These enhancements streamline the process, making it easier to add Reference Values and ensuring better usability of the Extensions Interface.
Before:
Users had to manually create instances for Measurement and ValueTriples to add Reference Values, which was cumbersome and error-prone.
Example:
measurement := &Measurement{ /* initialize measurement */ }
valueTriple := ValueTriple{
Environment: env,
Measurements: *NewMeasurements().Add(measurement),
}
comid.Triples.ReferenceValues.Add(valueTriple)
### After:
With the new methods, users can directly add Reference Values without creating these instances, significantly simplifying the process and reducing the likelihood of errors.
Example:
err := comid.AddSimpleReferenceValue(env, measurement)
if err != nil {
log.Fatalf("failed to add reference value: %v", err)
}