Пример #1
0
  private static String generateEncoded(final byte version, final byte[] publicKey) {
    // step 1: sha3 hash of the public key
    final byte[] sha3PublicKeyHash = Hashes.sha3_256(publicKey);

    // step 2: ripemd160 hash of (1)
    final byte[] ripemd160StepOneHash = Hashes.ripemd160(sha3PublicKeyHash);

    // step 3: store version byte in front of (2)
    final byte[] versionPrefixedRipemd160Hash =
        ArrayUtils.concat(new byte[] {version}, ripemd160StepOneHash);

    // step 4: get the checksum of (3)
    final byte[] stepThreeChecksum = generateChecksum(versionPrefixedRipemd160Hash);

    // step 5: concatenate (3) and (4)
    final byte[] concatStepThreeAndStepSix =
        ArrayUtils.concat(versionPrefixedRipemd160Hash, stepThreeChecksum);

    // step 6: base32 encode (5)
    return Base32Encoder.getString(concatStepThreeAndStepSix);
  }