combinePublicKeys function
PublicKey
combinePublicKeys(
- List<PublicKey> pubs
)
Implementation
PublicKey combinePublicKeys(List<PublicKey> pubs) {
if (pubs.isEmpty) {
throw SchnorrException('pks must be an array with one or more elements');
}
if (pubs.length == 1) {
return pubs[0];
}
var p = AffinePoint.fromXY(pubs[0].X, pubs[0].Y);
var curve = pubs[0].curve;
for (var i = 1; i < pubs.length; i++) {
if (pubs[i].curve != curve) {
throw SchnorrException('publickeys must be on the same curve');
}
p = curve.add(p, pubs[i]);
}
return PublicKey.fromPoint(curve, p);
}