unstoppabledomains / resolution

A library to resolve blockchain domain names.
MIT License
222 stars 66 forks source link

Zcash Sapling Address regexp pattern is incorrect #202

Closed boyfromcave closed 2 years ago

boyfromcave commented 2 years ago

https://github.com/unstoppabledomains/resolution/blob/bf8a2118ccbbf92f96596a2035e645e8ec3102c9/src/config/resolver-keys.json#L102

Zcash Sapling addresses are 78 characters in length.

This middle regexp pattern will be shy by 1 character. only 77 characters. I have tested this in your UD interface for adding a sapling address to a crypto domain; if a user adds a valid sapling address, the UI errors and says it is invalid address. But if you delete 1 character from a valid address, then your UD interface accepts the sapling address as valid.

The error is a bug. It appears that the regexp is missing the "1" in the middle pattern, "zs1". Adding the 1 in the pattern will extend the length of the address to 78 characters, which is correct.

So, the corrected regexp should be: "^z([a-zA-Z0-9]){94}$|^zs1([a-zA-Z0-9]){75}$|^t([a-zA-Z0-9]){34}$"

Note: this bug was found by a Ycash contributor. We review Zcash and Ycash related code, as we feel both should be widely supported.

Same issue found in resolution-go repo: https://github.com/unstoppabledomains/resolution-go/issues/20

sammyluo commented 2 years ago

@boyfromcave Thanks for reporting this issue and sorry for the late reply. It should be fixed by our recent updates. Thanks!