De-anonymizing account hashes

While accounts are known to be recognized by their public keys, internally on-chain, they are uniquely identified by fixed-length accounts hashes derived from those public keys. Because of that, in certain contexts, we may know the account hash but not the public key. CSPR.cloud maintains the mapping between account hashes and the corresponding public keys to be able to "de-anonymize" the former when needed by requesting the public key as an optional property.

Let's have a look at the Transfer API, for example. The Transfer object only provides the recipient account hash:

curl -X 'GET' \
  'https://api.testnet.cspr.cloud/deploys/6117d9f92a40d3785b53145c68a118cf36b974b2803acf41cffce8630acd769c/transfers' \
  -H 'accept: application/json' \
  -H 'authorization: 55f79117-fc4d-4d60-9956-65423f39a06a'
{
  "data": [
    {
      "amount": "2000000000000",
      "deploy_hash": "6117d9f92a40d3785b53145c68a118cf36b974b2803acf41cffce8630acd769c",
      "from_purse": "uref-72653d09444d0b3bd27372247510e9346c39fa831a89008dd9ce849a7b2c15e2-007",
      "id": 1704899420700,
      "initiator_account_hash": "7dc2bcc676eba6196d16374e1a2dbfa1df336f779854d95a0b4e65de6d593158",
      "timestamp": "2024-01-10T15:10:36Z",
      "to_account_hash": "b85634e0695ac3b6a7792c2009377b4a405118571a9c64ab2c66048250fef36c",
      "to_purse": "uref-7bba21087353cf75a83234b07525efdf33f59a6d71da00021a4bb80b6ace4bd7-004",
      "transform_key": "a1845ce7b2d334c7fd39b6313ebcfe4e8e29889bcdc792f7c67c7ba5360fd220"
    }
  ],
  "item_count": 1,
  "page_count": 1
}

Let's "de-anonymize" the recipient of the transfer above by including the to_public_key optional property:

curl -X 'GET' -G \
  'https://api.testnet.cspr.cloud/deploys/6117d9f92a40d3785b53145c68a118cf36b974b2803acf41cffce8630acd769c/transfers' \
  --data-urlencode 'includes=to_public_key' \
  -H 'accept: application/json' \
  -H 'authorization: 55f79117-fc4d-4d60-9956-65423f39a06a'
{
  "data": [
    {
      "amount": "2000000000000",
      "deploy_hash": "6117d9f92a40d3785b53145c68a118cf36b974b2803acf41cffce8630acd769c",
      "from_purse": "uref-72653d09444d0b3bd27372247510e9346c39fa831a89008dd9ce849a7b2c15e2-007",
      "id": 1704899420700,
      "initiator_account_hash": "7dc2bcc676eba6196d16374e1a2dbfa1df336f779854d95a0b4e65de6d593158",
      "timestamp": "2024-01-10T15:10:36Z",
      "to_account_hash": "b85634e0695ac3b6a7792c2009377b4a405118571a9c64ab2c66048250fef36c",
      "to_public_key": "02027fec2d969dd0779358c40abe2a772f309408348c2a1f413fddfe684a4287ba1a",
      "to_purse": "uref-7bba21087353cf75a83234b07525efdf33f59a6d71da00021a4bb80b6ace4bd7-004",
      "transform_key": "a1845ce7b2d334c7fd39b6313ebcfe4e8e29889bcdc792f7c67c7ba5360fd220"
    }
  ],
  "item_count": 1,
  "page_count": 1
}

Note the to_public_key property that was added in the second response. It contains the public key that corresponds to the account hash specified in to_account_hash. Please check Transfer Optional Properties to learn about all the optional data that can be included in the Transfer API responses.

Last updated