/build/rpc / assets / zk_compliance
generatehdwitnessdata
generatehdwitnessdata "master_pubkey" ( country age ) merkle_index ["",...] ( {"account":n,"change":n,"index":n,"salt":n} "compliance_root" "master_secret" ) Generate witness data for KYC HD zero-knowledge proofs. This RPC creates all the cryptographic data needed for HD proof generation. The HD system allows deriving child keys from a master key for privacy. Arguments: 1. master_pubkey (string, required) Master public key (33-byte compressed or 65-byte uncompressed) 2. country (numeric, optional) ISO 3166-1 numeric country code (metadata only, not used in leaf hash) 3. age (numeric, optional) Age in years 0-255 (metadata only, not used in leaf hash) 4. merkle_index (numeric, required) Index in the compliance merkle tree (0-255) 5. merkle_proof (json array, required) Merkle proof (sibling hashes from leaf to root) [ "", (string) Sibling hash at this level ... ] 6. derivation (json object, optional) HD derivation path parameters { "account": n, (numeric, optional, default=0) Account index "change": n, (numeric, optional, default=0) Change index (0=external, 1=internal) "index": n, (numeric, optional, default=0) Address index "salt": n, (numeric, optional, default=0) Random salt for additional entropy } 7. compliance_root (string, optional) Expected compliance root (for verification) 8. master_secret (string, optional) Master private key (hex). If provided, derives child_secret for wallet import. Not used by the ZK circuit (pubkey-only design). TESTING ONLY. Result: { (json object) "master_pubkey_x" : "hex", (string) X coordinate of master public key "master_pubkey_y" : "hex", (string) Y coordinate of master public key "child_pubkey" : "hex", (string) Derived child public key (compressed) "child_pubkey_x" : "hex", (string) X coordinate of child public key "child_pubkey_y" : "hex", (string) Y coordinate of child public key "child_address" : "str", (string) Taproot (bech32m) address for the child key "child_secret" : "hex", (string, optional) Derived child private key for wallet import when master_secret is supplied. TESTING ONLY. "leaf_hash" : "hex", (string) Merkle tree leaf hash (MiMC, BE hex) "merkle_index" : n, (numeric) Index in merkle tree "merkle_proof" : [ (json array) Merkle proof siblings "hex", (string) Sibling hash ... ], "computed_root" : "hex", (string) Computed merkle root from proof "root_matches" : true|false, (boolean, optional) Whether computed root matches provided compliance_root "path" : { (json object) Derivation path used "account" : n, (numeric) Account index "change" : n, (numeric) Change index "index" : n, (numeric) Address index "salt" : n (numeric) Salt value }, "country" : n, (numeric) Country code (metadata only, not in leaf hash) "age" : n, (numeric) Age (metadata only, not in leaf hash) "witness_data" : { (json object) Witness data for proof generation (V1 packed format, 32-byte padded with 0x prefix) "master_pubkey_x" : "hex", (string) Parent public key X coordinate (0x + 64 hex chars) "master_pubkey_y" : "hex", (string) Master public key Y coordinate (0x + 64 hex chars) "child_pubkey_x" : "hex", (string) Child public key X coordinate (0x + 64 hex chars) "child_pubkey_y" : "hex", (string) Child public key Y coordinate (0x + 64 hex chars) "derivation_commitment" : "hex", (string) Derivation commitment hash (0x + 64 hex chars) "path_vector" : "hex", (string) Packed path: account||change||index, padded to 32 bytes (0x + 64 hex chars) "salt" : "hex", (string) Salt value, padded to 32 bytes (0x + 64 hex chars) "output_key_high" : "hex", (string) Upper 128 bits of child x-only key (0x + 64 hex chars) "output_key_low" : "hex", (string) Lower 128 bits of child x-only key (0x + 64 hex chars) "merkle_path_bits" : "hex", (string) Packed merkle index, padded to 32 bytes (0x + 64 hex chars) "merkle_siblings" : [ (json array) Merkle proof sibling hashes "hex", (string) Sibling hash ... ] } } Examples: > bitcoin-cli generatehdwitnessdata "0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798" 840 35 0 '["0x1234...", "0x5678...", ...]' > curl --user myusername --data-binary '{"jsonrpc": "2.0", "id": "curltest", "method": "generatehdwitnessdata", "params": ["0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798", 840, 35, 0, ["0x1234...", "0x5678..."], {"account": 0, "change": 0, "index": 1, "salt": 42}]}' -H 'content-type: application/json' http://127.0.0.1:8332/
Signature
generatehdwitnessdata(master_pubkey: string, country?: number, age?: number, merkle_index: number, merkle_proof: array, derivation?: object, compliance_root?: string, master_secret?: string) → any Code samples
curl --user "$RPC_USER:$RPC_PASS" \
--data-binary '{"jsonrpc":"1.0","id":"docs","method":"generatehdwitnessdata","params":["\"<master_pubkey>\"",0,0,0,[],{},"\"<compliance_root>\"","\"<master_secret>\""]}' \
-H 'content-type: text/plain;' \
http://127.0.0.1:8332/ Parameters
| Name | Type | Req. | Description |
|---|---|---|---|
| master_pubkey | string | yes | Master public key (33-byte compressed or 65-byte uncompressed) |
| country | number | — | ISO 3166-1 numeric country code (metadata only, not used in leaf hash) |
| age | number | — | Age in years 0-255 (metadata only, not used in leaf hash) |
| merkle_index | number | yes | Index in the compliance merkle tree (0-255) |
| merkle_proof | any[] | yes | Merkle proof (sibling hashes from leaf to root) [ "", (string) Sibling hash at this level ... ] |
| derivation | object | — | HD derivation path parameters { "account": n, (numeric, optional, default=0) Account index "change": n, (numeric, optional, default=0) Change index (0=external, 1=internal) "index": n, (numeric, optional, default=0) Address index "salt": n, (numeric, optional, default=0) Random salt for additional entropy } |
| compliance_root | string | — | Expected compliance root (for verification) |
| master_secret | string | — | Master private key (hex). If provided, derives child_secret for wallet import. Not used by the ZK circuit (pubkey-only design). TESTING ONLY. |
Result
Type: any
{ (json object) "master_pubkey_x" : "hex", (string) X coordinate of master public key "master_pubkey_y" : "hex", (string) Y coordinate of master public key "child_pubkey" : "hex", (string) Derived child public key (compressed) "child_pubkey_x" : "hex", (string) X coordinate of child public key "child_pubkey_y" : "hex", (string) Y coordinate of child public key "child_address" : "str", (string) Taproot (bech32m) address for the child key "child_secret" : "hex", (string, optional) Derived child private key for wallet import when master_secret is supplied. TESTING ONLY. "leaf_hash" : "hex", (string) Merkle tree leaf hash (MiMC, BE hex) "merkle_index" : n, (numeric) Index in merkle tree "merkle_proof" : [ (json array) Merkle proof siblings "hex", (string) Sibling hash ... ], "computed_root" : "hex", (string) Computed merkle root from proof "root_matches" : true|false, (boolean, optional) Whether computed root matches provided compliance_root "path" : { (json object) Derivation path used "account" : n, (numeric) Account index "change" : n, (numeric) Change index "index" : n, (numeric) Address index "salt" : n (numeric) Salt value }, "country" : n, (numeric) Country code (metadata only, not in leaf hash) "age" : n, (numeric) Age (metadata only, not in leaf hash) "witness_data" : { (json object) Witness data for proof generation (V1 packed format, 32-byte padded with 0x prefix) "master_pubkey_x" : "hex", (string) Parent public key X coordinate (0x + 64 hex chars) "master_pubkey_y" : "hex", (string) Master public key Y coordinate (0x + 64 hex chars) "child_pubkey_x" : "hex", (string) Child public key X coordinate (0x + 64 hex chars) "child_pubkey_y" : "hex", (string) Child public key Y coordinate (0x + 64 hex chars) "derivation_commitment" : "hex", (string) Derivation commitment hash (0x + 64 hex chars) "path_vector" : "hex", (string) Packed path: account||change||index, padded to 32 bytes (0x + 64 hex chars) "salt" : "hex", (string) Salt value, padded to 32 bytes (0x + 64 hex chars) "output_key_high" : "hex", (string) Upper 128 bits of child x-only key (0x + 64 hex chars) "output_key_low" : "hex", (string) Lower 128 bits of child x-only key (0x + 64 hex chars) "merkle_path_bits" : "hex", (string) Packed merkle index, padded to 32 bytes (0x + 64 hex chars) "merkle_siblings" : [ (json array) Merkle proof sibling hashes "hex", (string) Sibling hash ... ] } }
Source: services/core-node/bcore/src/wallet/rpc/hd_witness.cpp:309
C++ symbol: generatehdwitnessdata