Computes the signature hash (sighash) for a transparent input, enabling external signing with hardware wallets or HSMs.
Signature
function get_sighash(pczt: WasmPczt, input_index: number): string
Parameters
The PCZT containing the input to sign
Index of the transparent input (0-based)
Returns
32-byte signature hash as hex string (TypeScript) or bytes (Go/Kotlin).
Example
// Get sighash for input 0
const sighashHex = t2z.get_sighash(pczt, 0);
// "64a1ef0a32a709943685a39db55a5abf3bdd3e395f9b8ecd7dc618b2d2f88e9b"
// Sign with secp256k1 ECDSA
import { secp256k1 } from '@noble/curves/secp256k1';
const sig = secp256k1.sign(hexToBytes(sighashHex), privateKeyBytes);
const derSig = sig.toDERRawBytes();
// Append SIGHASH_ALL type
const sigWithType = new Uint8Array([...derSig, 0x01]);
// Add to PCZT
pczt = t2z.append_signature(pczt, 0, pubkeyHex, bytesToHex(sigWithType));
Hardware Wallet Flow
// 1. Get sighash
const sighash = t2z.get_sighash(pczt, inputIndex);
// 2. Send to hardware wallet
const signature = await ledger.signMessage(
hexToBytes(sighash),
"m/44'/133'/0'/0/0" // Zcash path
);
// 3. Append to PCZT
pczt = t2z.append_signature(pczt, inputIndex, pubkey, signature);
See Also