X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FKeysInterface.java;h=bc3aaf5645d7f62d67a373c0e2ffbd8a33a22d2c;hb=76982ad5233afc2759d085bb243f33149369ab9b;hp=5d30628b9f44701bcff59a99e650caa71c828135;hpb=227672ae3d27961f63d45913aad01dbae1f53e99;p=ldk-java diff --git a/src/main/java/org/ldk/structs/KeysInterface.java b/src/main/java/org/ldk/structs/KeysInterface.java index 5d30628b..bc3aaf56 100644 --- a/src/main/java/org/ldk/structs/KeysInterface.java +++ b/src/main/java/org/ldk/structs/KeysInterface.java @@ -34,6 +34,14 @@ public class KeysInterface extends CommonBase { * parameter. */ Result_SecretKeyNoneZ get_node_secret(Recipient recipient); + /** + * Gets the ECDH shared secret of our [`node secret`] and `other_key`, multiplying by `tweak` if + * one is provided. Note that this tweak can be applied to `other_key` instead of our node + * secret, though this is less efficient. + * + * [`node secret`]: Self::get_node_secret + */ + Result_SharedSecretNoneZ ecdh(Recipient recipient, byte[] other_key, Option_ScalarZ tweak); /** * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. * @@ -105,6 +113,14 @@ public class KeysInterface extends CommonBase { long result = ret == null ? 0 : ret.clone_ptr(); return result; } + @Override public long ecdh(Recipient recipient, byte[] other_key, long tweak) { + org.ldk.structs.Option_ScalarZ tweak_hu_conv = org.ldk.structs.Option_ScalarZ.constr_from_ptr(tweak); + if (tweak_hu_conv != null) { tweak_hu_conv.ptrs_to.add(this); }; + Result_SharedSecretNoneZ ret = arg.ecdh(recipient, other_key, tweak_hu_conv); + Reference.reachabilityFence(arg); + long result = ret == null ? 0 : ret.clone_ptr(); + return result; + } @Override public byte[] get_destination_script() { byte[] ret = arg.get_destination_script(); Reference.reachabilityFence(arg); @@ -174,6 +190,24 @@ public class KeysInterface extends CommonBase { return ret_hu_conv; } + /** + * Gets the ECDH shared secret of our [`node secret`] and `other_key`, multiplying by `tweak` if + * one is provided. Note that this tweak can be applied to `other_key` instead of our node + * secret, though this is less efficient. + * + * [`node secret`]: Self::get_node_secret + */ + public Result_SharedSecretNoneZ ecdh(org.ldk.enums.Recipient recipient, byte[] other_key, Option_ScalarZ tweak) { + long ret = bindings.KeysInterface_ecdh(this.ptr, recipient, InternalUtils.check_arr_len(other_key, 33), tweak.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(recipient); + Reference.reachabilityFence(other_key); + Reference.reachabilityFence(tweak); + if (ret >= 0 && ret <= 4096) { return null; } + Result_SharedSecretNoneZ ret_hu_conv = Result_SharedSecretNoneZ.constr_from_ptr(ret); + return ret_hu_conv; + } + /** * Get a script pubkey which we send funds to when claiming on-chain contestable outputs. *