int CG21_PRESIGN_ROUND3_2_1()

in src/cg21/cg21_presign.c [393:448]


int CG21_PRESIGN_ROUND3_2_1(const CG21_PRESIGN_ROUND2_OUTPUT *r2hisOutput, CG21_PRESIGN_ROUND3_STORE_1 *r3Store,
                            const CG21_PRESIGN_ROUND2_STORE *r2Store, const CG21_PRESIGN_ROUND1_STORE *r1Store, int status){


    /*
     * status = 0      first call
     * status = 1      neither first call, nor last call
     * status = 2      last call
     * status = 3      first and last call (t=2)
     */

    /*
    * ---------STEP 1: compute Gamma -----------
    * Gamma:            \prod Gamma_j
    */

    r3Store->i = r2Store->i;
    //r3store is from example file is sending each time a different instance, it should be fixed,
    // for each i, same r3store should be sent to this function
    if (status==0 || status==3){
        OCT_copy(r3Store->Gamma, r2Store->Gamma);
    }

    // add Gamma_j to r3Store->Gamma
    CG21_ADD_TWO_PK(r3Store->Gamma, r2hisOutput->Gamma);

    /*
    * ---------STEP 2: compute Delta -----------
    * Delta:            Gamma^{k}, Gamma refers to the sum of Gamma_j computed in step1, and k sampled in round1Out
    */
    if (status==2 || status==3) { // last call, since in the last call the computation of Gamma in step1 is completed
        ECP_SECP256K1 tt;
        BIG_256_56 exp;

        // convert r1Store->k from octet to BIG_256_56
        BIG_256_56_fromBytesLen(exp, r1Store->k->val, r1Store->k->len);

        // convert r3Store2->Gamma from octet to ECP
        if (!ECP_SECP256K1_fromOctet(&tt, r3Store->Gamma))
        {
            return CG21_INVALID_ECP;
        }

        // computes Gamma^{k}
        ECP_SECP256K1_mul(&tt, exp);

        // convert ECP to octet
        ECP_SECP256K1_toOctet(r3Store->Delta, &tt, true);

        // clean up the variables
        ECP_SECP256K1_inf(&tt);
        BIG_256_56_zero(exp);
    }

    return CG21_OK;
}