mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-25 01:26:45 +00:00
add eckey arithmetic functions
This commit is contained in:
parent
dba1a9a2be
commit
4564c5d25a
2 changed files with 13 additions and 1 deletions
|
@ -30,7 +30,7 @@ public class ChildNumber {
|
|||
this.i = i;
|
||||
}
|
||||
|
||||
private static boolean hasHardenedBit(int a) {
|
||||
public static boolean hasHardenedBit(int a) {
|
||||
return (a & HARDENED_BIT) != 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -332,6 +332,18 @@ public class ECKey {
|
|||
return ECKey.fromPublicOnly(point, false);
|
||||
}
|
||||
|
||||
/** Add to the public point by the provided public key */
|
||||
public ECKey add(ECKey pubKey) {
|
||||
ECPoint point = pub.get().add(pubKey.getPubKeyPoint());
|
||||
return ECKey.fromPublicOnly(point, false);
|
||||
}
|
||||
|
||||
/** Calculate the value of the public key point modulo the secp256k1 curve order */
|
||||
public BigInteger moduloCurveOrder() {
|
||||
BigInteger xCoordinate = pub.get().normalize().getAffineXCoord().toBigInteger();
|
||||
return xCoordinate.mod(CURVE_PARAMS.getCurve().getOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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).
|
||||
|
|
Loading…
Reference in a new issue