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

it.auties.whatsapp.model.signal.keypair.SignalPreKeyPair Maven / Gradle / Ivy

There is a newer version: 3.5.1
Show newest version
package it.auties.whatsapp.model.signal.keypair;

import it.auties.whatsapp.model.request.Node;
import it.auties.whatsapp.util.KeyHelper;
import lombok.NonNull;

public record SignalPreKeyPair(int id, byte @NonNull [] publicKey, byte[] privateKey) implements ISignalKeyPair {
    public SignalPreKeyPair(int id, byte[] publicKey, byte[] privateKey) {
        this.id = id;
        this.publicKey = KeyHelper.withoutHeader(publicKey);
        this.privateKey = privateKey;
    }

    public static SignalPreKeyPair random(int id) {
        var keyPair = SignalKeyPair.random();
        return new SignalPreKeyPair(id, keyPair.publicKey(), keyPair.privateKey());
    }

    @Override
    public Node toNode() {
        return Node.ofChildren("key", Node.of("id", encodedId()), Node.of("value", publicKey()));
    }

    @Override
    public SignalKeyPair toGenericKeyPair() {
        return new SignalKeyPair(publicKey(), privateKey());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy