// 
// Decompiled by Procyon v0.6.0
// 

package com.google.crypto.tink.signature;

import com.google.crypto.tink.Parameters;
import com.google.crypto.tink.Key;
import com.google.crypto.tink.AccessesPartialKey;
import com.google.errorprone.annotations.RestrictedApi;
import java.security.GeneralSecurityException;
import com.google.crypto.tink.util.SecretBytes;

public class SlhDsaPrivateKey extends SignaturePrivateKey
{
    private static final int SLH_DSA_SHA2_128S_PRIVATE_KEY_BYTES = 64;
    private final SlhDsaPublicKey publicKey;
    private final SecretBytes privateKeyBytes;
    
    private SlhDsaPrivateKey(final SlhDsaPublicKey publicKey, final SecretBytes privateSeed) {
        this.publicKey = publicKey;
        this.privateKeyBytes = privateSeed;
    }
    
    @RestrictedApi(explanation = "Accessing parts of keys can produce unexpected incompatibilities, annotate the function with @AccessesPartialKey", link = "https://developers.google.com/tink/design/access_control#accessing_partial_keys", allowedOnPath = ".*Test\\.java", allowlistAnnotations = { AccessesPartialKey.class })
    @AccessesPartialKey
    public static SlhDsaPrivateKey createWithoutVerification(final SlhDsaPublicKey slhDsaPublicKey, final SecretBytes privateKeyBytes) throws GeneralSecurityException {
        if (privateKeyBytes.size() != 64) {
            throw new GeneralSecurityException("Incorrect private key size for SLH-DSA");
        }
        if (slhDsaPublicKey.getParameters().getHashType() != SlhDsaParameters.HashType.SHA2 || slhDsaPublicKey.getParameters().getPrivateKeySize() != 64 || slhDsaPublicKey.getParameters().getSignatureType() != SlhDsaParameters.SignatureType.SMALL_SIGNATURE) {
            throw new GeneralSecurityException("Unknown SKH-DSA instance; only SLH-DSA-SHA2-128S is currently supported");
        }
        return new SlhDsaPrivateKey(slhDsaPublicKey, privateKeyBytes);
    }
    
    @Override
    public SlhDsaPublicKey getPublicKey() {
        return this.publicKey;
    }
    
    @Override
    public SlhDsaParameters getParameters() {
        return this.publicKey.getParameters();
    }
    
    @RestrictedApi(explanation = "Accessing parts of keys can produce unexpected incompatibilities, annotate the function with @AccessesPartialKey", link = "https://developers.google.com/tink/design/access_control#accessing_partial_keys", allowedOnPath = ".*Test\\.java", allowlistAnnotations = { AccessesPartialKey.class })
    public SecretBytes getPrivateKeyBytes() {
        return this.privateKeyBytes;
    }
    
    @Override
    public boolean equalsKey(final Key o) {
        if (!(o instanceof SlhDsaPrivateKey)) {
            return false;
        }
        final SlhDsaPrivateKey that = (SlhDsaPrivateKey)o;
        return that.publicKey.equalsKey(this.publicKey) && this.privateKeyBytes.equalsSecretBytes(that.privateKeyBytes);
    }
}
