Language

Choose a language

/build/rpc / assets / zk_compliance

generatecomplianceroot

generatecomplianceroot [{"master_pubkey":"hex","country":n,"age":n,"index":n,"revoked":bool},...] ( "circuit_type" {"leaf_hashes":["",...]} ) Generate an append-only compliance merkle root from KYC identity data. This RPC handles all cryptographic operations for building the merkle tree. The tree is append-only: new identities can be added at unused indices. To revoke an identity, set revoked=true to replace it with a NUMS value. The issuer can use the returned root in registerasset or rotatezk. Cryptographic algorithms used per circuit type: - 'standard': SHA256 for leaf hashes and Merkle tree nodes - 'hd' / 'hd_v1': MiMC hash for leaf hashes and Merkle tree nodes (BLS12-381 field) Arguments: 1. identities (json array, required) Array of KYC identities [ { (json object) "master_pubkey": "hex", (string, optional) Master public key (33-byte compressed or X coordinate only). Use 'NUMS' or omit for revoked entry. "country": n, (numeric, optional) ISO 3166-1 numeric country code (omit for revoked) "age": n, (numeric, optional) Age in years (0-255, omit for revoked) "index": n, (numeric, required) Merkle tree index (0-255, REQUIRED for append-only model) "revoked": bool, (boolean, optional, default=false) If true, replace this index with NUMS value (revoke identity) }, ... ] 2. circuit_type (string, optional, default="standard") Circuit type: 'standard' (SHA256 leaf/nodes), 'hd' (MiMC leaf/nodes), or 'hd_v1' (MiMC leaf/nodes). Must match the circuit type used in the ZK proof system. - 'standard': leaf_hash = SHA256(pubkey_x || country || age), node_hash = SHA256(left || right) - 'hd'/'hd_v1': leaf_hash = MiMC(pubkey_x), node_hash = MiMC(left || right). Country/age are off-chain issuer policy. 3. existing_tree (json object, optional) Existing tree to update (append-only) { "leaf_hashes": [ (json array, required) Existing leaf hashes "", (string) Leaf hash at this index (empty string for unused) ... ], } Result: { (json object) "compliance_root" : "hex", (string) The merkle root for the compliance tree "identities" : [ (json array) Processed identities with merkle proofs { (json object) "index" : n, (numeric) Merkle tree index "leaf_hash" : "hex", (string) Computed leaf hash "merkle_proof" : [ (json array) Merkle proof (sibling hashes) "hex", (string) Sibling hash at this level ... ] }, ... ], "leaf_hashes" : [ (json array) All leaf hashes in the tree (empty string for unused slots) "hex", (string) Leaf hash at this index (empty for unused) ... ], "tree_depth" : n, (numeric) Merkle tree depth "total_identities" : n (numeric) Number of identities in tree } Examples: > bitcoin-cli generatecomplianceroot '[{"master_pubkey":"0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","country":840,"age":35,"index":0}]' > curl --user myusername --data-binary '{"jsonrpc": "2.0", "id": "curltest", "method": "generatecomplianceroot", "params": [[[{"master_pubkey":"0279BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","country":840,"age":35}]], "hd_v1"]}' -H 'content-type: application/json' http://127.0.0.1:8332/

Signature

generatecomplianceroot(identities: array, circuit_type?: string, existing_tree?: object) → any

Code samples

curl --user "$RPC_USER:$RPC_PASS" \
  --data-binary '{"jsonrpc":"1.0","id":"docs","method":"generatecomplianceroot","params":[[],"standard",{}]}' \
  -H 'content-type: text/plain;' \
  http://127.0.0.1:8332/

Parameters

NameTypeReq.Description
identitiesany[]yesArray of KYC identities [ { (json object) "master_pubkey": "hex", (string, optional) Master public key (33-byte compressed or X coordinate only). Use 'NUMS' or omit for revoked entry. "country": n, (numeric, optional) ISO 3166-1 numeric country code (omit for revoked) "age": n, (numeric, optional) Age in years (0-255, omit for revoked) "index": n, (numeric, required) Merkle tree index (0-255, REQUIRED for append-only model) "revoked": bool, (boolean, optional, default=false) If true, replace this index with NUMS value (revoke identity) }, ... ]
circuit_typestringCircuit type: 'standard' (SHA256 leaf/nodes), 'hd' (MiMC leaf/nodes), or 'hd_v1' (MiMC leaf/nodes). Must match the circuit type used in the ZK proof system. - 'standard': leaf_hash = SHA256(pubkey_x || country || age), node_hash = SHA256(left || right) - 'hd'/'hd_v1': leaf_hash = MiMC(pubkey_x), node_hash = MiMC(left || right). Country/age are off-chain issuer policy.
existing_treeobjectExisting tree to update (append-only) { "leaf_hashes": [ (json array, required) Existing leaf hashes "", (string) Leaf hash at this index (empty string for unused) ... ], }

Result

Type:  any

{ (json object) "compliance_root" : "hex", (string) The merkle root for the compliance tree "identities" : [ (json array) Processed identities with merkle proofs { (json object) "index" : n, (numeric) Merkle tree index "leaf_hash" : "hex", (string) Computed leaf hash "merkle_proof" : [ (json array) Merkle proof (sibling hashes) "hex", (string) Sibling hash at this level ... ] }, ... ], "leaf_hashes" : [ (json array) All leaf hashes in the tree (empty string for unused slots) "hex", (string) Leaf hash at this index (empty for unused) ... ], "tree_depth" : n, (numeric) Merkle tree depth "total_identities" : n (numeric) Number of identities in tree }

Source: services/core-node/bcore/src/wallet/rpc/compliance_root.cpp:266

C++ symbol: generatecomplianceroot