@@ -181,6 +181,14 @@ func (c Seedling) validateGroupKey(group asset.AssetGroup,
181181 "group asset type %v" , group .Genesis .Type )
182182 }
183183
184+ return validateAnchorMeta (c .Meta , anchorMeta )
185+ }
186+
187+ // validateAnchorMeta checks that the metadata of the seedling matches that of
188+ // the group anchor, if there is a group anchor.
189+ func validateAnchorMeta (seedlingMeta * proof.MetaReveal ,
190+ anchorMeta * proof.MetaReveal ) error {
191+
184192 // The decimal display of the seedling must match that of the group
185193 // anchor. We already validated the seedling metadata, so we don't care
186194 // if the value is explicit or if the metadata is JSON, but we must
@@ -189,11 +197,9 @@ func (c Seedling) validateGroupKey(group asset.AssetGroup,
189197 seedlingDecDisplay uint32
190198 anchorDecDisplay uint32
191199 )
192-
193- if c .Meta != nil {
194- _ , seedlingDecDisplay , _ = c .Meta .GetDecDisplay ()
200+ if seedlingMeta != nil {
201+ _ , seedlingDecDisplay , _ = seedlingMeta .GetDecDisplay ()
195202 }
196-
197203 if anchorMeta != nil {
198204 _ , anchorDecDisplay , _ = anchorMeta .GetDecDisplay ()
199205 }
@@ -204,6 +210,33 @@ func (c Seedling) validateGroupKey(group asset.AssetGroup,
204210 anchorDecDisplay )
205211 }
206212
213+ // If the anchor asset had universe commitments turned on, then the
214+ // seedling must also have them.
215+ var (
216+ seedlingUniverseCommitments bool
217+ anchorUniverseCommitments bool
218+ )
219+ if seedlingMeta != nil && seedlingMeta .UniverseCommitments {
220+ seedlingUniverseCommitments = true
221+ }
222+ if anchorMeta != nil && anchorMeta .UniverseCommitments {
223+ anchorUniverseCommitments = true
224+ }
225+
226+ if seedlingUniverseCommitments != anchorUniverseCommitments {
227+ return fmt .Errorf ("seedling universe commitments flag does " +
228+ "not match group anchor: %v, %v" ,
229+ seedlingUniverseCommitments , anchorUniverseCommitments )
230+ }
231+
232+ // For now, we simply require a delegation key to be set when universe
233+ // commitments are turned on. In the future, we could allow this to be
234+ // empty and the group internal key to be used for signing.
235+ if seedlingUniverseCommitments && seedlingMeta .DelegationKey .IsNone () {
236+ return fmt .Errorf ("delegation key must be set for universe " +
237+ "commitments flag" )
238+ }
239+
207240 return nil
208241}
209242
0 commit comments