Skip to content

Commit b19aec3

Browse files
committed
Ensure immutability of MuSigPublicKeys.pubKeys set
1 parent 31d90ce commit b19aec3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

coinlib/lib/src/musig/keys.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ class MuSigPublicKeys {
1010

1111
late final OpaqueMuSigCache _aggCache;
1212

13-
MuSigPublicKeys._(this.pubKeys, this.aggregate, this._aggCache);
13+
MuSigPublicKeys._(Set<ECPublicKey> pubKeys, this.aggregate, this._aggCache)
14+
: pubKeys = Set.unmodifiable(pubKeys);
1415

1516
factory MuSigPublicKeys(Set<ECPublicKey> pubKeys) {
1617

coinlib/test/musig/keys_test.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ void main() {
2121
() => expect(() => MuSigPublicKeys({}), throwsArgumentError),
2222
);
2323

24+
test("pubKeys is immutable", () {
25+
final keySet = getMuSigKeys().pubKeys;
26+
expect(() => keySet.remove(keySet.first), throwsA(anything));
27+
});
28+
2429
test("aggregation works regardless of format", () {
2530

2631
final compressed = getMuSigKeys(true).aggregate;

0 commit comments

Comments
 (0)