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

package org.bouncycastle.pqc.asn1;

import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.util.Arrays;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1Object;

public class SABERPrivateKey extends ASN1Object
{
    private int version;
    private byte[] z;
    private byte[] s;
    private byte[] hpk;
    private SABERPublicKey PublicKey;
    
    public SABERPrivateKey(final int version, final byte[] z, final byte[] s, final byte[] hpk) {
        this.version = version;
        if (version != 0) {
            throw new IllegalArgumentException("unrecognized version");
        }
        this.z = z;
        this.s = s;
        this.hpk = hpk;
    }
    
    public SABERPrivateKey(final int version, final byte[] z, final byte[] s, final byte[] hpk, final SABERPublicKey publicKey) {
        this.version = version;
        if (version != 0) {
            throw new IllegalArgumentException("unrecognized version");
        }
        this.z = z;
        this.s = s;
        this.hpk = hpk;
        this.PublicKey = publicKey;
    }
    
    private SABERPrivateKey(final ASN1Sequence asn1Sequence) {
        this.version = ASN1Integer.getInstance(asn1Sequence.getObjectAt(0)).intValueExact();
        if (this.version != 0) {
            throw new IllegalArgumentException("unrecognized version");
        }
        this.z = Arrays.clone(ASN1OctetString.getInstance(asn1Sequence.getObjectAt(1)).getOctets());
        this.s = Arrays.clone(ASN1OctetString.getInstance(asn1Sequence.getObjectAt(2)).getOctets());
        this.PublicKey = SABERPublicKey.getInstance(asn1Sequence.getObjectAt(3));
        this.hpk = Arrays.clone(ASN1OctetString.getInstance(asn1Sequence.getObjectAt(4)).getOctets());
    }
    
    public int getVersion() {
        return this.version;
    }
    
    public byte[] getZ() {
        return this.z;
    }
    
    public byte[] getS() {
        return this.s;
    }
    
    public byte[] getHpk() {
        return this.hpk;
    }
    
    public SABERPublicKey getPublicKey() {
        return this.PublicKey;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        final ASN1EncodableVector asn1EncodableVector = new ASN1EncodableVector();
        asn1EncodableVector.add(new ASN1Integer(this.version));
        asn1EncodableVector.add(new DEROctetString(this.z));
        asn1EncodableVector.add(new DEROctetString(this.s));
        asn1EncodableVector.add(new DEROctetString(this.hpk));
        return new DERSequence(asn1EncodableVector);
    }
    
    public static SABERPrivateKey getInstance(final Object o) {
        if (o instanceof SABERPrivateKey) {
            return (SABERPrivateKey)o;
        }
        if (o != null) {
            return new SABERPrivateKey(ASN1Sequence.getInstance(o));
        }
        return null;
    }
}
