I'm trying to implement the asset fingerprint in java.
So i'm importing these dependencies
<dependency>
<groupId>org.bitcoinj</groupId>
<artifactId>bitcoinj-core</artifactId>
<version>0.15.10</version>
</dependency>
<dependency>
<groupId>com.github.alphazero</groupId>
<artifactId>Blake2b</artifactId>
<version>bbf094983c</version>
</dependency>
And coded this as specified here: https://github.com/cardano-foundation/CIPs/pull/64
public static void main(String[] args) throws DecoderException {
final String policyId = "2697bec9e609932eaaaafb34c8e1ea706549d268166ef60285026b85";
final String assetName = "redomgrun";
byte[] policyIdBytes = Hex.decodeHex(policyId);
byte[] assetNameBytes = assetName.getBytes();
Digest blakeDigest = Blake2b.Digest.newInstance(20);
byte[] blakeHash = blakeDigest.digest(ArrayUtils.addAll(policyIdBytes, assetNameBytes));
String bechString = Bech32.encode("asset", blakeHash);
System.out.println(bechString);
}
But blake produces bytes like this
[127, -84, -10, 11, 1, -8, 78 ...
Which lead to String index out of range: 127
at bech encoding.
What am i doing wrong?