All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.rotilho.jnano.commons.Preconditions Maven / Gradle / Ivy

Go to download

JNano provides a set of low level Nano operations that includes signing, seed generation, block hashing and account creation.

There is a newer version: 1.5.0
Show newest version
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");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy