@@ -183,12 +183,43 @@ func (c Seedling) validateFields() error {
183
183
func (c Seedling ) validateGroupKey (group asset.AssetGroup ,
184
184
anchorMeta * proof.MetaReveal ) error {
185
185
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 () {
188
189
groupKeyBytes := c .GroupInfo .GroupPubKey .SerializeCompressed ()
189
190
return fmt .Errorf ("can't sign with group key %x" , groupKeyBytes )
190
191
}
191
192
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
+
192
223
// The seedling asset type must match the group asset type.
193
224
if c .AssetType != group .Genesis .Type {
194
225
return fmt .Errorf ("seedling type does not match " +
0 commit comments