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

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

class PolyVecMatrix
{
    private final int dilithiumK;
    private final int dilithiumL;
    private final PolyVecL[] mat;
    
    public PolyVecMatrix(final DilithiumEngine dilithiumEngine) {
        this.dilithiumK = dilithiumEngine.getDilithiumK();
        this.dilithiumL = dilithiumEngine.getDilithiumL();
        this.mat = new PolyVecL[this.dilithiumK];
        for (int i = 0; i < this.dilithiumK; ++i) {
            this.mat[i] = new PolyVecL(dilithiumEngine);
        }
    }
    
    public void pointwiseMontgomery(final PolyVecK polyVecK, final PolyVecL polyVecL) {
        for (int i = 0; i < this.dilithiumK; ++i) {
            polyVecK.getVectorIndex(i).pointwiseAccountMontgomery(this.mat[i], polyVecL);
        }
    }
    
    public void expandMatrix(final byte[] array) {
        for (int i = 0; i < this.dilithiumK; ++i) {
            for (int j = 0; j < this.dilithiumL; ++j) {
                this.mat[i].getVectorIndex(j).uniformBlocks(array, (short)((i << 8) + j));
            }
        }
    }
    
    private String addString() {
        String s = "[";
        for (int i = 0; i < this.dilithiumK; ++i) {
            final String string = s + "Outer Matrix " + i + " [" + this.mat[i].toString();
            if (i == this.dilithiumK - 1) {
                s = string + "]\n";
            }
            else {
                s = string + "],\n";
            }
        }
        return s + "]\n";
    }
    
    public String toString(final String s) {
        return s.concat(": \n" + this.addString());
    }
}
