package com.sunyard.chsm.sdf.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author liulu
 * @version V1.0
 * @since 2022/11/11
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class EccCipher {

    // X 分量
    private byte[] x;
    // Y 分量
    private byte[] y;
    // 明文的 SM3 杂凑值
    private byte[] M;
    // 密文数据长度
    private int L;
    // 密文数据
    private byte[] C;


    public byte[] getC1C3C2Bytes() {
        int xLen = x.length;
        int yLen = y.length;
        int mLen = M.length;

        byte[] rawData = new byte[xLen + yLen + mLen + L];

        System.arraycopy(x, 0, rawData, 0, xLen);
        System.arraycopy(y, 0, rawData, xLen, yLen);
        System.arraycopy(M, 0, rawData, xLen + yLen, mLen);
        System.arraycopy(C, 0, rawData, xLen + yLen + mLen, L);

        return rawData;
    }

}
