add helper method to multiply a public key

This commit is contained in:
Craig Raw 2024-10-08 10:31:23 +02:00
parent f8f50c0dd9
commit acb1d767e8
2 changed files with 7 additions and 1 deletions

View file

@ -575,7 +575,7 @@ public class OutputDescriptor {
return builder.toString(); return builder.toString();
} }
private List<ExtendedKey> sortExtendedPubKeys(Collection<ExtendedKey> keys) { public List<ExtendedKey> sortExtendedPubKeys(Collection<ExtendedKey> keys) {
List<ExtendedKey> sortedKeys = new ArrayList<>(keys); List<ExtendedKey> sortedKeys = new ArrayList<>(keys);
if(mapChildrenDerivations == null || mapChildrenDerivations.isEmpty() || mapChildrenDerivations.containsKey(null)) { if(mapChildrenDerivations == null || mapChildrenDerivations.isEmpty() || mapChildrenDerivations.containsKey(null)) {
return sortedKeys; return sortedKeys;

View file

@ -326,6 +326,12 @@ public class ECKey {
return pub.get(); return pub.get();
} }
/** Multiply the public point by the provided private key */
public ECKey multiply(BigInteger privKey) {
ECPoint point = pub.get().multiply(privKey);
return ECKey.fromPublicOnly(point, false);
}
/** /**
* Gets the private key in the form of an integer field element. The public key is derived by performing EC * Gets the private key in the form of an integer field element. The public key is derived by performing EC
* point addition this number of times (i.e. point multiplying). * point addition this number of times (i.e. point multiplying).