@@ -183,12 +183,43 @@ func (c Seedling) validateFields() error {
183183func (c Seedling ) validateGroupKey (group asset.AssetGroup ,
184184 anchorMeta * proof.MetaReveal ) error {
185185
186- // We must be able to sign with the group key.
187- if ! group .GroupKey .IsLocal () {
186+ // If an external key isn't specified but the actual group key used
187+ // isn't local to this daemon, we won't be able to sign with it.
188+ if c .ExternalKey .IsNone () && ! group .GroupKey .IsLocal () {
188189 groupKeyBytes := c .GroupInfo .GroupPubKey .SerializeCompressed ()
189190 return fmt .Errorf ("can't sign with group key %x" , groupKeyBytes )
190191 }
191192
193+ // If there is an external key defined, we need to check that it matches
194+ // the group key.
195+ err := fn .MapOptionZ (
196+ c .ExternalKey , func (extKey asset.ExternalKey ) error {
197+ if group .GroupKey == nil {
198+ return fmt .Errorf ("group key is nil" )
199+ }
200+
201+ if group .GroupKey .RawKey .PubKey == nil {
202+ return fmt .Errorf ("group raw key is nil" )
203+ }
204+
205+ pk , err := extKey .PubKey ()
206+ if err != nil {
207+ return fmt .Errorf ("error getting external " +
208+ "key: %w" , err )
209+ }
210+
211+ if ! pk .IsEqual (group .RawKey .PubKey ) {
212+ return fmt .Errorf ("external key does not " +
213+ "match group key" )
214+ }
215+
216+ return nil
217+ },
218+ )
219+ if err != nil {
220+ return fmt .Errorf ("error validating external key: %w" , err )
221+ }
222+
192223 // The seedling asset type must match the group asset type.
193224 if c .AssetType != group .Genesis .Type {
194225 return fmt .Errorf ("seedling type does not match " +
0 commit comments