Signature
- TypeScript
- Go
- Kotlin
Parameters
Pczt
required
The PCZT containing the input to sign
number
required
Index of the transparent input (0-based)
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Get the signature hash for external signing
function get_sighash(pczt: WasmPczt, input_index: number): string
func GetSighash(pczt *Pczt, inputIndex uint32) ([]byte, error)
fun getSighash(pczt: Pczt, inputIndex: UInt): ByteArray
// 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));
// 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);
Was this page helpful?
