MarcoEzekiel / go-zcashaddress

A set of parsers for zcash in a variety of langages
Apache License 2.0
1 stars 0 forks source link

Testnet address validation failed #4

Open jiayupu-cb opened 2 months ago

jiayupu-cb commented 2 months ago

Hi team,

When calling zcash.DecodeAddress(address, zcash.Testnet()) from the library, one testnet address validation failed in our unit tests. I tried to print a log right after this line and it seems the decoded testnet addresses are not being correctly parsed:

here is the testnet address we used: tmDkyTviKNEZ4846hgmFks1uKGYGUUWuucm here is the log I printed: === RUN Test_ZcashTestnet_ValidateAddress Decoded address: {P2pkh:<nil> P2sh:<nil> Sapling:<nil> Unified:<nil> Tex:<nil>}

After further exploration, I found the p2pkhLead is defined as [2]byte{0x1c, 0x25} here for the testnet in the library but it is supposed to be {0x1D, 0x25} according to ZIP 320 doc

"For Testnet addresses, the required lead bytes of a P2PKH address in step 2 are [0x1D, 0x25]"

Is there a specific reason why we use [2]byte{0x1c, 0x25} in the library for the testnet p2pkhLead? As I wonder this might be the root cause of why above test case failed. Thank you!

MarcoEzekiel commented 2 months ago

I will take a look at the today and get back to you.

On Mon, Sep 16, 2024 at 8:09 AM jiayupu-cb @.***> wrote:

Hi team,

When calling zcash.DecodeAddress(address, zcash.Testnet()) from the library https://github.com/MarcoEzekiel/go-zcashaddress/blob/main/zcashaddress.go#L76, one testnet address validation failed in our unit tests. I tried to print a log right after this line and it seems the decoded testnet addresses are not being correctly parsed:

here is the testnet address we used: tmDkyTviKNEZ4846hgmFks1uKGYGUUWuucm here is the log I printed: === RUN Test_ZcashTestnet_ValidateAddress Decoded address: {P2pkh: P2sh: Sapling: Unified: Tex:}

After further exploration, I found the p2pkhLead is defined as [2]byte{0x1c, 0x25} here https://github.com/MarcoEzekiel/go-zcashaddress/blob/main/zcashaddress.go#L53 for the testnet in the library but it is supposed to be {0x1D, 0x25} according to ZIP 320 doc https://zips.z.cash/zip-0320

"For Testnet addresses, the required lead bytes of a P2PKH address in step 2 are [0x1D, 0x25]"

Is there a specific reason why we use [2]byte{0x1c, 0x25} in the library for the testnet p2pkhLead? As I wonder this might be the root cause of why above test case failed. Thank you!

— Reply to this email directly, view it on GitHub https://github.com/MarcoEzekiel/go-zcashaddress/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZPWO7NO2NP6ZBVGPYAVSLZW3RC5AVCNFSM6AAAAABOJMRH56VHI2DSMVQWIX3LMV43ASLTON2WKOZSGUZDQNJZGQZTINY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Mark A Harris 303-859-3752

jiayupu-cb commented 1 month ago

Hey team, gentle bump on this issue, wondering when we might expect an update? Ty!

MarcoEzekiel commented 1 month ago

It is on my list this morning. I will have it done today.

Mark A Harris 303-859-3752

On Thu, Sep 19, 2024 at 7:46 AM jiayupu-cb @.***> wrote:

Hey team, gentle bump on this issue, wondering when we might expect an update? Ty!

— Reply to this email directly, view it on GitHub https://github.com/MarcoEzekiel/go-zcashaddress/issues/4#issuecomment-2361035300, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZPWOZWDZSF4ERWKRB5HHTZXLIR7AVCNFSM6AAAAABOJMRH56VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRRGAZTKMZQGA . You are receiving this because you commented.Message ID: @.***>

MarcoEzekiel commented 1 month ago

@jiayupu-cb . Good catch! I have fixed, tested with a small test, and reached out to Zcash about a larger set of Testnet test vectors. You will find changes merged into Main!