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

package org.bouncycastle.pqc.crypto.crystals.dilithium;

class PolyVecL
{
    Poly[] vec;
    private DilithiumEngine engine;
    private int mode;
    private int polyVecBytes;
    private int dilithiumL;
    private int dilithiumK;
    
    public PolyVecL(final DilithiumEngine engine) {
        this.engine = engine;
        this.mode = engine.getDilithiumMode();
        this.dilithiumL = engine.getDilithiumL();
        this.dilithiumK = engine.getDilithiumK();
        this.vec = new Poly[this.dilithiumL];
        for (int i = 0; i < this.dilithiumL; ++i) {
            this.vec[i] = new Poly(engine);
        }
    }
    
    public PolyVecL() throws Exception {
        throw new Exception("Requires Parameter");
    }
    
    public Poly getVectorIndex(final int n) {
        return this.vec[n];
    }
    
    public void expandMatrix(final byte[] array, final int n) {
        for (int i = 0; i < this.dilithiumL; ++i) {
            this.vec[i].uniformBlocks(array, (short)((n << 8) + i));
        }
    }
    
    public void uniformEta(final byte[] array, final short n) {
        short n2 = n;
        for (int i = 0; i < this.dilithiumL; ++i) {
            final Poly vectorIndex = this.getVectorIndex(i);
            final short n3 = n2;
            ++n2;
            vectorIndex.uniformEta(array, n3);
        }
    }
    
    public void copyPolyVecL(final PolyVecL polyVecL) {
        for (int i = 0; i < this.dilithiumL; ++i) {
            for (int j = 0; j < 256; ++j) {
                polyVecL.getVectorIndex(i).setCoeffIndex(j, this.getVectorIndex(i).getCoeffIndex(j));
            }
        }
    }
    
    public void polyVecNtt() {
        for (int i = 0; i < this.dilithiumL; ++i) {
            this.vec[i].polyNtt();
        }
    }
    
    public void uniformGamma1(final byte[] array, final short n) {
        for (int i = 0; i < this.dilithiumL; ++i) {
            this.getVectorIndex(i).uniformGamma1(array, (short)(this.dilithiumL * n + i));
        }
    }
    
    public void pointwisePolyMontgomery(final Poly poly, final PolyVecL polyVecL) {
        for (int i = 0; i < this.dilithiumL; ++i) {
            this.getVectorIndex(i).pointwiseMontgomery(poly, polyVecL.getVectorIndex(i));
        }
    }
    
    public void invNttToMont() {
        for (int i = 0; i < this.dilithiumL; ++i) {
            this.getVectorIndex(i).invNttToMont();
        }
    }
    
    public void addPolyVecL(final PolyVecL polyVecL) {
        for (int i = 0; i < this.dilithiumL; ++i) {
            this.getVectorIndex(i).addPoly(polyVecL.getVectorIndex(i));
        }
    }
    
    public void reduce() {
        for (int i = 0; i < this.dilithiumL; ++i) {
            this.getVectorIndex(i).reduce();
        }
    }
    
    public boolean checkNorm(final int n) {
        for (int i = 0; i < this.dilithiumL; ++i) {
            if (this.getVectorIndex(i).checkNorm(n)) {
                return true;
            }
        }
        return false;
    }
    
    @Override
    public String toString() {
        String str = "\n[";
        for (int i = 0; i < this.dilithiumL; ++i) {
            str = str + "Inner Matrix " + i + " " + this.getVectorIndex(i).toString();
            if (i != this.dilithiumL - 1) {
                str += ",\n";
            }
        }
        return str + "]";
    }
    
    public String toString(final String str) {
        return str + ": " + this.toString();
    }
}
