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

com.rotilho.jnano.commons.NanoKeys 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.nio.ByteBuffer;

import lombok.NonNull;

public final class NanoKeys {
    private NanoKeys() {
    }

    public static byte[] createPrivateKey(@NonNull byte[] seed, int index) {
        Preconditions.checkArgument(NanoSeeds.isValid(seed), () -> "Invalid seed " + seed);
        Preconditions.checkArgument(index >= 0, () -> "Invalid index " + index);
        return Hashes.digest256(seed, ByteBuffer.allocate(4).putInt(index).array());
    }

    public static byte[] createPublicKey(@NonNull byte[] privateKey) {
        return ED25519.createPublicKey(privateKey);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy