1

where can i find a script or snippet of code where I can validate a NXT address?

  • Maybe first check the official NXT client source code? – Mikko Ohtamaa Sep 1 '14 at 19:52
  • 1
    yea but i would have to look through 10,000 lines of code. if someone did it already, they can easily just point me in that direction. – Patoshi パトシ Sep 1 '14 at 19:57
  • To what extent do you want to "validate" addresses? Do you want to check that they are in a correct format? Do you want to check that they correspond to an active account? Do you want to check that the account balance is nonzero? Do you want to check that the account belongs to a specific user? – Greg Hewgill Sep 1 '14 at 23:54
  • just want to check if they are valid – Patoshi パトシ Sep 3 '14 at 1:14
0

http://wiki.nxtcrypto.org/wiki/RS_Address_Format

As of version 1.0.1 of the Nxt software, the use of Reed-Solomon addresses for Nxt account is supported. It's the default format in the official client. This form of address improves reliability by introducing redundancy that can detect and correct errors when entering and using Nxt account numbers. These addresses are always in the form of: NXT-XXXX-XXXX-XXXX-XXXXX ... where X is a non-ambiguous number or alphabetic character (the letters O and I are not used; nor are the numbers 1 and 0). Addresses are always prefixed with "NXT-", and hyphens are used to separate the address into groups of 4, 4, 4, and then 5 characters. The addresses are NOT case-sensitive. Contents [hide] 1 Background 1.1 Benefits of Reed-Solomon addresses 2 Encoding of Nxt Reed-Solomon addresses 3 Technical Details Background

The default format for Nxt account numbers is a completely numeric 64-bit identifier that is derived from the account's private key. Early adopters of Nxt complained that this format was error-prone, since there were numerous instances where a single mistyped character resulted in transactions being unintentionally sent to the wrong account. Reed-Solomon error-correction codes addresses this issue by adding redundancy to addresses. Other options were explored (MD5 hashes, checksum digits, etc.) but a Reed-Solomon format was chosen because: the account collision rate is the same as the default address format; the system's basic error correction can be used to assist users in typing addresses; some programming languages do not have a native MD5 hashing function, and the Reed-Solomon implementation is simpler than MD5. Benefits of Reed-Solomon addresses The chance of a random address collision, using Nxt's implementation of 4 "check-bits", is 1 in a million (20-bit redundancy). It allows up to 2 typos in an address to be corrected. It guarantees that up to 4 typos can be detected. The address length is always 17 characters, and is always prefixed with "NXT". This makes the addresses easily recognizable as belonging to Nxt C++, PHP, and JavaScript implementations can be found at: https://drive.google.com/file/d/0B7kbeA6whDvNWVczbEtvQ1YtZGc Encoding of Nxt Reed-Solomon addresses

Case is not enforced in this format, but for unification all addresses are displayed using upper case. Addresses are split by dashes into groups of 4 characters and a final group of 5 characters, but this is not enforced during address input. The old numeric addresses are also recognized and supported for backwards compatibility. Example RS Addresses: NXT-3DH5-DSAE-4WQ7-3LPSE NXT-K4G2-FF32-WLL3-QBGEL Technical Details

The first and most important rule is that no error-correction scheme is infallible: You cannot rely on error correction, period. The problem is somewhat counter-intuitive: either you can do a simple yes/no check of address validity, which will give you one in a million collision, or you can try and correct errors. You cannot do both. The problem here is that the Reed-Solomon algorithm is only guaranteed to correct up to 2 errors. If there are more than 2 errors present in an address entry, it will produce false positives with a probability of around 10% and transactions will still be sent to incorrect addresses. Think of the algorithm as error-guessing, instead, to assist users with spotting errors. Reed-Solomon (RS) addresses for Nxt are encoded as follows: Take the original 64-bit account ID, add 1 zero bit to get 65 and then split it into thirteen 5-bit "symbols" (65 / 5 = 13). Order the symbols from lowest bit to highest bits, in little-endian order, i.e. bits 0-4, 5-9, 10-14, etc. up to 60-64. Append 4 symbols of parity (20 bits), produced by the Reed-Solomon encoding of our 13 symbols from step one (which are left untouched). This produces a 13 + 4 = 17 symbol codeword. Scramble the codeword symbols in a predefined order and encode them 1-to-1 with an alphabet of 32 characters, splitting them into groups by dashes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.