http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/test/test_big_consistency_XXX.c.in
----------------------------------------------------------------------
diff --git a/test/test_big_consistency_XXX.c.in 
b/test/test_big_consistency_XXX.c.in
new file mode 100644
index 0000000..ae4d2fc
--- /dev/null
+++ b/test/test_big_consistency_XXX.c.in
@@ -0,0 +1,254 @@
+/**
+ * @file test_big_consistency.c
+ * @author Alessandro Budroni
+ * @brief Test for consistency with BIG_XXX
+ *
+ * LICENSE
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include "arch.h"
+#include "amcl.h"
+#include "utils.h"
+#include "big_XXX.h"
+
+int main()
+{
+
+    int i,j;
+    char raw[256], bytes[MODBYTES_XXX];
+    csprng rng;
+
+    BIG_XXX F,G,H,I,Z;
+    DBIG_XXX DF,DG;
+
+    /* Fake random source */
+    RAND_clean(&rng);
+    for (i=0; i<256; i++) raw[i]=(char)i;
+    RAND_seed(&rng,256,raw);
+
+    /* Set to zero */
+    BIG_XXX_zero(F);
+    BIG_XXX_zero(G);
+    BIG_XXX_dzero(DF);
+    BIG_XXX_dzero(DG);
+
+    /* Testing equal function and set zero function */
+    if(BIG_XXX_comp(G,F) | !BIG_XXX_iszilch(F) | !BIG_XXX_iszilch(G) | 
BIG_XXX_dcomp(DG,DF) | !BIG_XXX_diszilch(DF) | !BIG_XXX_diszilch(DG))
+    {
+        printf("ERROR comparing or setting zero BIG_XXX\n");
+        exit(EXIT_FAILURE);
+    }
+
+    /* Testing coping and equal function */
+    BIG_XXX_random(F,&rng);
+    BIG_XXX_random(DF,&rng);
+    BIG_XXX_copy(G,F);
+    BIG_XXX_dcopy(DG,DF);
+    if(BIG_XXX_comp(G,F) | BIG_XXX_dcomp(DG,DF))
+    {
+        printf("ERROR testing coping and equal BIG_XXX\n");
+        exit(EXIT_FAILURE);
+    }
+
+    /* Testing addition, subtraction */
+    for (i=0; i<100; i++)
+    {
+        BIG_XXX_random(F,&rng);
+        BIG_XXX_random(H,&rng);
+        BIG_XXX_copy(G,F);
+        BIG_XXX_add(G,G,H);
+        BIG_XXX_sub(G,G,H);
+        BIG_XXX_sub(H,H,H);
+        if(BIG_XXX_comp(G,F) | !BIG_XXX_iszilch(H))
+        {
+            printf("ERROR testing addition/subtraction BIG_XXX\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+    BIG_XXX_one(I);
+    BIG_XXX_zero(Z);
+    BIG_XXX_zero(F);
+    BIG_XXX_add(F,F,F);
+    BIG_XXX_add(Z,I,Z);
+    if(BIG_XXX_comp(Z,I) | !BIG_XXX_iszilch(F))
+    {
+        printf("ERROR testing addition/subtraction BIG_XXX\n");
+        exit(EXIT_FAILURE);
+    }
+
+    /* Testing small multiplication and division by 3 */
+    for (i=0; i<100; i++)
+    {
+        BIG_XXX_random(F,&rng);
+        BIG_XXX_copy(G,F);
+        BIG_XXX_imul(G,G,3);
+        BIG_XXX_div3(G);
+        if(BIG_XXX_comp(G,F))
+        {
+            printf("ERROR testing small multiplication and division by 3 
BIG_XXX\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    /* Testing small multiplication and addition */
+    BIG_XXX_random(F,&rng);
+    for (j = 1; j <= 20; ++j)
+    {
+        BIG_XXX_imul(H,F,j);
+        BIG_XXX_copy(G,F);
+        for (i = 1; i < j; ++i)
+        {
+            BIG_XXX_add(G,G,F);
+        }
+        BIG_XXX_norm(G);
+        BIG_XXX_norm(H);
+        if(BIG_XXX_comp(H,G) != 0)
+        {
+            printf("ERROR testing small multiplication and addition BIG_XXX, 
%d\n",j);
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    /* Testing square */
+    for (i=0; i<100; i++)
+    {
+        BIG_XXX_random(F,&rng);
+        BIG_XXX_copy(G,F);
+        BIG_XXX_sqr(DG,G);
+        BIG_XXX_mul(DF,F,F);
+        if(BIG_XXX_dcomp(DG,DF))
+        {
+            printf("ERROR testing square BIG_XXX\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    /* Testing square mod */
+    for (i=0; i<100; i++)
+    {
+        BIG_XXX_random(H,&rng);
+        BIG_XXX_randomnum(F,H,&rng);
+        BIG_XXX_copy(G,F);
+        BIG_XXX_modsqr(G,G,H);
+        BIG_XXX_sqr(DF,F);
+        BIG_XXX_dmod(F,DF,H);
+        if(BIG_XXX_comp(G,F))
+        {
+            printf("ERROR testing mod square BIG_XXX\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    /* Testing from and to bytes conversion */
+    for (i=0; i<100; i++)
+    {
+        BIG_XXX_random(F,&rng);
+        BIG_XXX_copy(G,F);
+        BIG_XXX_toBytes(bytes,G);
+        BIG_XXX_fromBytes(G,bytes);
+        if(BIG_XXX_comp(G,F))
+        {
+            printf("ERROR testing from and to bytes conversion BIG_XXX\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+    BIG_XXX_toBytes(bytes,G);
+    BIG_XXX_fromBytesLen(G,bytes,MODBYTES_XXX);
+    if(BIG_XXX_comp(G,F))
+    {
+        printf("ERROR testing from and to bytes conversion BIG_XXX\n");
+        exit(EXIT_FAILURE);
+    }
+
+    /* Testing small increment and decrement */
+    for (i=0; i<100; i++)
+    {
+        BIG_XXX_random(F,&rng);
+        BIG_XXX_copy(G,F);
+        BIG_XXX_inc(G,i);
+        BIG_XXX_dec(G,i);
+        if(BIG_XXX_comp(G,F))
+        {
+            printf("ERROR testing small increment and decrement BIG_XXX\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    /* Testing small increment and decrement */
+    for (i=0; i<100; i++)
+    {
+        BIG_XXX_random(F,&rng);
+        BIG_XXX_copy(G,F);
+        if(BIG_XXX_comp(G,F))
+        {
+            printf("ERROR testing small increment and decrement BIG_XXX\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    /* Testing random with modulo */
+    for (i=0; i<100; i++)
+    {
+        BIG_XXX_random(G,&rng);
+        BIG_XXX_randomnum(F,G,&rng);
+        if(BIG_XXX_comp(F,G)>0)
+        {
+            printf("ERROR testing random with modulo BIG_XXX\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    /* Testing mod neg */
+    for (i=0; i<100; i++)
+    {
+        BIG_XXX_random(H,&rng);
+        BIG_XXX_randomnum(F,H,&rng);
+        BIG_XXX_modneg(G,F,H);
+        BIG_XXX_modneg(G,G,H);
+        BIG_XXX_norm(G);
+        BIG_XXX_norm(F);
+        if(BIG_XXX_comp(F,G))
+        {
+            printf("ERROR testing mod neg BIG_XXX\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    /* Testing copy from/to BIG_XXX/DBIG_XXX */
+    for (i=0; i<100; i++)
+    {
+        BIG_XXX_random(F,&rng);
+        BIG_XXX_copy(G,F);
+        BIG_XXX_dzero(DF);
+        BIG_XXX_dsucopy(DF,F);
+        BIG_XXX_sducopy(F,DF);
+        if(BIG_XXX_comp(F,G))
+        {
+            printf("ERROR testing copy from/to BIG_XXX/DBIG_XXX\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    printf("SUCCESS TEST CONSISTENCY OF BIG_XXX PASSED\n");
+    exit(EXIT_SUCCESS);
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/test/test_ecc_ZZZ.c.in
----------------------------------------------------------------------
diff --git a/test/test_ecc_ZZZ.c.in b/test/test_ecc_ZZZ.c.in
new file mode 100644
index 0000000..ee9231e
--- /dev/null
+++ b/test/test_ecc_ZZZ.c.in
@@ -0,0 +1,233 @@
+/**
+ * @file test_ecc_ZZZ.c
+ * @author Kealan McCusker
+ * @brief Test function for ECC
+ *
+ * LICENSE
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* test driver and function exerciser for ECDH/ECIES/ECDSA API Functions */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "ecdh_ZZZ.h"
+#include "randapi.h"
+
+//#define DEBUG
+
+int main()
+{
+    int i,j=0,res;
+    unsigned long ran;
+    char pp[]="M0ng00se";
+    /* These octets are automatically protected against buffer overflow 
attacks */
+    /* Note salt must be big enough to include an appended word */
+    /* Note ECIES ciphertext C must be big enough to include at least 1 
appended block */
+    /* Recall EFS_ZZZ is field size in bytes. So EFS_ZZZ=32 for 256-bit curve 
*/
+    char 
s0[EGS_ZZZ],s1[EGS_ZZZ],w0[2*EFS_ZZZ+1],w1[2*EFS_ZZZ+1],z0[EFS_ZZZ],z1[EFS_ZZZ],raw[100],key[AESKEY_ZZZ],salt[32],pw[20];
+#if CURVETYPE_ZZZ != MONTGOMERY
+    char 
ds[EGS_ZZZ],p1[32],p2[32],v[2*EFS_ZZZ+1],m[32],plm[32],c[64],t[32],cs[EGS_ZZZ];
+#endif
+
+    octet S0= {0,sizeof(s0),s0};
+    octet S1= {0,sizeof(s1),s1};
+    octet W0= {0,sizeof(w0),w0};
+    octet W1= {0,sizeof(w1),w1};
+    octet Z0= {0,sizeof(z0),z0};
+    octet Z1= {0,sizeof(z1),z1};
+    octet RAW= {0,sizeof(raw),raw};
+    octet KEY= {0,sizeof(key),key};
+    octet SALT= {0,sizeof(salt),salt};
+    octet PW= {0,sizeof(pw),pw};
+#if CURVETYPE_ZZZ != MONTGOMERY
+    octet DS= {0,sizeof(ds),ds};
+    octet CS= {0,sizeof(cs),cs};
+    octet P1= {0,sizeof(p1),p1};
+    octet P2= {0,sizeof(p2),p2};
+    octet V= {0,sizeof(v),v};
+    octet M= {0,sizeof(m),m};
+    octet PlM= {0,sizeof(plm),plm};
+    octet C= {0,sizeof(c),c};
+    octet T= {0,sizeof(t),t};
+#endif
+
+// Initialize radom number generator with fake random seed source
+    csprng RNG;
+    time((time_t *)&ran);
+
+    RAW.len=100;
+    RAW.val[0]=ran;
+    RAW.val[1]=ran>>8;
+    RAW.val[2]=ran>>16;
+    RAW.val[3]=ran>>24;
+    for (i=0; i<100; i++) RAW.val[i]=i;
+
+    CREATE_CSPRNG(&RNG,&RAW);
+
+// Set salt
+    for (j=0; j<100; j++)
+    {
+        SALT.len=8;
+        for (i=0; i<8; i++) SALT.val[i]=i+1;
+
+// Copy Passhrase
+#ifdef DEBUG
+        printf("Alice's Passphrase= %s\n",pp);
+#endif
+        OCT_empty(&PW);
+        OCT_jstring(&PW,pp);   // set Password from string
+
+// Derive private key S0 of size EGS_ZZZ bytes from Password and Salt
+        PBKDF2(HASH_TYPE_ZZZ,&PW,&SALT,1000,EGS_ZZZ,&S0);
+#ifdef DEBUG
+        printf("Alices private key= 0x");
+        OCT_output(&S0);
+#endif
+
+// Generate Key pair S/W
+        ECP_ZZZ_KEY_PAIR_GENERATE(NULL,&S0,&W0);
+#ifdef DEBUG
+        printf("Alices public key= 0x");
+        OCT_output(&W0);
+#endif
+        res=ECP_ZZZ_PUBLIC_KEY_VALIDATE(&W0);
+        if (res!=0)
+        {
+            printf("ECP Public Key is invalid!\n");
+            exit(1);
+        }
+
+// Random private key for other party
+        ECP_ZZZ_KEY_PAIR_GENERATE(&RNG,&S1,&W1);
+        res=ECP_ZZZ_PUBLIC_KEY_VALIDATE(&W1);
+        if (res!=0)
+        {
+            printf("ECP Public Key is invalid!\n");
+            exit(1);
+        }
+#ifdef DEBUG
+        printf("Servers private key= 0x");
+        OCT_output(&S1);
+        printf("Servers public key= 0x");
+        OCT_output(&W1);
+#endif
+
+// Calculate common key using DH - IEEE 1363 method
+        ECP_ZZZ_SVDP_DH(&S0,&W1,&Z0);
+        ECP_ZZZ_SVDP_DH(&S1,&W0,&Z1);
+        if (!OCT_comp(&Z0,&Z1))
+        {
+            printf("ECPSVDP-DH Failed\n");
+            exit(1);
+        }
+
+        KDF2(HASH_TYPE_ZZZ,&Z0,NULL,AESKEY_ZZZ,&KEY);
+#ifdef DEBUG
+        printf("Alice's DH Key=  0x");
+        OCT_output(&KEY);
+        printf("Servers DH Key=  0x");
+        OCT_output(&KEY);
+#endif
+
+#if CURVETYPE_ZZZ != MONTGOMERY
+#ifdef DEBUG
+        printf("Testing ECIES\n");
+#endif
+// Generate parameters and message randomly
+        OCT_rand(&P1,&RNG,P1.len);
+        OCT_rand(&P2,&RNG,P2.len);
+        OCT_rand(&M,&RNG,M.len);
+
+// ECIES ecncryption
+        ECP_ZZZ_ECIES_ENCRYPT(HASH_TYPE_ZZZ,&P1,&P2,&RNG,&W1,&M,12,&V,&C,&T);
+#ifdef DEBUG
+        printf("Ciphertext= \n");
+        printf("V= 0x");
+        OCT_output(&V);
+        printf("C= 0x");
+        OCT_output(&C);
+        printf("T= 0x");
+        OCT_output(&T);
+#endif
+        OCT_copy(&PlM,&M);
+
+// ECIES decryption
+        if (!ECP_ZZZ_ECIES_DECRYPT(HASH_TYPE_ZZZ,&P1,&P2,&V,&C,&T,&S1,&M))
+        {
+            printf("ECIES Decryption Failed\n");
+            exit(1);
+        }
+#ifdef DEBUG
+        else
+        {
+            printf("ECIES Decryption Succeeded\n");
+        }
+#endif
+
+// Compare intial message with the decripted one
+        if(!OCT_comp(&PlM,&M))
+        {
+            printf("ECIES Decryption Failed\n");
+            exit(1);
+        }
+#ifdef DEBUG
+        printf("Message is 0x");
+        OCT_output(&M);
+
+        printf("Testing ECDSA\n");
+#endif
+
+// Sign with ECDSA
+        if (ECP_ZZZ_SP_DSA(HASH_TYPE_ZZZ,&RNG,NULL,&S0,&M,&CS,&DS)!=0)
+        {
+            printf("ECDSA Signature Failed\n");
+            exit(1);
+        }
+#ifdef DEBUG
+        printf("Signature C = 0x");
+        OCT_output(&CS);
+        printf("Signature D = 0x");
+        OCT_output(&DS);
+#endif
+
+// Verify ECDSA signature
+        if (ECP_ZZZ_VP_DSA(HASH_TYPE_ZZZ,&W0,&M,&CS,&DS)!=0)
+        {
+            printf("ECDSA Verification Failed\n");
+            exit(1);
+        }
+#ifdef DEBUG
+        else
+        {
+            printf("ECDSA Signature/Verification succeeded %d\n",j);
+        }
+#endif
+
+#endif
+    }
+
+    KILL_CSPRNG(&RNG);
+
+    printf("SUCCESS\n");
+    return 0;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/test/test_ecdh_ZZZ.c.in
----------------------------------------------------------------------
diff --git a/test/test_ecdh_ZZZ.c.in b/test/test_ecdh_ZZZ.c.in
new file mode 100644
index 0000000..4b5b5f0
--- /dev/null
+++ b/test/test_ecdh_ZZZ.c.in
@@ -0,0 +1,308 @@
+/**
+ * @file test_ecdh_ZZZ.c
+ * @author Kealan McCusker
+ * @brief Test function for ECDH
+ *
+ * LICENSE
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* Build executible after installation:
+
+  gcc -std=c99 -g ./test_ecdh.c -I/opt/amcl/include -L/opt/amcl/lib -lamcl 
-lecdh -o test_ecdh
+
+*/
+
+#include "ecdh_ZZZ.h"
+#include "utils.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define LINE_LEN 500
+//#define DEBUG
+
+int main(int argc, char** argv)
+{
+    if (argc != 2)
+    {
+        printf("usage: ./test_ecdh_ZZZ [path to test vector file]\n");
+        exit(EXIT_FAILURE);
+    }
+    int rc;
+    FILE * fp = NULL;
+    char line[LINE_LEN];
+    char * linePtr = NULL;
+    int l1=0, l2=0, i=0;
+
+    char raw[256], key[AESKEY_ZZZ], ciphertext[AESKEY_ZZZ*2], 
res[AESKEY_ZZZ*2], plaintext[AESKEY_ZZZ*2];
+    octet Key= {0,sizeof(key),key}, Ciphertext= 
{0,sizeof(ciphertext),ciphertext}, Plaintext= {0,sizeof(plaintext),plaintext}, 
Res= {0,sizeof(res),res};
+    csprng rng;
+
+    /* Fake random source */
+    RAND_clean(&rng);
+    for (i=0; i<256; i++) raw[i]=(char)i;
+    RAND_seed(&rng,256,raw);
+
+
+    char QCAVSx[EGS_ZZZ];
+    const char* QCAVSxStr = "QCAVSx = ";
+    octet QCAVSxOct = {EGS_ZZZ,EGS_ZZZ,QCAVSx};
+
+#if CURVETYPE_ZZZ!=MONTGOMERY
+    char QCAVSy[EGS_ZZZ];
+    const char* QCAVSyStr = "QCAVSy = ";
+    octet QCAVSyOct = {EGS_ZZZ,EGS_ZZZ,QCAVSy};
+#endif
+
+    char * dIUT = NULL;
+    const char* dIUTStr = "dIUT = ";
+    octet dIUTOct;
+
+    char QIUTx[EGS_ZZZ];
+    const char* QIUTxStr = "QIUTx = ";
+    octet QIUTxOct = {EGS_ZZZ,EGS_ZZZ,QIUTx};
+
+#if CURVETYPE_ZZZ!=MONTGOMERY
+    char QIUTy[EGS_ZZZ];
+    const char* QIUTyStr = "QIUTy = ";
+    octet QIUTyOct = {EGS_ZZZ,EGS_ZZZ,QIUTy};
+#endif
+
+    char * ZIUT = NULL;
+    const char* ZIUTStr = "ZIUT = ";
+    octet ZIUTOct;
+
+    char q[2*EFS_ZZZ+1];
+    octet QOct= {0,sizeof(q),q};
+    char z[EFS_ZZZ];
+    octet ZOct= {0,sizeof(z),z};
+
+    fp = fopen(argv[1], "r");
+    if (fp == NULL)
+    {
+        printf("ERROR opening test vector file\n");
+        exit(EXIT_FAILURE);
+    }
+
+    bool readLine = false;
+    while (fgets(line, LINE_LEN, fp) != NULL)
+    {
+        i++;
+        readLine = true;
+        if (!strncmp(line, QCAVSxStr, strlen(QCAVSxStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(QCAVSxStr);
+
+            // Allocate data
+            l1 = strlen(linePtr)-1;
+
+            // QCAVSx binary value
+            amcl_hex2bin(linePtr, QCAVSx, l1);
+        }
+
+#if CURVETYPE_ZZZ!=MONTGOMERY
+        if (!strncmp(line, QCAVSyStr, strlen(QCAVSyStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(QCAVSyStr);
+
+            // Allocate data
+            l1 = strlen(linePtr)-1;
+
+            // QCAVSy binary value
+            amcl_hex2bin(linePtr, QCAVSy, l1);
+        }
+#endif
+
+        if (!strncmp(line, dIUTStr, strlen(dIUTStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(dIUTStr);
+
+            // Allocate memory
+            l1 = strlen(linePtr)-1;
+            l2 = l1/2;
+            dIUT = (char*) malloc (l2);
+            if (dIUT==NULL)
+                exit(EXIT_FAILURE);
+
+            // dIUT binary value
+            amcl_hex2bin(linePtr, dIUT, l1);
+
+            dIUTOct.len=l2;
+            dIUTOct.max=l2;
+            dIUTOct.val=dIUT;
+        }
+
+        if (!strncmp(line, QIUTxStr, strlen(QIUTxStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(QIUTxStr);
+
+            // Allocate data
+            l1 = strlen(linePtr)-1;
+
+            // QIUTx binary value
+            amcl_hex2bin(linePtr, QIUTx, l1);
+        }
+
+#if CURVETYPE_ZZZ!=MONTGOMERY
+        if (!strncmp(line, QIUTyStr, strlen(QIUTyStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(QIUTyStr);
+
+            // Allocate data
+            l1 = strlen(linePtr)-1;
+
+            // QIUTy binary value
+            amcl_hex2bin(linePtr, QIUTy, l1);
+        }
+#endif
+
+        if (!strncmp(line, ZIUTStr, strlen(ZIUTStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(ZIUTStr);
+
+            // Allocate memory
+            l1 = strlen(linePtr)-1;
+            l2 = l1/2;
+            ZIUT = (char*) malloc (l2);
+            if (ZIUT==NULL)
+                exit(EXIT_FAILURE);
+
+            // ZIUT binary value
+            amcl_hex2bin(linePtr, ZIUT, l1);
+
+            ZIUTOct.len=l2;
+            ZIUTOct.max=l2;
+            ZIUTOct.val=ZIUT;
+
+            // Assign QIUT
+            char q1[2*EFS_ZZZ+1];
+            octet QIUTOct= {0,sizeof(q1),q1};
+#if CURVETYPE_ZZZ!=MONTGOMERY
+            QIUTOct.val[0]=4;
+            QIUTOct.len=1;
+            OCT_joctet(&QIUTOct,&QIUTxOct);
+            OCT_joctet(&QIUTOct,&QIUTyOct);
+#else
+            QIUTOct.val[0]=2;
+            QIUTOct.len=1;
+            OCT_joctet(&QIUTOct,&QIUTxOct);
+#endif
+
+            // Assign QCAVS
+            char q2[2*EFS_ZZZ+1];
+            octet QCAVSOct= {0,sizeof(q2),q2};
+#if CURVETYPE_ZZZ!=MONTGOMERY
+            QCAVSOct.val[0]=4;
+            QCAVSOct.len=1;
+            OCT_joctet(&QCAVSOct,&QCAVSxOct);
+            OCT_joctet(&QCAVSOct,&QCAVSyOct);
+#else
+            QCAVSOct.val[0]=2;
+            QCAVSOct.len=1;
+            OCT_joctet(&QCAVSOct,&QCAVSxOct);
+#endif
+            // Check correct public key generated
+            ECP_ZZZ_KEY_PAIR_GENERATE(NULL,&dIUTOct,&QOct);
+            rc = OCT_comp(&QOct,&QIUTOct);
+            if (!rc)
+            {
+                printf("ERROR: TEST ECDH KEYPAIR FAILED LINE %d\n",i);
+#ifdef DEBUG
+                printf("\nline %d QOct:    ",i);
+                OCT_output(&QOct);
+                printf("\nline %d QIUTOct: ",i);
+                OCT_output(&QIUTOct);
+                printf("\n");
+#endif
+                exit(EXIT_FAILURE);
+            }
+
+            // Check correct shared value generated
+            ECP_ZZZ_SVDP_DH(&dIUTOct,&QCAVSOct,&ZOct);
+            rc = OCT_comp(&ZOct,&ZIUTOct);
+            if (!rc)
+            {
+
+                printf("TEST ECDH Z FAILED LINE %d\n",i);
+#ifdef DEBUG
+                printf("\nline %d ZOct: ",i);
+                OCT_output(&ZOct);
+                printf("\nline %dZIUTOct: ",i);
+                OCT_output(&ZIUTOct);
+                printf("\n");
+#endif
+                exit(EXIT_FAILURE);
+            }
+            free(dIUT);
+            dIUT = NULL;
+            free(ZIUT);
+            ZIUT = NULL;
+        }
+    }
+    fclose(fp);
+    if (!readLine)
+    {
+        printf("ERROR Empty test vector file\n");
+        exit(EXIT_FAILURE);
+    }
+
+// Self test AES-CBC
+    for(i=0; i<20; i++)
+    {
+        OCT_rand(&Key,&rng,AESKEY_ZZZ*2);
+        OCT_rand(&Plaintext,&rng,AESKEY_ZZZ);
+        OCT_copy(&Res,&Plaintext);
+
+        AES_CBC_IV0_ENCRYPT(&Key,&Plaintext,&Ciphertext);
+        rc = AES_CBC_IV0_DECRYPT(&Key,&Ciphertext,&Plaintext);
+        if (!rc || !OCT_comp(&Plaintext,&Res))
+        {
+            printf("ERROR AES_CBC decryption failed\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    printf("SUCCESS TEST ECDH KEYPAIR PASSED\n");
+    exit(EXIT_SUCCESS);
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/test/test_ecdsa_keypair_ZZZ.c.in
----------------------------------------------------------------------
diff --git a/test/test_ecdsa_keypair_ZZZ.c.in b/test/test_ecdsa_keypair_ZZZ.c.in
new file mode 100644
index 0000000..8f8b05d
--- /dev/null
+++ b/test/test_ecdsa_keypair_ZZZ.c.in
@@ -0,0 +1,171 @@
+/**
+ * @file test_ecdsa_keypair_ZZZ.c
+ * @author Kealan McCusker
+ * @brief Test function for ECDSA keypair,
+ *
+ * LICENSE
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* Build executible after installation:
+
+  gcc -std=c99 -g ./test_ecdsa_keypair.c -I/opt/amcl/include -L/opt/amcl/lib 
-lamcl -lecdh -o test_ecdsa_keypair
+
+*/
+
+#include "ecdh_ZZZ.h"
+#include "utils.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define LINE_LEN 300
+// #define DEBUG
+
+int main(int argc, char** argv)
+{
+    if (argc != 2)
+    {
+        printf("usage: ./test_ecdsa_sign_ZZZ [path to test vector file]\n");
+        exit(EXIT_FAILURE);
+    }
+    int rc;
+    FILE * fp = NULL;
+    char line[LINE_LEN];
+    char * linePtr = NULL;
+    int l1=0;
+    int l2=0;
+    char * d = NULL;
+    const char* dStr = "d = ";
+    octet dOct;
+    char Qx[EGS_ZZZ];
+    const char* QxStr = "Qx = ";
+    octet QxOct = {EGS_ZZZ,EGS_ZZZ,Qx};
+    char Qy[EGS_ZZZ];
+    const char* QyStr = "Qy = ";
+    octet QyOct = {EGS_ZZZ,EGS_ZZZ,Qy};
+
+    char q2[2*EFS_ZZZ+1];
+    octet Q2Oct= {0,sizeof(q2),q2};
+
+    fp = fopen(argv[1], "r");
+    if (fp == NULL)
+    {
+        printf("ERROR opening test vector file\n");
+        exit(EXIT_FAILURE);
+    }
+
+    bool readLine = false;
+    int i=0;
+    while (fgets(line, LINE_LEN, fp) != NULL)
+    {
+        i++;
+        readLine = true;
+        if (!strncmp(line, dStr, strlen(dStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(dStr);
+
+            // Allocate memory
+            l1 = strlen(linePtr)-1;
+            l2 = l1/2;
+            d = (char*) malloc (l2);
+            if (d==NULL)
+                exit(EXIT_FAILURE);
+
+            // d binary value
+            amcl_hex2bin(linePtr, d, l1);
+
+            dOct.len=l2;
+            dOct.max=l2;
+            dOct.val=d;
+        }
+
+        if (!strncmp(line, QxStr, strlen(QxStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(QxStr);
+
+            // Allocate data
+            l1 = strlen(linePtr)-1;
+
+            // Qx binary value
+            amcl_hex2bin(linePtr, Qx, l1);
+        }
+
+        if (!strncmp(line, QyStr, strlen(QyStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(QyStr);
+
+            // Allocate data
+            l1 = strlen(linePtr)-1;
+
+            // Qy binary value
+            amcl_hex2bin(linePtr, Qy, l1);
+
+            // Assign Public Key
+            BIG_XXX qx, qy;
+            char q[2*EFS_ZZZ+1];
+            BIG_XXX_fromBytes(qx,QxOct.val);
+            BIG_XXX_fromBytes(qy,QyOct.val);
+            octet QOct= {sizeof(q),sizeof(q),q};
+            QOct.val[0]=4;
+            BIG_XXX_toBytes(&(QOct.val[1]),qx);
+            BIG_XXX_toBytes(&(QOct.val[EFS_ZZZ+1]),qy);
+
+            // Generate Key pair
+            ECP_ZZZ_KEY_PAIR_GENERATE(NULL,&dOct,&Q2Oct);
+
+#ifdef DEBUG
+            printf("QOct: ");
+            OCT_output(&QOct);
+            printf("\r\n");
+            printf("Q2Oct: ");
+            OCT_output(&Q2Oct);
+            printf("\r\n");
+#endif
+            rc = OCT_comp(&QOct,&Q2Oct);
+            if (!rc)
+            {
+                printf("TEST ECDSA KEYPAIR FAILED LINE %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            free(d);
+            d = NULL;
+        }
+    }
+    fclose(fp);
+    if (!readLine)
+    {
+        printf("ERROR Empty test vector file\n");
+        exit(EXIT_FAILURE);
+    }
+    printf("SUCCESS TEST ECDSA KEYPAIR PASSED\n");
+    exit(EXIT_SUCCESS);
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/test/test_ecdsa_sign_ZZZ.c.in
----------------------------------------------------------------------
diff --git a/test/test_ecdsa_sign_ZZZ.c.in b/test/test_ecdsa_sign_ZZZ.c.in
new file mode 100644
index 0000000..40230a3
--- /dev/null
+++ b/test/test_ecdsa_sign_ZZZ.c.in
@@ -0,0 +1,329 @@
+/**
+ * @file test_ecdsa_sign_ZZZ.c
+ * @author Kealan McCusker
+ * @brief Test function for ECDSA signature,
+ *
+ * LICENSE
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* Build executible after installation:
+
+  gcc -std=c99 -g ./test_ecdsa_sign.c -I/opt/amcl/include -L/opt/amcl/lib 
-lamcl -lecdh -o test_ecdsa_sign
+
+*/
+
+#include "ecdh_ZZZ.h"
+#include "utils.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define LINE_LEN 300
+//#define DEBUG
+
+int main(int argc, char** argv)
+{
+    if (argc != 3)
+    {
+        printf("usage: ./test_ecdsa_sign_ZZZ_256/512 [path to test vector 
file] [hash type-sha256||sha384||sha512] \n");
+        exit(EXIT_FAILURE);
+    }
+    int rc;
+    FILE * fp = NULL;
+    char line[LINE_LEN];
+    char * linePtr = NULL;
+    int l1=0;
+    int l2=0;
+    char * Msg = NULL;
+    const char* MsgStr = "Msg = ";
+    octet MsgOct;
+    char * d = NULL;
+    const char* dStr = "d = ";
+    octet dOct;
+    char Qx[EGS_ZZZ];
+    const char* QxStr = "Qx = ";
+    octet QxOct = {EGS_ZZZ,EGS_ZZZ,Qx};
+    char Qy[EGS_ZZZ];
+    const char* QyStr = "Qy = ";
+    octet QyOct = {EGS_ZZZ,EGS_ZZZ,Qy};
+    char * k = NULL;
+    const char* kStr = "k = ";
+    octet kOct;
+    char * R = NULL;
+    const char* RStr = "R = ";
+    octet ROct;
+    char * S = NULL;
+    const char* SStr = "S = ";
+    octet SOct;
+
+    char r2[EGS_ZZZ],s2[EGS_ZZZ];
+    octet R2Oct= {0,sizeof(r2),r2};
+    octet S2Oct= {0,sizeof(s2),s2};
+
+    // Assign hash type
+    int hash_type;
+    if (!strcmp(argv[2], "sha256"))
+    {
+        hash_type = 32;
+    }
+    else if (!strcmp(argv[2], "sha384"))
+    {
+        hash_type = 48;
+    }
+    else if (!strcmp(argv[2], "sha512"))
+    {
+        hash_type = 64;
+    }
+    else
+    {
+        hash_type = 32;
+    }
+
+    fp = fopen(argv[1], "r");
+    if (fp == NULL)
+    {
+        printf("ERROR opening test vector file\n");
+        exit(EXIT_FAILURE);
+    }
+
+    bool readLine = false;
+    int i=0;
+    while (fgets(line, LINE_LEN, fp) != NULL)
+    {
+        i++;
+        readLine = true;
+        if (!strncmp(line, MsgStr, strlen(MsgStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(MsgStr);
+
+            // Allocate memory
+            l1 = strlen(linePtr)-1;
+            l2 = l1/2;
+            Msg = (char*) malloc (l2);
+            if (Msg==NULL)
+                exit(EXIT_FAILURE);
+
+            // Msg binary value
+            amcl_hex2bin(linePtr, Msg, l1);
+
+            MsgOct.len=l2;
+            MsgOct.max=l2;
+            MsgOct.val=Msg;
+        }
+
+        if (!strncmp(line, dStr, strlen(dStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(dStr);
+
+            // Allocate memory
+            l1 = strlen(linePtr)-1;
+            l2 = l1/2;
+            d = (char*) malloc (l2);
+            if (d==NULL)
+                exit(EXIT_FAILURE);
+
+            // d binary value
+            amcl_hex2bin(linePtr, d, l1);
+
+            dOct.len=l2;
+            dOct.max=l2;
+            dOct.val=d;
+        }
+
+        if (!strncmp(line, QxStr, strlen(QxStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(QxStr);
+
+            // Allocate data
+            l1 = strlen(linePtr)-1;
+
+            // Qx binary value
+            amcl_hex2bin(linePtr, Qx, l1);
+        }
+
+        if (!strncmp(line, QyStr, strlen(QyStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(QyStr);
+
+            // Allocate data
+            l1 = strlen(linePtr)-1;
+
+            // Qy binary value
+            amcl_hex2bin(linePtr, Qy, l1);
+        }
+
+        if (!strncmp(line, kStr, strlen(kStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(kStr);
+
+            // Allocate memory
+            l1 = strlen(linePtr)-1;
+            l2 = l1/2;
+            k = (char*) malloc (l2);
+            if (k==NULL)
+                exit(EXIT_FAILURE);
+
+            // k binary value
+            amcl_hex2bin(linePtr, k, l1);
+
+            kOct.len=l2;
+            kOct.max=l2;
+            kOct.val=k;
+        }
+
+        if (!strncmp(line, RStr, strlen(RStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(RStr);
+
+            // Allocate memory
+            l1 = strlen(linePtr)-1;
+            l2 = l1/2;
+            R = (char*) malloc (l2);
+            if (R==NULL)
+                exit(EXIT_FAILURE);
+
+            // R binary value
+            amcl_hex2bin(linePtr, R, l1);
+
+            ROct.len=l2;
+            ROct.max=l2;
+            ROct.val=R;
+        }
+
+        if (!strncmp(line, SStr, strlen(SStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(SStr);
+
+            // Allocate memory
+            l1 = strlen(linePtr)-1;
+            l2 = l1/2;
+            S = (char*) malloc (l2);
+            if (S==NULL)
+                exit(EXIT_FAILURE);
+
+            // S binary value
+            amcl_hex2bin(linePtr, S, l1);
+
+            SOct.len=l2;
+            SOct.max=l2;
+            SOct.val=S;
+
+            // Assign Public Key
+            BIG_XXX qx,qy;
+            char q[2*EFS_ZZZ+1];
+            BIG_XXX_fromBytes(qx,QxOct.val);
+            BIG_XXX_fromBytes(qy,QyOct.val);
+            octet QOct= {sizeof(q),sizeof(q),q};
+            QOct.val[0]=4;
+            BIG_XXX_toBytes(&(QOct.val[1]),qx);
+            BIG_XXX_toBytes(&(QOct.val[EFS_ZZZ+1]),qy);
+
+#ifdef DEBUG
+            printf("hash_type %d\n",hash_type);
+            printf("kOct: ");
+            OCT_output(&kOct);
+            printf("dOct: ");
+            OCT_output(&dOct);
+            printf("MsgOct: ");
+            OCT_output(&MsgOct);
+            printf("\n");
+#endif
+
+            ECP_ZZZ_SP_DSA(hash_type,NULL,&kOct,&dOct,&MsgOct,&R2Oct,&S2Oct);
+
+            rc = OCT_comp(&ROct,&R2Oct);
+            if (!rc)
+            {
+                printf("TEST ECDSA SIGN FAILED COMPARE R LINE %d\n",i);
+#ifdef DEBUG
+                printf("ROct: ");
+                OCT_output(&ROct);
+                printf("\n");
+                printf("R2Oct: ");
+                OCT_output(&R2Oct);
+                printf("\n");
+#endif
+                exit(EXIT_FAILURE);
+            }
+
+            rc = OCT_comp(&SOct,&S2Oct);
+            if (!rc)
+            {
+                printf("TEST ECDSA SIGN FAILED COMPARE S LINE %d\n",i);
+#ifdef DEBUG
+                printf("SOct: ");
+                OCT_output(&SOct);
+                printf("\n");
+                printf("S2Oct: ");
+                OCT_output(&S2Oct);
+                printf("\n");
+#endif
+                exit(EXIT_FAILURE);
+            }
+
+            free(Msg);
+            Msg = NULL;
+            free(d);
+            d = NULL;
+            free(k);
+            k = NULL;
+            free(R);
+            R = NULL;
+            free(S);
+            S = NULL;
+        }
+    }
+    fclose(fp);
+    if (!readLine)
+    {
+        printf("ERROR Empty test vector file\n");
+        exit(EXIT_FAILURE);
+    }
+    printf("SUCCESS TEST ECDSA %s SIGN PASSED\n", argv[2]);
+    exit(EXIT_SUCCESS);
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/test/test_ecdsa_verify_ZZZ.c.in
----------------------------------------------------------------------
diff --git a/test/test_ecdsa_verify_ZZZ.c.in b/test/test_ecdsa_verify_ZZZ.c.in
new file mode 100644
index 0000000..c674a01
--- /dev/null
+++ b/test/test_ecdsa_verify_ZZZ.c.in
@@ -0,0 +1,263 @@
+/**
+ * @file test_ecdsa_verify_ZZZ.c
+ * @author Kealan McCusker
+ * @brief Test function for ECDSA verification,
+ *
+ * LICENSE
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* Build executible after installation:
+
+  gcc -std=c99 -g ./test_ecdsa_verify.c -I/opt/amcl/include -L/opt/amcl/lib 
-lamcl -lecdh -o test_ecdsa_verify
+
+*/
+
+#include "ecdh_ZZZ.h"
+#include "utils.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define LINE_LEN 300
+// #define DEBUG
+
+int main(int argc, char** argv)
+{
+    if (argc != 3)
+    {
+        printf("usage: ./test_ecdsa_sign_ZZZ_256/512 [path to test vector 
file] [hash type: sha256||sha512] \n");
+        exit(EXIT_FAILURE);
+    }
+    int rc;
+    bool pass;
+    FILE * fp = NULL;
+    char line[LINE_LEN];
+    char * linePtr = NULL;
+    int l1=0;
+    int l2=0;
+    char * Msg = NULL;
+    const char* MsgStr = "Msg = ";
+    octet MsgOct;
+    char Qx[EGS_ZZZ];
+    const char* QxStr = "Qx = ";
+    octet QxOct = {EGS_ZZZ,EGS_ZZZ,Qx};
+    char Qy[EGS_ZZZ];
+    const char* QyStr = "Qy = ";
+    octet QyOct = {EGS_ZZZ,EGS_ZZZ,Qy};
+    char * R = NULL;
+    const char* RStr = "R = ";
+    octet ROct;
+    char * S = NULL;
+    const char* SStr = "S = ";
+    octet SOct;
+    const char* ResultStr = "Result = ";
+
+    // Assign hash type
+    int hash_type;
+    if (!strcmp(argv[2], "sha256"))
+    {
+        hash_type = 32;
+    }
+    else if (!strcmp(argv[2], "sha384"))
+    {
+        hash_type = 48;
+    }
+    else if (!strcmp(argv[2], "sha512"))
+    {
+        hash_type = 64;
+    }
+    else
+    {
+        hash_type = 32;
+    }
+
+    fp = fopen(argv[1], "r");
+    if (fp == NULL)
+    {
+        printf("ERROR opening test vector file\n");
+        exit(EXIT_FAILURE);
+    }
+
+    bool readLine = false;
+
+    int i=0;
+    while (fgets(line, LINE_LEN, fp) != NULL)
+    {
+        i++;
+        readLine = true;
+        if (!strncmp(line, MsgStr, strlen(MsgStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(MsgStr);
+
+            // Allocate memory
+            l1 = strlen(linePtr)-1;
+            l2 = l1/2;
+            Msg = (char*) malloc (l2);
+            if (Msg==NULL)
+                exit(EXIT_FAILURE);
+
+            // Msg binary value
+            amcl_hex2bin(linePtr, Msg, l1);
+
+            MsgOct.len=l2;
+            MsgOct.max=l2;
+            MsgOct.val=Msg;
+        }
+
+        if (!strncmp(line, QxStr, strlen(QxStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(QxStr);
+
+            // Allocate data
+            l1 = strlen(linePtr)-1;
+
+            // Qx binary value
+            amcl_hex2bin(linePtr, Qx, l1);
+        }
+
+        if (!strncmp(line, QyStr, strlen(QyStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(QyStr);
+
+            // Allocate data
+            l1 = strlen(linePtr)-1;
+
+            // Qy binary value
+            amcl_hex2bin(linePtr, Qy, l1);
+        }
+
+        if (!strncmp(line, RStr, strlen(RStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(RStr);
+
+            // Allocate memory
+            l1 = strlen(linePtr)-1;
+            l2 = l1/2;
+            R = (char*) malloc (l2);
+            if (R==NULL)
+                exit(EXIT_FAILURE);
+
+            // R binary value
+            amcl_hex2bin(linePtr, R, l1);
+
+            ROct.len=l2;
+            ROct.max=l2;
+            ROct.val=R;
+        }
+
+        if (!strncmp(line, SStr, strlen(SStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            // Find hex value in string
+            linePtr = line + strlen(SStr);
+
+            // Allocate memory
+            l1 = strlen(linePtr)-1;
+            l2 = l1/2;
+            S = (char*) malloc (l2);
+            if (S==NULL)
+                exit(EXIT_FAILURE);
+
+            // S binary value
+            amcl_hex2bin(linePtr, S, l1);
+
+            SOct.len=l2;
+            SOct.max=l2;
+            SOct.val=S;
+        }
+
+        if (!strncmp(line, ResultStr, strlen(ResultStr)))
+        {
+#ifdef DEBUG
+            printf("line %d %s\n", i,line);
+#endif
+            linePtr = line + strlen(ResultStr);
+            char r1[1];
+            char r2[1] = {"P"};
+            strncpy(r1,linePtr,1);
+            if (r1[0] == r2[0])
+            {
+                pass = true;
+            }
+            else
+            {
+                pass = false;
+            }
+
+            // Assign Public Key to EC
+            BIG_XXX qx, qy;
+            char q[2*EFS_ZZZ+1];
+            BIG_XXX_fromBytes(qx,QxOct.val);
+            BIG_XXX_fromBytes(qy,QyOct.val);
+            octet QOct= {sizeof(q),sizeof(q),q};
+            QOct.val[0]=4;
+            BIG_XXX_toBytes(&(QOct.val[1]),qx);
+            BIG_XXX_toBytes(&(QOct.val[EFS_ZZZ+1]),qy);
+
+            rc = ECP_ZZZ_VP_DSA(hash_type,&QOct,&MsgOct,&ROct,&SOct);
+            // Test expected to pass. rc is true for fail
+            if ( pass && rc )
+            {
+                printf("TEST ECDSA VERIFY FAILED LINE %d pass %d rc 
%d\n",i,pass,rc);
+                exit(EXIT_FAILURE);
+            }
+
+            // Test expected to fail
+            if ( !pass && !rc )
+            {
+                printf("TEST ECDSA VERIFY FAILED LINE %d pass %d rc 
%d\n",i,pass,rc);
+                exit(EXIT_FAILURE);
+            }
+
+            free(Msg);
+            Msg = NULL;
+            free(R);
+            R = NULL;
+            free(S);
+            S = NULL;
+        }
+    }
+    fclose(fp);
+    if (!readLine)
+    {
+        printf("ERROR Empty test vector file\n");
+        exit(EXIT_FAILURE);
+    }
+    printf("SUCCESS TEST ECDSA %s VERIFY PASSED\n", argv[2]);
+    exit(EXIT_SUCCESS);
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/test/test_ecp2_arithmetics_ZZZ.c.in
----------------------------------------------------------------------
diff --git a/test/test_ecp2_arithmetics_ZZZ.c.in 
b/test/test_ecp2_arithmetics_ZZZ.c.in
new file mode 100644
index 0000000..06be072
--- /dev/null
+++ b/test/test_ecp2_arithmetics_ZZZ.c.in
@@ -0,0 +1,400 @@
+/**
+ * @file test_ecp2_arithmetics_ZZZ.c
+ * @author Alessandro Budroni
+ * @brief Test for aritmetics with ECP2_ZZZ
+ *
+ * LICENSE
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "arch.h"
+#include "amcl.h"
+#include "utils.h"
+#include "ecp2_ZZZ.h"
+
+#define LINE_LEN 1000
+#define MAX_STRING 1000
+
+void read_BIG_XXX(BIG_XXX A, char* string)
+{
+    int len;
+    char bin[LINE_LEN];
+    BIG_XXX_zero(A);
+    len = strlen(string)+1;
+    amcl_hex2bin(string,bin,len);
+    len = (len-1)/2;;
+    BIG_XXX_fromBytesLen(A,bin,len);
+    BIG_XXX_norm(A);
+}
+
+
+int read_ECP2_ZZZ(ECP2_ZZZ *ecp2, char* stringx1)
+{
+    char *stringx2, *stringy1, *stringy2;
+    BIG_XXX x1,x2,y1,y2;
+    FP2_YYY x,y;
+
+    stringx2 = strchr(stringx1,':');
+    stringx2[0] = '\0';
+    stringx2++;
+    stringy1 = strchr(stringx2,'&');
+    stringy1[0] = '\0';
+    stringy1++;
+    stringy2 = strchr(stringy1,':');
+    stringy2[0] = '\0';
+    stringy2++;
+
+    read_BIG_XXX(x1,stringx1);
+    read_BIG_XXX(x2,stringx2);
+    read_BIG_XXX(y1,stringy1);
+    read_BIG_XXX(y2,stringy2);
+
+    FP2_YYY_from_BIGs(&x,x1,x2);
+    FP2_YYY_from_BIGs(&y,y1,y2);
+
+    return ECP2_ZZZ_set(ecp2,&x,&y);
+}
+
+int main(int argc, char** argv)
+{
+    if (argc != 2)
+    {
+        printf("usage: ./test_ecp2_arithmetics_ZZZ [path to test vector 
file]\n");
+        exit(EXIT_FAILURE);
+    }
+
+    int i=0, len=0;
+
+    char line[LINE_LEN];
+    char * linePtr = NULL;
+
+    ECP2_ZZZ ECP2aux1, ECP2aux2, inf;
+    FP2_YYY FP2aux1,FP2aux2;
+
+    char oct[LINE_LEN];
+    octet OCTaux= {0,sizeof(oct),oct};
+
+    ECP2_ZZZ ecp2[4];
+    const char* ECP21line = "ECP21 = ";
+    const char* ECP22line = "ECP22 = ";
+    const char* ECP23line = "ECP23 = ";
+    const char* ECP24line = "ECP24 = ";
+    ECP2_ZZZ ecp2sum;
+    const char* ECP2sumline = "ECP2sum = ";
+    ECP2_ZZZ ecp2neg;
+    const char* ECP2negline = "ECP2neg = ";
+    ECP2_ZZZ ecp2sub;
+    const char* ECP2subline = "ECP2sub = ";
+    ECP2_ZZZ ecp2dbl;
+    const char* ECP2dblline = "ECP2dbl = ";
+    BIG_XXX BIGscalar[4];
+    const char* BIGscalar1line = "BIGscalar1 = ";
+    const char* BIGscalar2line = "BIGscalar2 = ";
+    const char* BIGscalar3line = "BIGscalar3 = ";
+    const char* BIGscalar4line = "BIGscalar4 = ";
+    ECP2_ZZZ ecp2mul;
+    const char* ECP2mulline = "ECP2mul = ";
+    ECP2_ZZZ ecp2mul4;
+    const char* ECP2mul4line = "ECP2mul4 = ";
+    ECP2_ZZZ ecp2wrong;
+    const char* ECP2wrongline = "ECP2wrong = ";
+    ECP2_ZZZ ecp2inf;
+    const char* ECP2infline = "ECP2inf = ";
+    ECP2_ZZZ ecp2set1;
+    const char* ECP2set1line = "ECP2set1 = ";
+    ECP2_ZZZ ecp2set2;
+    const char* ECP2set2line = "ECP2set2 = ";
+
+    ECP2_ZZZ_inf(&inf);
+
+    if(!ECP2_ZZZ_isinf(&inf))
+    {
+        printf("ERROR setting ECP2_ZZZ to infinity\n");
+        exit(EXIT_FAILURE);
+    }
+
+    FILE *fp;
+    fp = fopen(argv[1],"r");
+    if (fp == NULL)
+    {
+        printf("ERROR opening test vector file\n");
+        exit(EXIT_FAILURE);
+    }
+
+    while (fgets(line, LINE_LEN, fp) != NULL)
+    {
+        i++;
+        if (!strncmp(line,  ECP21line, strlen(ECP21line)))
+        {
+            len = strlen(ECP21line);
+            linePtr = line + len;
+            if(!read_ECP2_ZZZ(&ecp2[0],linePtr) || ECP2_ZZZ_isinf(&ecp2[0]))
+            {
+                printf("ERROR getting test vector input ECP2_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP2_ZZZ_get(&FP2aux1,&FP2aux2,&ecp2[0]);
+            FP2_YYY_sqr(&FP2aux2,&FP2aux2);
+            ECP2_ZZZ_rhs(&FP2aux1,&FP2aux1);
+            if (!FP2_YYY_equals(&FP2aux1,&FP2aux2))
+            {
+                printf("ERROR computing right hand side of equation ECP, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP2_ZZZ_toOctet(&OCTaux,&ecp2[0]);
+            ECP2_ZZZ_fromOctet(&ECP2aux1,&OCTaux);
+            if(!ECP2_ZZZ_equals(&ECP2aux1,&ecp2[0]))
+            {
+                printf("ERROR converting ECP2_ZZZ to/from OCTET, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP22line, strlen(ECP22line)))
+        {
+            len = strlen(ECP22line);
+            linePtr = line + len;
+            if(!read_ECP2_ZZZ(&ecp2[1],linePtr) || ECP2_ZZZ_isinf(&ecp2[1]))
+            {
+                printf("ERROR getting test vector input ECP2_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP23line, strlen(ECP23line)))
+        {
+            len = strlen(ECP23line);
+            linePtr = line + len;
+            if(!read_ECP2_ZZZ(&ecp2[2],linePtr) || ECP2_ZZZ_isinf(&ecp2[2]))
+            {
+                printf("ERROR getting test vector input ECP2_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP24line, strlen(ECP24line)))
+        {
+            len = strlen(ECP24line);
+            linePtr = line + len;
+            if(!read_ECP2_ZZZ(&ecp2[3],linePtr) || ECP2_ZZZ_isinf(&ecp2[3]))
+            {
+                printf("ERROR getting test vector input ECP2_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP2sumline, strlen(ECP2sumline)))
+        {
+            len = strlen(ECP2sumline);
+            linePtr = line + len;
+            if(!read_ECP2_ZZZ(&ecp2sum,linePtr))
+            {
+                printf("ERROR reading test vector input ECP2_ZZZs, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP2_ZZZ_copy(&ECP2aux1,&ecp2[0]);
+            ECP2_ZZZ_add(&ECP2aux1,&ecp2[1]);
+            ECP2_ZZZ_affine(&ECP2aux1);
+            ECP2_ZZZ_copy(&ECP2aux2,&ecp2[1]); // testing commutativity P+Q = 
Q+P
+            ECP2_ZZZ_add(&ECP2aux2,&ecp2[0]);
+            ECP2_ZZZ_affine(&ECP2aux2);
+            if(!ECP2_ZZZ_equals(&ECP2aux1,&ecp2sum) || 
!ECP2_ZZZ_equals(&ECP2aux2,&ecp2sum))
+            {
+                printf("ERROR adding two ECP2_ZZZs, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP2_ZZZ_copy(&ECP2aux1,&ecp2[0]); // testing associativity 
(P+Q)+R = P+(Q+R)
+            ECP2_ZZZ_add(&ECP2aux1,&ecp2[1]);
+            ECP2_ZZZ_add(&ECP2aux1,&ecp2[2]);
+            ECP2_ZZZ_affine(&ECP2aux1);
+            ECP2_ZZZ_copy(&ECP2aux2,&ecp2[2]);
+            ECP2_ZZZ_add(&ECP2aux2,&ecp2[1]);
+            ECP2_ZZZ_add(&ECP2aux2,&ecp2[0]);
+            ECP2_ZZZ_affine(&ECP2aux2);
+            if(!ECP2_ZZZ_equals(&ECP2aux1,&ECP2aux2))
+            {
+                printf("ERROR testing associativity bewtween three ECP2_ZZZs, 
line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP2negline, strlen(ECP2negline)))
+        {
+            len = strlen(ECP2negline);
+            linePtr = line + len;
+            if(!read_ECP2_ZZZ(&ecp2neg,linePtr))
+            {
+                printf("ERROR getting test vector input ECP2_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP2_ZZZ_copy(&ECP2aux1,&ecp2[0]);
+            ECP2_ZZZ_neg(&ECP2aux1);
+            ECP2_ZZZ_affine(&ECP2aux1);
+            if(!ECP2_ZZZ_equals(&ECP2aux1,&ecp2neg))
+            {
+                printf("ERROR computing negative of ECP2_ZZZ, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP2subline, strlen(ECP2subline)))
+        {
+            len = strlen(ECP2subline);
+            linePtr = line + len;
+            if(!read_ECP2_ZZZ(&ecp2sub,linePtr))
+            {
+                printf("ERROR getting test vector input ECP2_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP2_ZZZ_copy(&ECP2aux1,&ecp2[0]);
+            ECP2_ZZZ_sub(&ECP2aux1,&ecp2[1]);
+            ECP2_ZZZ_affine(&ECP2aux1);
+            if(!ECP2_ZZZ_equals(&ECP2aux1,&ecp2sub))
+            {
+                printf("ERROR performing subtraction bewtween two ECP2_ZZZs, 
line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP2dblline, strlen(ECP2dblline)))
+        {
+            len = strlen(ECP2dblline);
+            linePtr = line + len;
+            if(!read_ECP2_ZZZ(&ecp2dbl,linePtr))
+            {
+                printf("ERROR getting test vector input ECP2_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP2_ZZZ_copy(&ECP2aux1,&ecp2[0]);
+            ECP2_ZZZ_dbl(&ECP2aux1);
+            ECP2_ZZZ_affine(&ECP2aux1);
+            if(!ECP2_ZZZ_equals(&ECP2aux1,&ecp2dbl))
+            {
+                printf("ERROR computing double of ECP2_ZZZ, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  BIGscalar1line, strlen(BIGscalar1line)))
+        {
+            len = strlen(BIGscalar1line);
+            linePtr = line + len;
+            read_BIG_XXX(BIGscalar[0],linePtr);
+        }
+        if (!strncmp(line,  BIGscalar2line, strlen(BIGscalar2line)))
+        {
+            len = strlen(BIGscalar2line);
+            linePtr = line + len;
+            read_BIG_XXX(BIGscalar[1],linePtr);
+        }
+        if (!strncmp(line,  BIGscalar3line, strlen(BIGscalar3line)))
+        {
+            len = strlen(BIGscalar3line);
+            linePtr = line + len;
+            read_BIG_XXX(BIGscalar[2],linePtr);
+        }
+        if (!strncmp(line,  BIGscalar4line, strlen(BIGscalar4line)))
+        {
+            len = strlen(BIGscalar4line);
+            linePtr = line + len;
+            read_BIG_XXX(BIGscalar[3],linePtr);
+        }
+        if (!strncmp(line,  ECP2mulline, strlen(ECP2mulline)))
+        {
+            len = strlen(ECP2mulline);
+            linePtr = line + len;
+            if(!read_ECP2_ZZZ(&ecp2mul,linePtr))
+            {
+                printf("ERROR getting test vector input ECP2_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP2_ZZZ_copy(&ECP2aux1,&ecp2[0]);
+            ECP2_ZZZ_mul(&ECP2aux1,BIGscalar[0]);
+            ECP2_ZZZ_affine(&ECP2aux1);
+            if(!ECP2_ZZZ_equals(&ECP2aux1,&ecp2mul))
+            {
+                printf("ERROR computing multiplication of ECP2_ZZZ by a 
scalar, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP2mul4line, strlen(ECP2mul4line)))
+        {
+            len = strlen(ECP2mul4line);
+            linePtr = line + len;
+            if(!read_ECP2_ZZZ(&ecp2mul4,linePtr))
+            {
+                printf("ERROR getting test vector input ECP2_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP2_ZZZ_mul4(&ECP2aux1,ecp2,BIGscalar);
+            ECP2_ZZZ_affine(&ECP2aux1);
+            if(!ECP2_ZZZ_equals(&ECP2aux1,&ecp2mul4))
+            {
+                printf("ERROR computing linear combination of 4 ECP2_ZZZs, 
line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP2wrongline, strlen(ECP2wrongline)))
+        {
+            len = strlen(ECP2wrongline);
+            linePtr = line + len;
+            if(read_ECP2_ZZZ(&ecp2wrong,linePtr) || 
!ECP2_ZZZ_isinf(&ecp2wrong) || !ECP2_ZZZ_equals(&ecp2wrong,&inf))
+            {
+                printf("ERROR identifying a wrong ECP2_ZZZ, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP2infline, strlen(ECP2infline)))
+        {
+            len = strlen(ECP2infline);
+            linePtr = line + len;
+            if(read_ECP2_ZZZ(&ecp2inf,linePtr) || !ECP2_ZZZ_isinf(&ecp2inf) || 
!ECP2_ZZZ_equals(&ecp2inf,&inf))
+            {
+                printf("ERROR identifying infinite point ECP2_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP2set1line, strlen(ECP2set1line)))
+        {
+            len = strlen(ECP2set1line);
+            linePtr = line + len;
+            if(!read_ECP2_ZZZ(&ecp2set1,linePtr))
+            {
+                printf("ERROR getting test vector input ECP2_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP2_ZZZ_get(&FP2aux1,&FP2aux2,&ecp2[0]);
+            ECP2_ZZZ_setx(&ECP2aux1,&FP2aux1);
+        }
+        if (!strncmp(line,  ECP2set2line, strlen(ECP2set2line)))
+        {
+            len = strlen(ECP2set2line);
+            linePtr = line + len;
+            if(!read_ECP2_ZZZ(&ecp2set2,linePtr))
+            {
+                printf("ERROR getting test vector input ECP2_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            if((!ECP2_ZZZ_equals(&ECP2aux1,&ecp2set2)) && 
(!ECP2_ZZZ_equals(&ECP2aux1,&ecp2set1)))
+            {
+                printf("ERROR computing ECP2_ZZZ from coordinate x and with y 
set2, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+    }
+    fclose(fp);
+
+    printf("SUCCESS TEST ARITMETIC OF ECP2_ZZZ PASSED\n");
+    exit(EXIT_SUCCESS);
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/test/test_ecp4_arithmetics_ZZZ.c.in
----------------------------------------------------------------------
diff --git a/test/test_ecp4_arithmetics_ZZZ.c.in 
b/test/test_ecp4_arithmetics_ZZZ.c.in
new file mode 100644
index 0000000..3bc07fd
--- /dev/null
+++ b/test/test_ecp4_arithmetics_ZZZ.c.in
@@ -0,0 +1,413 @@
+/**
+ * @file test_ecp4_arithmetics_ZZZ.c
+ * @author Alessandro Budroni
+ * @brief Test for aritmetics with ECP4_ZZZ
+ *
+ * LICENSE
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "arch.h"
+#include "amcl.h"
+#include "utils.h"
+#include "ecp4_ZZZ.h"
+
+#define LINE_LEN 1000
+
+void read_BIG_XXX(BIG_XXX A, char* string, int len)
+{
+    char bin[MODBYTES_XXX];
+    amcl_hex2bin(string,bin,len);
+    BIG_XXX_fromBytes(A,bin);
+}
+
+void read_FP2_ZZZ(FP2_YYY *fp2, char* str)
+{
+    BIG_XXX X,Y;
+
+    read_BIG_XXX(X,str,2*MODBYTES_XXX);
+    read_BIG_XXX(Y,str+2*MODBYTES_XXX,2*MODBYTES_XXX);
+
+    FP2_YYY_from_BIGs(fp2,X,Y);
+}
+
+int read_ECP4_ZZZ(ECP4_ZZZ *ecp4, char* str)
+{
+    char octstr[8*MODBYTES_XXX];
+    octet OCTstr = {sizeof(octstr),sizeof(octstr),octstr};
+
+    amcl_hex2bin(str,OCTstr.val,strlen(str));
+    return ECP4_ZZZ_fromOctet(ecp4,&OCTstr);
+}
+
+int main(int argc, char** argv)
+{
+    if (argc != 2)
+    {
+        printf("usage: ./test_ecp4_arithmetics_ZZZ [path to test vector 
file]\n");
+        exit(EXIT_FAILURE);
+    }
+
+    int i=0, k, len=0;
+
+    char line[LINE_LEN];
+    char * linePtr = NULL;
+
+    ECP4_ZZZ ECP4aux1, ECP4aux2, inf;
+    FP4_YYY FP4aux1,FP4aux2;
+
+    char oct[LINE_LEN];
+    octet OCTaux= {0,sizeof(oct),oct};
+
+    ECP4_ZZZ ecp41, ecp4frobs[8];
+    const char* ECP41line = "ECP41 = ";
+    ECP4_ZZZ ecp42;
+    const char* ECP42line = "ECP42 = ";
+    ECP4_ZZZ ecp4sum;
+    const char* ECP4sumline = "ECP4sum = ";
+    ECP4_ZZZ ecp4neg;
+    const char* ECP4negline = "ECP4neg = ";
+    ECP4_ZZZ ecp4sub;
+    const char* ECP4subline = "ECP4sub = ";
+    ECP4_ZZZ ecp4dbl;
+    const char* ECP4dblline = "ECP4dbl = ";
+    BIG_XXX BIGscalar[8];
+    const char* BIGscalarlines[8] =
+    {
+        "BIGscalar1 = ",
+        "BIGscalar2 = ",
+        "BIGscalar3 = ",
+        "BIGscalar4 = ",
+        "BIGscalar5 = ",
+        "BIGscalar6 = ",
+        "BIGscalar7 = ",
+        "BIGscalar8 = "
+    };
+    ECP4_ZZZ ecp4mul;
+    const char* ECP4mulline = "ECP4mul = ";
+    FP2_YYY fp2fr;
+    const char* FP2frline[3] =
+    {
+        "FP2fr1 = ",
+        "FP2fr2 = ",
+        "FP2fr3 = "
+    };
+    ECP4_ZZZ ecp4frob;
+    const char* ECP4frobline = "ECP4frob = ";
+    ECP4_ZZZ ecp4mul8;
+    const char* ECP4mul8line = "ECP4mul8 = ";
+    ECP4_ZZZ ecp4wrong;
+    const char* ECP4wrongline = "ECP4wrong = ";
+    ECP4_ZZZ ecp4inf;
+    const char* ECP4infline = "ECP4inf = ";
+    ECP4_ZZZ ecp4set1;
+    const char* ECP4set1line = "ECP4set1 = ";
+    ECP4_ZZZ ecp4set2;
+    const char* ECP4set2line = "ECP4set2 = ";
+
+    FP2_YYY F[3];
+    ECP4_ZZZ_frob_constants(F);
+
+    ECP4_ZZZ_inf(&inf);
+
+    if(!ECP4_ZZZ_isinf(&inf))
+    {
+        printf("ERROR setting ECP4_ZZZ to infinity\n");
+        exit(EXIT_FAILURE);
+    }
+
+    FILE *fp;
+    fp = fopen(argv[1],"r");
+    if (fp == NULL)
+    {
+        printf("ERROR opening test vector file\n");
+        exit(EXIT_FAILURE);
+    }
+
+    while (fgets(line, LINE_LEN, fp) != NULL)
+    {
+        i++;
+        if (!strncmp(line,  ECP41line, strlen(ECP41line)))
+        {
+            len = strlen(ECP41line);
+            linePtr = line + len;
+            if(!read_ECP4_ZZZ(&ecp41,linePtr) || ECP4_ZZZ_isinf(&ecp41))
+            {
+                printf("ERROR getting test vector input ECP4_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP4_ZZZ_get(&FP4aux1,&FP4aux2,&ecp41);
+            FP4_YYY_sqr(&FP4aux2,&FP4aux2);
+            ECP4_ZZZ_rhs(&FP4aux1,&FP4aux1);
+            if (!FP4_YYY_equals(&FP4aux1,&FP4aux2))
+            {
+                printf("ERROR computing right hand side of equation ECP, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP4_ZZZ_toOctet(&OCTaux,&ecp41);
+            ECP4_ZZZ_fromOctet(&ECP4aux1,&OCTaux);
+            ECP4_ZZZ_reduce(&ECP4aux1);
+            if(!ECP4_ZZZ_equals(&ECP4aux1,&ecp41))
+            {
+                printf("ERROR converting ECP4_ZZZ to/from OCTET, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP4_ZZZ_copy(ecp4frobs,&ecp41);
+            for(k=1; k<8; k++)
+            {
+                ECP4_ZZZ_copy(ecp4frobs+k,ecp4frobs+k-1);
+                ECP4_ZZZ_frob(ecp4frobs+k,F,1);
+            }
+        }
+        if (!strncmp(line,  ECP42line, strlen(ECP42line)))
+        {
+            len = strlen(ECP42line);
+            linePtr = line + len;
+            if(!read_ECP4_ZZZ(&ecp42,linePtr) || ECP4_ZZZ_isinf(&ecp42))
+            {
+                printf("ERROR getting test vector input ECP4_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP4sumline, strlen(ECP4sumline)))
+        {
+            len = strlen(ECP4sumline);
+            linePtr = line + len;
+            if(!read_ECP4_ZZZ(&ecp4sum,linePtr))
+            {
+                printf("ERROR reading test vector input ECP4_ZZZs, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP4_ZZZ_copy(&ECP4aux1,&ecp41);
+            ECP4_ZZZ_add(&ECP4aux1,&ecp42);
+            ECP4_ZZZ_reduce(&ECP4aux1);
+            ECP4_ZZZ_affine(&ECP4aux1);
+            ECP4_ZZZ_copy(&ECP4aux2,&ecp42); // testing commutativity P+Q = Q+P
+            ECP4_ZZZ_add(&ECP4aux2,&ecp41);
+            ECP4_ZZZ_reduce(&ECP4aux1);
+            ECP4_ZZZ_affine(&ECP4aux2);
+            if(!ECP4_ZZZ_equals(&ECP4aux1,&ecp4sum) || 
!ECP4_ZZZ_equals(&ECP4aux2,&ecp4sum))
+            {
+                printf("ERROR adding two ECP4_ZZZs, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP4_ZZZ_copy(&ECP4aux1,&ecp41); // testing associativity (P+Q)+R 
= P+(Q+R)
+            ECP4_ZZZ_add(&ECP4aux1,&ecp42);
+            ECP4_ZZZ_add(&ECP4aux1,ecp4frobs+2);
+            ECP4_ZZZ_affine(&ECP4aux1);
+            ECP4_ZZZ_copy(&ECP4aux2,ecp4frobs+2);
+            ECP4_ZZZ_add(&ECP4aux2,&ecp42);
+            ECP4_ZZZ_add(&ECP4aux2,&ecp41);
+            ECP4_ZZZ_affine(&ECP4aux2);
+            if(!ECP4_ZZZ_equals(&ECP4aux1,&ECP4aux2))
+            {
+                printf("ERROR testing associativity bewtween three ECP4_ZZZs, 
line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP4negline, strlen(ECP4negline)))
+        {
+            len = strlen(ECP4negline);
+            linePtr = line + len;
+            if(!read_ECP4_ZZZ(&ecp4neg,linePtr))
+            {
+                printf("ERROR getting test vector input ECP4_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP4_ZZZ_copy(&ECP4aux1,&ecp41);
+            ECP4_ZZZ_neg(&ECP4aux1);
+            ECP4_ZZZ_affine(&ECP4aux1);
+            if(!ECP4_ZZZ_equals(&ECP4aux1,&ecp4neg))
+            {
+                printf("ERROR computing negative of ECP4_ZZZ, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP4subline, strlen(ECP4subline)))
+        {
+            len = strlen(ECP4subline);
+            linePtr = line + len;
+            if(!read_ECP4_ZZZ(&ecp4sub,linePtr))
+            {
+                printf("ERROR getting test vector input ECP4_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP4_ZZZ_copy(&ECP4aux1,&ecp41);
+            ECP4_ZZZ_sub(&ECP4aux1,&ecp42);
+            ECP4_ZZZ_affine(&ECP4aux1);
+            if(!ECP4_ZZZ_equals(&ECP4aux1,&ecp4sub))
+            {
+                printf("ERROR performing subtraction bewtween two ECP4_ZZZs, 
line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP4dblline, strlen(ECP4dblline)))
+        {
+            len = strlen(ECP4dblline);
+            linePtr = line + len;
+            if(!read_ECP4_ZZZ(&ecp4dbl,linePtr))
+            {
+                printf("ERROR getting test vector input ECP4_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP4_ZZZ_copy(&ECP4aux1,&ecp41);
+            ECP4_ZZZ_dbl(&ECP4aux1);
+            ECP4_ZZZ_affine(&ECP4aux1);
+            if(!ECP4_ZZZ_equals(&ECP4aux1,&ecp4dbl))
+            {
+                printf("ERROR computing double of ECP4_ZZZ, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        for(k=0; k<8; k++)
+        {
+            if (!strncmp(line,  BIGscalarlines[k], strlen(BIGscalarlines[k])))
+            {
+                len = strlen(BIGscalarlines[k]);
+                linePtr = line + len;
+                read_BIG_XXX(BIGscalar[k],linePtr,strlen(linePtr));
+            }
+        }
+        if (!strncmp(line,  ECP4mulline, strlen(ECP4mulline)))
+        {
+            len = strlen(ECP4mulline);
+            linePtr = line + len;
+            if(!read_ECP4_ZZZ(&ecp4mul,linePtr))
+            {
+                printf("ERROR getting test vector input ECP4_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP4_ZZZ_copy(&ECP4aux1,&ecp41);
+            ECP4_ZZZ_mul(&ECP4aux1,BIGscalar[0]);
+            ECP4_ZZZ_affine(&ECP4aux1);
+            if(!ECP4_ZZZ_equals(&ECP4aux1,&ecp4mul))
+            {
+                printf("ERROR computing multiplication of ECP4_ZZZ by a 
scalar, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        for (k=0; k<3; k++)
+        {
+            if(!strncmp(line, FP2frline[k], strlen(FP2frline[k])))
+            {
+                len = strlen(FP2frline[k]);
+                linePtr = line+len;
+                read_FP2_ZZZ(&fp2fr,linePtr);
+
+                if(!FP2_YYY_equals(&fp2fr,F+k))
+                {
+                    printf("ERROR computing %d-th frobenius constant, line 
%d\n",k+1,i);
+                    exit(EXIT_FAILURE);
+                }
+            }
+        }
+        if(!strncmp(line, ECP4frobline, strlen(ECP4frobline)))
+        {
+            len = strlen(ECP4frobline);
+            linePtr = line+len;
+            read_ECP4_ZZZ(&ecp4frob,linePtr);
+
+            ECP4_ZZZ_copy(&ECP4aux1,&ecp41);
+            ECP4_ZZZ_frob(&ECP4aux1,F,3);
+
+            if(!ECP4_ZZZ_equals(&ecp4frob,&ECP4aux1))
+            {
+                printf("ERROR computing frobenius action (P^3), line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP4mul8line, strlen(ECP4mul8line)))
+        {
+            len = strlen(ECP4mul8line);
+            linePtr = line + len;
+            if(!read_ECP4_ZZZ(&ecp4mul8,linePtr))
+            {
+                printf("ERROR getting test vector input ECP4_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+
+            ECP4_ZZZ_mul8(&ECP4aux1,ecp4frobs,BIGscalar);
+            ECP4_ZZZ_affine(&ECP4aux1);
+
+            if(!ECP4_ZZZ_equals(&ECP4aux1,&ecp4mul8))
+            {
+                printf("ERROR computing linear combination of 8 ECP4_ZZZs, 
line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP4wrongline, strlen(ECP4wrongline)))
+        {
+            len = strlen(ECP4wrongline);
+            linePtr = line + len;
+            if(read_ECP4_ZZZ(&ecp4wrong,linePtr) || 
!ECP4_ZZZ_isinf(&ecp4wrong) || !ECP4_ZZZ_equals(&ecp4wrong,&inf))
+            {
+                printf("ERROR identifying a wrong ECP4_ZZZ, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            if(ECP4_ZZZ_setx(&ECP4aux1,&ecp4wrong.x))
+            {
+                printf("ERROR identifying a wrong ECP4_ZZZ x, line %d\n",i);
+            }
+        }
+        if (!strncmp(line,  ECP4infline, strlen(ECP4infline)))
+        {
+            len = strlen(ECP4infline);
+            linePtr = line + len;
+            if(read_ECP4_ZZZ(&ecp4inf,linePtr) || !ECP4_ZZZ_isinf(&ecp4inf) || 
!ECP4_ZZZ_equals(&ecp4inf,&inf))
+            {
+                printf("ERROR identifying infinite point ECP4_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP4set1line, strlen(ECP4set1line)))
+        {
+            len = strlen(ECP4set1line);
+            linePtr = line + len;
+            if(!read_ECP4_ZZZ(&ecp4set1,linePtr))
+            {
+                printf("ERROR getting test vector input ECP4_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP4_ZZZ_get(&FP4aux1,&FP4aux2,&ecp41);
+            ECP4_ZZZ_setx(&ECP4aux1,&FP4aux1);
+        }
+        if (!strncmp(line,  ECP4set2line, strlen(ECP4set2line)))
+        {
+            len = strlen(ECP4set2line);
+            linePtr = line + len;
+            if(!read_ECP4_ZZZ(&ecp4set2,linePtr))
+            {
+                printf("ERROR getting test vector input ECP4_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            if((!ECP4_ZZZ_equals(&ECP4aux1,&ecp4set2)) && 
(!ECP4_ZZZ_equals(&ECP4aux1,&ecp4set1)))
+            {
+                printf("ERROR computing ECP4_ZZZ from coordinate x and with y 
set2, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+    }
+    fclose(fp);
+
+    printf("SUCCESS TEST ARITMETIC OF ECP4_ZZZ PASSED\n");
+    exit(EXIT_SUCCESS);
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/test/test_ecp8_arithmetics_ZZZ.c.in
----------------------------------------------------------------------
diff --git a/test/test_ecp8_arithmetics_ZZZ.c.in 
b/test/test_ecp8_arithmetics_ZZZ.c.in
new file mode 100644
index 0000000..5847300
--- /dev/null
+++ b/test/test_ecp8_arithmetics_ZZZ.c.in
@@ -0,0 +1,416 @@
+/**
+ * @file test_ecp8_arithmetics_ZZZ.c
+ * @author Alessandro Budroni
+ * @brief Test for aritmetics with ECP8_ZZZ
+ *
+ * LICENSE
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "arch.h"
+#include "amcl.h"
+#include "utils.h"
+#include "ecp8_ZZZ.h"
+
+#define LINE_LEN 3000
+
+void read_BIG_XXX(BIG_XXX A, char* string, int len)
+{
+    char bin[MODBYTES_XXX];
+    amcl_hex2bin(string,bin,len);
+    BIG_XXX_fromBytes(A,bin);
+}
+
+void read_FP2_ZZZ(FP2_YYY *fp2, char* str)
+{
+    BIG_XXX X,Y;
+
+    read_BIG_XXX(X,str,2*MODBYTES_XXX);
+    read_BIG_XXX(Y,str+2*MODBYTES_XXX,2*MODBYTES_XXX);
+
+    FP2_YYY_from_BIGs(fp2,X,Y);
+}
+
+int read_ECP8_ZZZ(ECP8_ZZZ *ecp8, char* str)
+{
+    char octstr[16*MODBYTES_XXX];
+    octet OCTstr = {sizeof(octstr),sizeof(octstr),octstr};
+
+    amcl_hex2bin(str,OCTstr.val,strlen(str));
+    return ECP8_ZZZ_fromOctet(ecp8,&OCTstr);
+}
+
+int main(int argc, char** argv)
+{
+    if (argc != 2)
+    {
+        printf("usage: ./test_ecp8_arithmetics_ZZZ [path to test vector 
file]\n");
+        exit(EXIT_FAILURE);
+    }
+
+    int i=0, k, len=0;
+
+    char line[LINE_LEN];
+    char * linePtr = NULL;
+
+    ECP8_ZZZ ECP8aux1, ECP8aux2, inf;
+    FP8_YYY FP8aux1,FP8aux2;
+
+    char oct[LINE_LEN];
+    octet OCTaux= {0,sizeof(oct),oct};
+
+    ECP8_ZZZ ecp81, ecp8frobs[16];
+    const char* ECP81line = "ECP81 = ";
+    ECP8_ZZZ ecp82;
+    const char* ECP82line = "ECP82 = ";
+    ECP8_ZZZ ecp8sum;
+    const char* ECP8sumline = "ECP8sum = ";
+    ECP8_ZZZ ecp8neg;
+    const char* ECP8negline = "ECP8neg = ";
+    ECP8_ZZZ ecp8sub;
+    const char* ECP8subline = "ECP8sub = ";
+    ECP8_ZZZ ecp8dbl;
+    const char* ECP8dblline = "ECP8dbl = ";
+    BIG_XXX BIGscalar[16];
+    const char* BIGscalarlines[16] =
+    {
+        "BIGscalar1 = ",
+        "BIGscalar2 = ",
+        "BIGscalar3 = ",
+        "BIGscalar4 = ",
+        "BIGscalar5 = ",
+        "BIGscalar6 = ",
+        "BIGscalar7 = ",
+        "BIGscalar8 = ",
+        "BIGscalar9 = ",
+        "BIGscalar10 = ",
+        "BIGscalar11 = ",
+        "BIGscalar12 = ",
+        "BIGscalar13 = ",
+        "BIGscalar14 = ",
+        "BIGscalar15 = ",
+        "BIGscalar16 = ",
+    };
+    ECP8_ZZZ ecp8mul;
+    const char* ECP8mulline = "ECP8mul = ";
+    FP2_YYY fp2fr;
+    const char* FP2frline[3] =
+    {
+        "FP2fr1 = ",
+        "FP2fr2 = ",
+        "FP2fr3 = "
+    };
+    ECP8_ZZZ ecp8frob;
+    const char* ECP8frobline = "ECP8frob = ";
+    ECP8_ZZZ ecp8mul16;
+    const char* ECP8mul16line = "ECP8mul16 = ";
+    ECP8_ZZZ ecp8wrong;
+    const char* ECP8wrongline = "ECP8wrong = ";
+    ECP8_ZZZ ecp8inf;
+    const char* ECP8infline = "ECP8inf = ";
+    ECP8_ZZZ ecp8set1;
+    const char* ECP8set1line = "ECP8set1 = ";
+    ECP8_ZZZ ecp8set2;
+    const char* ECP8set2line = "ECP8set2 = ";
+
+    FP2_YYY F[3];
+    ECP8_ZZZ_frob_constants(F);
+
+    ECP8_ZZZ_inf(&inf);
+
+    if(!ECP8_ZZZ_isinf(&inf))
+    {
+        printf("ERROR setting ECP8_ZZZ to infinity\n");
+        exit(EXIT_FAILURE);
+    }
+
+    FILE *fp;
+    fp = fopen(argv[1],"r");
+    if (fp == NULL)
+    {
+        printf("ERROR opening test vector file\n");
+        exit(EXIT_FAILURE);
+    }
+
+    while (fgets(line, LINE_LEN, fp) != NULL)
+    {
+        i++;
+        if (!strncmp(line,  ECP81line, strlen(ECP81line)))
+        {
+            len = strlen(ECP81line);
+            linePtr = line + len;
+            if(!read_ECP8_ZZZ(&ecp81,linePtr) || ECP8_ZZZ_isinf(&ecp81))
+            {
+                printf("ERROR getting test vector input ECP8_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP8_ZZZ_get(&FP8aux1,&FP8aux2,&ecp81);
+            FP8_YYY_sqr(&FP8aux2,&FP8aux2);
+            ECP8_ZZZ_rhs(&FP8aux1,&FP8aux1);
+            if (!FP8_YYY_equals(&FP8aux1,&FP8aux2))
+            {
+                printf("ERROR computing right hand side of equation ECP, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP8_ZZZ_toOctet(&OCTaux,&ecp81);
+            ECP8_ZZZ_fromOctet(&ECP8aux1,&OCTaux);
+            if(!ECP8_ZZZ_equals(&ECP8aux1,&ecp81))
+            {
+                printf("ERROR converting ECP8_ZZZ to/from OCTET, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP8_ZZZ_copy(ecp8frobs,&ecp81);
+            for(k=1; k<16; k++)
+            {
+                ECP8_ZZZ_copy(ecp8frobs+k,ecp8frobs+k-1);
+                ECP8_ZZZ_frob(ecp8frobs+k,F,1);
+            }
+        }
+        if (!strncmp(line,  ECP82line, strlen(ECP82line)))
+        {
+            len = strlen(ECP82line);
+            linePtr = line + len;
+            if(!read_ECP8_ZZZ(&ecp82,linePtr) || ECP8_ZZZ_isinf(&ecp82))
+            {
+                printf("ERROR getting test vector input ECP8_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP8sumline, strlen(ECP8sumline)))
+        {
+            len = strlen(ECP8sumline);
+            linePtr = line + len;
+            if(!read_ECP8_ZZZ(&ecp8sum,linePtr))
+            {
+                printf("ERROR reading test vector input ECP8_ZZZs, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP8_ZZZ_copy(&ECP8aux1,&ecp81);
+            ECP8_ZZZ_add(&ECP8aux1,&ecp82);
+            ECP8_ZZZ_reduce(&ECP8aux1);
+            ECP8_ZZZ_affine(&ECP8aux1);
+            ECP8_ZZZ_copy(&ECP8aux2,&ecp82); // testing commutativity P+Q = Q+P
+            ECP8_ZZZ_add(&ECP8aux2,&ecp81);
+            ECP8_ZZZ_reduce(&ECP8aux1);
+            ECP8_ZZZ_affine(&ECP8aux1);
+            if(!ECP8_ZZZ_equals(&ECP8aux1,&ecp8sum) || 
!ECP8_ZZZ_equals(&ECP8aux2,&ecp8sum))
+            {
+                printf("ERROR adding two ECP8_ZZZs, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP8_ZZZ_copy(&ECP8aux1,&ecp81); // testing associativity (P+Q)+R 
= P+(Q+R)
+            ECP8_ZZZ_add(&ECP8aux1,&ecp82);
+            ECP8_ZZZ_add(&ECP8aux1,ecp8frobs+2);
+            ECP8_ZZZ_affine(&ECP8aux1);
+            ECP8_ZZZ_copy(&ECP8aux2,ecp8frobs+2);
+            ECP8_ZZZ_add(&ECP8aux2,&ecp82);
+            ECP8_ZZZ_add(&ECP8aux2,&ecp81);
+            ECP8_ZZZ_affine(&ECP8aux2);
+            if(!ECP8_ZZZ_equals(&ECP8aux1,&ECP8aux2))
+            {
+                printf("ERROR testing associativity bewtween three ECP8_ZZZs, 
line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP8negline, strlen(ECP8negline)))
+        {
+            len = strlen(ECP8negline);
+            linePtr = line + len;
+            if(!read_ECP8_ZZZ(&ecp8neg,linePtr))
+            {
+                printf("ERROR getting test vector input ECP8_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP8_ZZZ_copy(&ECP8aux1,&ecp81);
+            ECP8_ZZZ_neg(&ECP8aux1);
+            ECP8_ZZZ_affine(&ECP8aux1);
+            if(!ECP8_ZZZ_equals(&ECP8aux1,&ecp8neg))
+            {
+                printf("ERROR computing negative of ECP8_ZZZ, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP8subline, strlen(ECP8subline)))
+        {
+            len = strlen(ECP8subline);
+            linePtr = line + len;
+            if(!read_ECP8_ZZZ(&ecp8sub,linePtr))
+            {
+                printf("ERROR getting test vector input ECP8_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP8_ZZZ_copy(&ECP8aux1,&ecp81);
+            ECP8_ZZZ_sub(&ECP8aux1,&ecp82);
+            ECP8_ZZZ_affine(&ECP8aux1);
+            if(!ECP8_ZZZ_equals(&ECP8aux1,&ecp8sub))
+            {
+                printf("ERROR performing subtraction bewtween two ECP8_ZZZs, 
line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP8dblline, strlen(ECP8dblline)))
+        {
+            len = strlen(ECP8dblline);
+            linePtr = line + len;
+            if(!read_ECP8_ZZZ(&ecp8dbl,linePtr))
+            {
+                printf("ERROR getting test vector input ECP8_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP8_ZZZ_copy(&ECP8aux1,&ecp81);
+            ECP8_ZZZ_dbl(&ECP8aux1);
+            ECP8_ZZZ_affine(&ECP8aux1);
+            if(!ECP8_ZZZ_equals(&ECP8aux1,&ecp8dbl))
+            {
+                printf("ERROR computing double of ECP8_ZZZ, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        for(k=0; k<16; k++)
+        {
+            if (!strncmp(line,  BIGscalarlines[k], strlen(BIGscalarlines[k])))
+            {
+                len = strlen(BIGscalarlines[k]);
+                linePtr = line + len;
+                read_BIG_XXX(BIGscalar[k],linePtr,strlen(linePtr));
+            }
+        }
+        if (!strncmp(line,  ECP8mulline, strlen(ECP8mulline)))
+        {
+            len = strlen(ECP8mulline);
+            linePtr = line + len;
+            if(!read_ECP8_ZZZ(&ecp8mul,linePtr))
+            {
+                printf("ERROR getting test vector input ECP8_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP8_ZZZ_copy(&ECP8aux1,&ecp81);
+            ECP8_ZZZ_mul(&ECP8aux1,BIGscalar[0]);
+            ECP8_ZZZ_affine(&ECP8aux1);
+            if(!ECP8_ZZZ_equals(&ECP8aux1,&ecp8mul))
+            {
+                printf("ERROR computing multiplication of ECP8_ZZZ by a 
scalar, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        for (k=0; k<3; k++)
+        {
+            if(!strncmp(line, FP2frline[k], strlen(FP2frline[k])))
+            {
+                len = strlen(FP2frline[k]);
+                linePtr = line+len;
+                read_FP2_ZZZ(&fp2fr,linePtr);
+
+                if(!FP2_YYY_equals(&fp2fr,F+k))
+                {
+                    printf("ERROR computing %d-th frobenius constant, line 
%d\n",k+1,i);
+                    exit(EXIT_FAILURE);
+                }
+            }
+        }
+        if(!strncmp(line, ECP8frobline, strlen(ECP8frobline)))
+        {
+            len = strlen(ECP8frobline);
+            linePtr = line+len;
+            read_ECP8_ZZZ(&ecp8frob,linePtr);
+
+            ECP8_ZZZ_copy(&ECP8aux1,&ecp81);
+            ECP8_ZZZ_frob(&ECP8aux1,F,3);
+
+            if(!ECP8_ZZZ_equals(&ecp8frob,&ECP8aux1))
+            {
+                printf("ERROR computing frobenius action (P^3), line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP8mul16line, strlen(ECP8mul16line)))
+        {
+            len = strlen(ECP8mul16line);
+            linePtr = line + len;
+            if(!read_ECP8_ZZZ(&ecp8mul16,linePtr))
+            {
+                printf("ERROR getting test vector input ECP8_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+
+            ECP8_ZZZ_mul16(&ECP8aux1,ecp8frobs,BIGscalar);
+            ECP8_ZZZ_affine(&ECP8aux1);
+
+            if(!ECP8_ZZZ_equals(&ECP8aux1,&ecp8mul16))
+            {
+                printf("ERROR computing linear combination of 8 ECP8_ZZZs, 
line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP8wrongline, strlen(ECP8wrongline)))
+        {
+            len = strlen(ECP8wrongline);
+            linePtr = line + len;
+            if(read_ECP8_ZZZ(&ecp8wrong,linePtr) || 
!ECP8_ZZZ_isinf(&ecp8wrong) || !ECP8_ZZZ_equals(&ecp8wrong,&inf))
+            {
+                printf("ERROR identifying a wrong ECP8_ZZZ, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP8infline, strlen(ECP8infline)))
+        {
+            len = strlen(ECP8infline);
+            linePtr = line + len;
+            if(read_ECP8_ZZZ(&ecp8inf,linePtr) || !ECP8_ZZZ_isinf(&ecp8inf) || 
!ECP8_ZZZ_equals(&ecp8inf,&inf))
+            {
+                printf("ERROR identifying infinite point ECP8_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+        if (!strncmp(line,  ECP8set1line, strlen(ECP8set1line)))
+        {
+            len = strlen(ECP8set1line);
+            linePtr = line + len;
+            if(!read_ECP8_ZZZ(&ecp8set1,linePtr))
+            {
+                printf("ERROR getting test vector input ECP8_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            ECP8_ZZZ_get(&FP8aux1,&FP8aux2,&ecp81);
+            ECP8_ZZZ_setx(&ECP8aux1,&FP8aux1);
+        }
+        if (!strncmp(line,  ECP8set2line, strlen(ECP8set2line)))
+        {
+            len = strlen(ECP8set2line);
+            linePtr = line + len;
+            if(!read_ECP8_ZZZ(&ecp8set2,linePtr))
+            {
+                printf("ERROR getting test vector input ECP8_ZZZ, line 
%d\n",i);
+                exit(EXIT_FAILURE);
+            }
+            if((!ECP8_ZZZ_equals(&ECP8aux1,&ecp8set2)) && 
(!ECP8_ZZZ_equals(&ECP8aux1,&ecp8set1)))
+            {
+                printf("ERROR computing ECP8_ZZZ from coordinate x and with y 
set2, line %d\n",i);
+                exit(EXIT_FAILURE);
+            }
+        }
+    }
+    fclose(fp);
+
+    printf("SUCCESS TEST ARITMETIC OF ECP8_ZZZ PASSED\n");
+    exit(EXIT_SUCCESS);
+}


Reply via email to