mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-12-25 17:46:44 +00:00
prefer using libsecp256k1 to derive public keys from private
This commit is contained in:
parent
d05ec39df7
commit
cd1e21ebaa
2 changed files with 12 additions and 2 deletions
|
@ -275,6 +275,16 @@ public class ECKey {
|
|||
* use {@code new BigInteger(1, bytes);}
|
||||
*/
|
||||
public static ECPoint publicPointFromPrivate(BigInteger privKey) {
|
||||
if(Secp256k1Context.isEnabled()) {
|
||||
try {
|
||||
byte[] pubKeyBytes = NativeSecp256k1.computePubkey(Utils.bigIntegerToBytes(privKey, 32), false);
|
||||
LazyECPoint lazyECPoint = new LazyECPoint(CURVE.getCurve(), pubKeyBytes);
|
||||
return lazyECPoint.get();
|
||||
} catch(NativeSecp256k1Util.AssertFailException e) {
|
||||
log.error("Error computing public key from private", e);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: FixedPointCombMultiplier currently doesn't support scalars longer than the group order,
|
||||
* but that could change in future versions.
|
||||
|
|
|
@ -924,8 +924,8 @@ public class Wallet extends Persistable implements Comparable<Wallet> {
|
|||
* @return the number of weight units (WU)
|
||||
*/
|
||||
public int getInputWeightUnits() {
|
||||
//Estimate assuming an input spending from a fresh receive node - it does not matter this node has no real utxos
|
||||
WalletNode receiveNode = getFreshNode(KeyPurpose.RECEIVE);
|
||||
//Estimate assuming an input spending from the parent receive node - it does not matter this node has no real utxos
|
||||
WalletNode receiveNode = new WalletNode(this, KeyPurpose.RECEIVE);
|
||||
|
||||
Transaction transaction = new Transaction();
|
||||
TransactionOutput prevTxOut = transaction.addOutput(1L, receiveNode.getAddress());
|
||||
|
|
Loading…
Reference in a new issue