Zcash: how can i validate a t-address ?

Created on 10 Jan 2017  路  4Comments  路  Source: zcash/zcash

hello , i am new to zcash , i didn't found a method to validate a t-address , can anyone help ?

question

Most helpful comment

There are three levels at which you might want to validate an address:

  1. Is it a valid Base58Check-encoded string? This will detect typos, but it wouldn't detect a user providing the wrong kind of address (for example, a Bitcoin address instead of a Zcash address).
  2. After Base58Check decoding, is it of the correct form (lead bytes and length) for a Zcash t-address?
  3. Is it an address that someone can actually receive currency at?

For 1, you need a library that implements Base58Check. For debugging I sometimes use the Python base58 module, which has a base58.b58decode_check function. There are equivalents available in most commonly-used programming languages.

For 2, read the "Transparent Payment Addresses" section of the Zcash protocol spec. Note that we may support additional address types in future (in particular we almost certainly will add support for BIP32-style addresses), so if you validate at this level and don't update that code when new types are added, you'll end up excluding them.

For 3, there's really no way to tell.

All 4 comments

There are three levels at which you might want to validate an address:

  1. Is it a valid Base58Check-encoded string? This will detect typos, but it wouldn't detect a user providing the wrong kind of address (for example, a Bitcoin address instead of a Zcash address).
  2. After Base58Check decoding, is it of the correct form (lead bytes and length) for a Zcash t-address?
  3. Is it an address that someone can actually receive currency at?

For 1, you need a library that implements Base58Check. For debugging I sometimes use the Python base58 module, which has a base58.b58decode_check function. There are equivalents available in most commonly-used programming languages.

For 2, read the "Transparent Payment Addresses" section of the Zcash protocol spec. Note that we may support additional address types in future (in particular we almost certainly will add support for BIP32-style addresses), so if you validate at this level and don't update that code when new types are added, you'll end up excluding them.

For 3, there's really no way to tell.

thx daira ~

For 2, read the "Transparent Payment Addresses" section of the Zcash protocol spec

That section doesn't exist any more in the that document you pointed to.

I have just realized many important things are missing in the Zcash docs.

I'd really like to have a reference for :

  1. The format of Zcash address t-address
  2. Data structure & Format of a Zcash transaction that gets relayed to the network.
  3. SIgnature scheme, how is a non shielded transaction signed in Zcash

The section heading is now just "Transparent Addresses" (5.6.1). Transaction format is described in section 7.1, and the signature scheme is in ZIP 143 for Overwinter, and ZIP 243 for Sapling.

Was this page helpful?
0 / 5 - 0 ratings