Class Taproot
java.lang.Object
com.codename1.crypto.bitcoin.Taproot
Taproot (BIP-341) key tweaking and script trees.
A Taproot output commits to an internal key and, optionally, the Merkle root of a tree
of scripts: Q = P + H_TapTweak(P || root) * G. A key-path spend signs with the tweaked
private key; tweakPrivateKey(byte[], byte[]) gives it. BIP-86 wallets use no script tree.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe leaf version of a Tapscript leaf. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]branchHash(byte[] a, byte[] b) The hash of a branch:H_TapBranchof the two children in byte order.static byte[]internalKey(byte[] privateKey) The x-only internal key of a private key, as BIP-86 derives it.static byte[]The hash of a script leaf:H_TapLeaf(version || compactSize(len) || script).static byte[]outputKey(byte[] internalKey32, byte[] merkleRoot) The x-only output key of an internal key and an optional Merkle root.static ScriptoutputScript(byte[] internalKey32, byte[] merkleRoot) The P2TR output script of an internal key and optional Merkle root.static byte[]taggedHash(String tag, byte[] data) SHA256(SHA256(tag) || SHA256(tag) || data), BIP-340's tagged hash.static byte[]tweak(byte[] internalKey32, byte[] merkleRoot) The tweakH_TapTweak(internalKey || merkleRoot); passnullfor a key-only output.static byte[]tweakPrivateKey(byte[] privateKey, byte[] merkleRoot) The private key that signs foroutputKey(byte[], byte[])on the key path.static byte[][]tweakPublicKey(byte[] internalKey32, byte[] merkleRoot) The output key and its parity:{x-only key, {0 or 1}}.
-
Field Details
-
LEAF_VERSION_TAPSCRIPT
public static final int LEAF_VERSION_TAPSCRIPTThe leaf version of a Tapscript leaf.- See Also:
-
-
Method Details
-
taggedHash
SHA256(SHA256(tag) || SHA256(tag) || data), BIP-340's tagged hash. -
tweak
public static byte[] tweak(byte[] internalKey32, byte[] merkleRoot) The tweakH_TapTweak(internalKey || merkleRoot); passnullfor a key-only output. -
outputKey
public static byte[] outputKey(byte[] internalKey32, byte[] merkleRoot) The x-only output key of an internal key and an optional Merkle root. -
tweakPublicKey
public static byte[][] tweakPublicKey(byte[] internalKey32, byte[] merkleRoot) The output key and its parity:{x-only key, {0 or 1}}. The parity goes into the control block of a script-path spend. -
tweakPrivateKey
public static byte[] tweakPrivateKey(byte[] privateKey, byte[] merkleRoot) The private key that signs foroutputKey(byte[], byte[])on the key path. -
internalKey
public static byte[] internalKey(byte[] privateKey) The x-only internal key of a private key, as BIP-86 derives it. -
leafHash
The hash of a script leaf:H_TapLeaf(version || compactSize(len) || script). -
branchHash
public static byte[] branchHash(byte[] a, byte[] b) The hash of a branch:H_TapBranchof the two children in byte order. -
outputScript
The P2TR output script of an internal key and optional Merkle root.
-