com.rotilho.jnano.commons.Preconditions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jnano-commons Show documentation
Show all versions of jnano-commons Show documentation
JNano provides a set of low level Nano operations that includes signing, seed generation, block hashing and account creation.
package com.rotilho.jnano.commons;
import java.util.function.Supplier;
final class Preconditions {
private Preconditions() {
}
static void checkArgument(boolean expression, Supplier supplier) {
if (!expression) {
throw new IllegalArgumentException(supplier.get());
}
}
static void checkHash(byte[] hash) {
checkArgument(hash.length == 32, () -> "Invalid hash length");
}
static void checkSignature(byte[] signature) {
checkArgument(signature.length == 64, () -> "Invalid signature length");
}
static void checkKey(byte[] key) {
checkArgument(key.length == 32, () -> "Invalid key length");
}
static void checkSeed(byte[] seed) {
checkArgument(seed.length == 32, () -> "Invalid seed length");
}
}