http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/Makefile.docker
----------------------------------------------------------------------
diff --git a/Makefile.docker b/Makefile.docker
new file mode 100644
index 0000000..4ffebbd
--- /dev/null
+++ b/Makefile.docker
@@ -0,0 +1,43 @@
+# The name for the docker builder image
+BUILDER_CONTAINER_NAME="milagro-crypto/amcl-builder"
+
+# Coverage info
+COVERAGE_INFO=target/LINUX_64BIT_COVERAGE/coverage/amcl.info
+
+define make
+       rm -rf target
+       docker create \
+               --env WINEPREFIX=/tmp/.wine \
+               --name builder \
+               --workdir /src \
+               $(BUILDER_CONTAINER_NAME) sh -c "mkdir -p /tmp/.wine && make $1"
+       docker cp . builder:/src
+       -docker start -ai builder; \
+       echo $$? > buildall.exit
+       docker cp builder:/src/target .
+       docker stop builder
+       docker rm builder
+       @# Workaround: Correct path for coverage src files
+       ls ${COVERAGE_INFO} && sed -i -e "s#^SF:/src\(.*\)#SF:${PWD}\1#g" 
${COVERAGE_INFO} || echo "Skipping coverage info"
+       @mv buildall.exit target
+       @exit `cat target/buildall.exit`
+endef
+
+all: builder
+
+builder:
+       docker build -t $(BUILDER_CONTAINER_NAME) .
+
+
+# --- MAKE TARGETS DOCKER WRAPPERS ---
+
+default:
+       $(call make,default)
+qa:
+       $(call make,qa)
+build:
+       $(call make,build TYPE=$(TYPE))
+buildall:
+       $(call make,buildall)
+
+.PHONY: all builder default qa build buildall

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 3e3fa48..37215a4 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,210 @@
 # AMCL - *Apache Milagro Crypto Library*
+
+[![Branch](https://img.shields.io/badge/-master:-gray.svg)](https://github.com/milagro-crypto/milagro-crypto-c/tree/master)
+[![Build 
Status](https://travis-ci.org/milagro-crypto/milagro-crypto-c.svg?branch=master)](https://travis-ci.org/milagro-crypto/milagro-crypto-c)
+[![Coverage 
Status](https://coveralls.io/repos/github/milagro-crypto/milagro-crypto-c/badge.svg?branch=master)](https://coveralls.io/github/milagro-crypto/milagro-crypto-c?branch=master)
+
+* **category**:    Library
+* **copyright**:   2018 The Apache Software Foundation
+* **license**:     ASL 2.0 ([Apache License Version 2.0, January 
2004](http://www.apache.org/licenses/LICENSE-2.0))
+* **link**:        https://github.com/milagro-crypto/milagro-crypto-c
+* **introduction**: [AMCL.pdf](doc/AMCL.pdf)
+
+
+## Description
+
+*AMCL - Apache Milagro Crypto Library*
+
+AMCL is a standards compliant C cryptographic library with no external 
dependencies, specifically designed to support the Internet of Things (IoT).
+
+For a detailed explanation about this library please read: 
[doc/AMCL.pdf](doc/AMCL.pdf)
+
+AMCL is provided in *C* language but includes a 
*[Python](https://www.python.org)* wrapper for some modules to aid development 
work.
+
+NOTE: This product includes software developed at *[The Apache Software 
Foundation](http://www.apache.org/)*.
+
+## Software Dependencies
+
+In order to build this library, the following packages are required:
+
+* [CMake](https://cmake.org/) is required to build the source code.
+* [CFFI](https://cffi.readthedocs.org/en/release-0.8/), the C Foreign Function 
Interface for Python is required in order to execute tests.
+* [Doxygen](http://doxygen.org) is required to build the source code 
documentation.
+* [Python](https://www.python.org/) language is required to build the Python 
language wrapper.
+
+
+The above packages can be installed in different ways, depending on the 
Operating System used:
+
+* **Debian/Ubuntu Linux**
+
+
+    sudo apt-get install -y git cmake build-essential python python-dev 
python-pip libffi-dev doxygen doxygen-latex parallel
+    sudo pip install cffi
+
+
+* **RedHat/CentOS/Fedora Linux**
+
+
+    sudo yum groupinstall "Development Tools" "Development Libraries"
+    sudo yum install -y git cmake python libpython-devel python-pip 
libffi-devel doxygen doxygen-latex parallel
+    sudo pip install cffi
+
+
+* **MacOS**
+
+
+    ruby -e "$(curl -fsSL 
https://raw.githubusercontent.com/Homebrew/install/master/install)"
+    brew install cmake
+    brew install pkg-config libffi
+    sudo pip install cffi
+    brew install doxygen
+    brew install parallel
+
+
+* **Windows**
+    * Minimalist GNU for Windows [MinGW](http://www.mingw.org) provides the 
tool set used to build the library and should be installed
+    * When the MinGW installer starts select the **mingw32-base** and 
**mingw32-gcc-g++** components
+    * From the menu select *"Installation"* → *"Apply Changes"*, then 
click *"Apply"*
+    * Finally add *C:\MinGW\bin* to the PATH variable
+    * pip install cffi
+    * install CMake following the instructions on http://www.cmake.org
+    * install Doxygen following the instructions on http://www.doxygen.org
+
+
+## Build Instructions
+
+#### Linux and Mac
+
+##### Quick start
+
+A Makefile is present at the project root that reads the options defined in
+config.mk. Change these options and then type the following to build and test
+the library.
+
+    make
+
+##### Multiple curves and RSA security levels
+
+The default build (see config.mk) uses multiple curves and RSA security
+levels. There is an example called testall.c in the examples directory that
+shows how to write a program to use the different curves etc in a single
+program. To build and run the example use this script;
+
+    buildMulti.sh
+
+##### Manual build
+
+NOTE: The default build is for 64 bit machines
+
+    git clone https://github.com/milagro-crypto/milagro-crypto-c
+    cd milagro-crypto-c
+    mkdir -p target/build
+    cd target/build
+    cmake -D CMAKE_INSTALL_PREFIX=/opt/amcl ../..
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./
+    make
+    make test
+    make doc
+    sudo make install
+
+On Debian/Ubuntu machine instead of executing the *"sudo make install"* 
command it is possible to execute *"sudo checkinstall"* to build and install a 
DEB package.
+
+Now you can set the path to where libs and python package are installed:
+
+    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./:/opt/amcl/lib
+    export PYTHONPATH=/usr/lib/python2.7/dist-packages
+
+NOTE: The build can be configured by setting flags on the command line, for 
example:
+
+    cmake -DAMCL_CHUNK=64 ../..
+    cmake -D CMAKE_INSTALL_PREFIX=/opt/amcl -D AMCL_CHUNK=64 -D BUILD_WCC=on 
../..
+
+It is possible also to build the library supporting more than one elliptic 
curve and more  than one RSA security level, for example
+
+       cmake -DAMCL_CURVE=BN254CX,NIST254 -DAMCL_RSA=2048,3072 ../..
+
+To list other available CMake options, use:
+
+    cmake -LH
+
+##### Uninstall software
+
+    sudo make uninstall
+
+##### Building an installer
+
+After having built the libraries you can build a binary installer and a source 
distribution by running this command
+
+    make package
+
+
+#### Windows
+
+Start a command prompt as an administrator
+
+    git clone https://github.com/milagro-crypto/milagro-crypto-c
+    cd milagro-crypto-c
+    mkdir target\build
+    cd target\build
+    cmake -G "MinGW Makefiles" ..\..
+    mingw32-make
+    mingw32-make test
+    mingw32-make doc
+    mingw32-make install
+
+Post install append the PATH system variable to point to the install ./lib:
+
+*My Computer -> Properties -> Advanced > Environment Variables*
+
+The build can be configured using by setting flags on the command line i.e.
+
+    cmake -G "MinGW Makefiles" -D BUILD_PYTHON=on ..
+
+##### Uninstall software
+
+    mingw32-make uninstall
+
+##### Building an installer
+
+After having built the libraries you can build a Windows installer using this 
command
+
+    sudo mingw32-make package
+
+In order for this to work NSSI has to have been installed
+
+## Contributions
+
+This project includes a Makefile that allows you to test and build the project 
in a Linux-compatible system with simple commands.
+All the artifacts and reports produced using this Makefile are stored in the 
*target* folder.
+
+All the packages listed in the *Dockerfile* are required in order to build and 
test all the library options in the current environment. Alternatively, 
everything can be built inside a [Docker](https://www.docker.com) container 
using the command "make -f Makefile.docker buildall".
+
+To see all available options:
+```
+make help
+```
+
+To build the builder Docker image:
+```
+make -f Makefile.docker
+```
+
+To build the project inside a Docker container (requires Docker) you need to 
build a builder image (once), and then build the project in its context:
+```
+make -f Makefile.docker buildall
+```
+
+To build a particular set of predefined makefile options inside a Docker 
container:
+```
+make -f Makefile.docker build TYPE=LINUX_64BIT_NIST256_RSA2048
+```
+
+To execute all the test builds and generate reports in the current environment:
+```
+make qa
+```
+
+To format the code (please use this command before submitting any pull 
request):
+```
+make format
+```

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/RELEASE
----------------------------------------------------------------------
diff --git a/RELEASE b/RELEASE
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/RELEASE
@@ -0,0 +1 @@
+1

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/VERSION
----------------------------------------------------------------------
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..f1cd7de
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+4.12.2

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/amcl.pc.in
----------------------------------------------------------------------
diff --git a/amcl.pc.in b/amcl.pc.in
new file mode 100644
index 0000000..7b17086
--- /dev/null
+++ b/amcl.pc.in
@@ -0,0 +1,10 @@
+prefix="@CMAKE_INSTALL_PREFIX@"
+exec_prefix=${prefix}
+libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+
+Name: amcl
+Description: AMCL is a standards compliant C cryptographic library designed to 
support the Internet of Things (IoT).
+Version: @AMCL_VERSION@
+Libs: -L${libdir} @AMCL_PRIVATE_LIBS@
+Cflags: -I${includedir}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/benchmark/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt
new file mode 100644
index 0000000..b1e7c37
--- /dev/null
+++ b/benchmark/CMakeLists.txt
@@ -0,0 +1,52 @@
+# 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.
+
+cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
+
+foreach(curve ${AMCL_CURVE})
+  amcl_curve_field(PF "${curve}")
+  amcl_curve_field(TC "${curve}")
+  amcl_curve_field(CS "${curve}")
+
+  # Curve Benchmark
+  amcl_configure_file_curve(benchtest_ec_ZZZ.c.in benchtest_ec_${TC}.c 
"${curve}" benchtest_ec_${TC}_GEN_SRCS)
+  add_executable(benchtest_ec_${TC} ${benchtest_ec_${TC}_GEN_SRCS})
+  target_link_libraries(benchtest_ec_${TC} PRIVATE amcl_curve_${TC})
+
+  # Pairing Benchmark
+  if(TARGET amcl_pairing_${TC})
+    amcl_configure_file_curve(benchtest_pair_ZZZ.c.in benchtest_pair_${TC}.c 
"${curve}" benchtest_pair_${TC}_GEN_SRCS)
+    add_executable(benchtest_pair_${TC} ${benchtest_pair_${TC}_GEN_SRCS})
+    target_link_libraries(benchtest_pair_${TC} PRIVATE amcl_pairing_${TC})
+  endif()
+
+  # MPIN Benchmark
+  if(TARGET amcl_mpin_${TC})
+    amcl_configure_file_curve(benchtest_mpin_ZZZ.c.in benchtest_mpin_${TC}.c 
"${curve}" benchtest_mpin_${TC}_GEN_SRCS)
+    add_executable(benchtest_mpin_${TC} ${benchtest_mpin_${TC}_GEN_SRCS})
+    target_link_libraries(benchtest_mpin_${TC} PRIVATE amcl_mpin_${TC})
+  endif()
+  
+endforeach()
+
+foreach(level ${AMCL_RSA})
+  amcl_rsa_field(TFF "${level}")
+
+  amcl_configure_file_rsa(benchtest_rsa_WWW.c.in benchtest_rsa_${TFF}.c 
"${level}" benchtest_rsa_${TFF}_GEN_SRCS)
+  add_executable(benchtest_rsa_${TFF} ${benchtest_rsa_${TFF}_GEN_SRCS})
+  target_link_libraries(benchtest_rsa_${TFF} PRIVATE amcl_rsa_${TFF})
+endforeach()

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/benchmark/benchtest_ec_ZZZ.c.in
----------------------------------------------------------------------
diff --git a/benchmark/benchtest_ec_ZZZ.c.in b/benchmark/benchtest_ec_ZZZ.c.in
new file mode 100644
index 0000000..acb3945
--- /dev/null
+++ b/benchmark/benchtest_ec_ZZZ.c.in
@@ -0,0 +1,116 @@
+/**
+ * @file test_mpin_sign.c
+ * @author Mike Scott
+ * @brief Test and benchmark elliptic curve
+ *
+ * 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 <time.h>
+#include "ecp_ZZZ.h"
+
+#define MIN_TIME 10.0
+#define MIN_ITERS 10
+
+int main()
+{
+    csprng RNG;
+#if CURVETYPE_ZZZ!=MONTGOMERY
+    BIG_XXX y;
+#endif
+    BIG_XXX s,r,x;
+    ECP_ZZZ P,G;
+    int i,iterations;
+    clock_t start;
+    double elapsed;
+    char pr[10];
+    unsigned long ran;
+
+    printf("\nBechmark test EC - ");
+
+    printf("ZZZ Curve\n");
+
+#if CURVETYPE_ZZZ==WEIERSTRASS
+    printf("Weierstrass parameterization\n");
+#endif
+#if CURVETYPE_ZZZ==EDWARDS
+    printf("Edwards parameterization\n");
+#endif
+#if CURVETYPE_ZZZ==MONTGOMERY
+    printf("Montgomery parameterization\n");
+#endif
+
+#if CHUNK==16
+    printf("16-bit Build\n\n");
+#endif
+#if CHUNK==32
+    printf("32-bit Build\n\n");
+#endif
+#if CHUNK==64
+    printf("64-bit Build\n\n");
+#endif
+
+    time((time_t *)&ran);
+    pr[0]=ran;
+    pr[1]=ran>>8;
+    pr[2]=ran>>16;
+    pr[3]=ran>>24;
+    for (i=4; i<10; i++) pr[i]=i;
+    RAND_seed(&RNG,10,pr);
+
+    BIG_XXX_rcopy(x,CURVE_Gx_ZZZ);
+#if CURVETYPE_ZZZ!=MONTGOMERY
+    BIG_XXX_rcopy(y,CURVE_Gy_ZZZ);
+    ECP_ZZZ_set(&G,x,y);
+#else
+    ECP_ZZZ_set(&G,x);
+#endif
+
+    BIG_XXX_rcopy(r,CURVE_Order_ZZZ);
+    BIG_XXX_randomnum(s,r,&RNG);
+    ECP_ZZZ_copy(&P,&G);
+    ECP_ZZZ_mul(&P,r);
+
+    if (!ECP_ZZZ_isinf(&P))
+    {
+        printf("FAILURE - rG!=O\n");
+        exit(EXIT_FAILURE);
+    }
+
+    iterations=0;
+    start=clock();
+    do
+    {
+        ECP_ZZZ_copy(&P,&G);
+        ECP_ZZZ_mul(&P,s);
+
+        iterations++;
+        elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
+    }
+    while (elapsed<MIN_TIME || iterations<MIN_ITERS);
+    elapsed=1000.0*elapsed/iterations;
+    printf("EC  mul - %8d iterations  ",iterations);
+    printf(" %8.2lf ms per iteration\n",elapsed);
+
+    printf("\nSUCCESS BENCHMARK TEST OF EC FUNCTIONS PASSED\n\n");
+    exit(EXIT_SUCCESS);
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/benchmark/benchtest_mpin_ZZZ.c.in
----------------------------------------------------------------------
diff --git a/benchmark/benchtest_mpin_ZZZ.c.in 
b/benchmark/benchtest_mpin_ZZZ.c.in
new file mode 100644
index 0000000..3d16459
--- /dev/null
+++ b/benchmark/benchtest_mpin_ZZZ.c.in
@@ -0,0 +1,255 @@
+/*
+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.
+*/
+
+/* Time MPIN Protocol */
+
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "config_curve_ZZZ.h"
+#include "randapi.h"
+#if CURVE_SECURITY_ZZZ == 128
+#include "mpin_ZZZ.h"
+#elif CURVE_SECURITY_ZZZ == 192
+#include "mpin192_ZZZ.h"
+#elif CURVE_SECURITY_ZZZ == 256
+#include "mpin256_ZZZ.h"
+#endif
+
+#if CURVE_SECURITY_ZZZ == 128
+#define G2LEN 4*PFS_ZZZ
+#elif CURVE_SECURITY_ZZZ == 192
+#define G2LEN 8*PFS_ZZZ
+#elif CURVE_SECURITY_ZZZ == 256
+#define G2LEN 16*PFS_ZZZ
+#endif
+#define GTLEN 3*G2LEN
+
+#define MIN_TIME 10.0
+#define MIN_ITERS 10
+
+int mpin(csprng *RNG)
+{
+    int pin,rtn;
+    int date=0;
+    char 
x[PGS_ZZZ],s[PGS_ZZZ],y[PGS_ZZZ],client_id[100],sst[G2LEN],token[2*PFS_ZZZ+1],sec[2*PFS_ZZZ+1],permit[2*PFS_ZZZ+1],xcid[2*PFS_ZZZ+1],xid[2*PFS_ZZZ+1],e[GTLEN],f[GTLEN];
+    char 
hcid[PFS_ZZZ],hsid[PFS_ZZZ],hid[2*PFS_ZZZ+1],htid[2*PFS_ZZZ+1],h[PGS_ZZZ];
+    char r[PGS_ZZZ],z[2*PFS_ZZZ+1],w[PGS_ZZZ],t[2*PFS_ZZZ+1];
+    char g1[GTLEN],g2[GTLEN];
+    char ck[AESKEY_ZZZ],sk[AESKEY_ZZZ];
+    octet S= {0,sizeof(s),s};
+    octet X= {0,sizeof(x),x};
+    octet Y= {0,sizeof(y),y};
+    octet H= {0,sizeof(h),h};
+    octet CLIENT_ID= {0,sizeof(client_id),client_id};
+    octet SST= {0,sizeof(sst),sst};
+    octet TOKEN= {0,sizeof(token),token};
+    octet SEC= {0,sizeof(sec),sec};
+    octet PERMIT= {0,sizeof(permit),permit};
+    octet xCID= {0,sizeof(xcid),xcid};
+    octet xID= {0,sizeof(xid),xid};
+    octet HCID= {0,sizeof(hcid),hcid};
+    octet HSID= {0,sizeof(hsid),hsid};
+    octet HID= {0,sizeof(hid),hid};
+    octet HTID= {0,sizeof(htid),htid};
+    octet E= {0,sizeof(e),e};
+    octet F= {0,sizeof(f),f};
+    octet R= {0,sizeof(r),r};
+    octet Z= {0,sizeof(z),z};
+    octet W= {0,sizeof(w),w};
+    octet T= {0,sizeof(t),t};
+    octet G1= {0,sizeof(g1),g1};
+    octet G2= {0,sizeof(g2),g2};
+    octet SK= {0,sizeof(sk),sk};
+    octet CK= {0,sizeof(ck),ck};
+    octet *pxID,*pxCID,*pHID,*pHTID,*pE,*pF,*pPERMIT,*prHID;
+    char idhex[100];
+
+    int iterations;
+    clock_t start;
+    double elapsed;
+
+    /* Trusted Authority set-up */
+    MPIN_ZZZ_RANDOM_GENERATE(RNG,&S);
+    printf("Master Secret= ");
+    OCT_output(&S);
+
+    /* Create Client Identity */
+    OCT_jstring(&CLIENT_ID,"[email protected]");
+    HASH_ID(HASH_TYPE_ZZZ,&CLIENT_ID,&HCID);  /* Either Client or TA 
calculates Hash(ID) - you decide! */
+
+    printf("Client ID Hash= ");
+    OCT_output(&HCID);
+    printf("\n");
+
+    OCT_toHex(&CLIENT_ID,idhex);
+    printf("Client ID= %s\n",idhex);// OCT_toHex(&CLIENT_ID); printf("\n");
+
+    /* Client and Server are issued secrets by DTA */
+    MPIN_ZZZ_GET_SERVER_SECRET(&S,&SST);
+    printf("Server Secret= ");
+    OCT_output(&SST);
+
+    MPIN_ZZZ_GET_CLIENT_SECRET(&S,&HCID,&TOKEN);
+    printf("Client Secret= ");
+    OCT_output(&TOKEN);
+
+    /* Client extracts PIN from secret to create Token */
+    pin=1234;
+    printf("Client extracts PIN= %d\n",pin);
+    MPIN_ZZZ_EXTRACT_PIN(HASH_TYPE_ZZZ,&CLIENT_ID,pin,&TOKEN);
+    printf("Client Token= ");
+    OCT_output(&TOKEN);
+
+    MPIN_ZZZ_PRECOMPUTE(&TOKEN,&HCID,NULL,&G1,&G2);
+
+    /* MPin Protocol */
+    pxID=&xID;
+    pxCID=&xCID;
+    pHID=&HID;
+    pHTID=&HTID;
+    pE=&E;
+    pF=&F;
+    pPERMIT=&PERMIT;
+
+    prHID=pHID;
+    pPERMIT=NULL;
+    pxCID=NULL;
+    pHTID=NULL;
+    pE=NULL;
+    pF=NULL;
+
+    int timeValue;
+    printf("MPIN Single Pass\n");
+    timeValue = GET_TIME();
+
+    iterations=0;
+    start=clock();
+    do
+    {
+        
MPIN_ZZZ_CLIENT(HASH_TYPE_ZZZ,date,&CLIENT_ID,RNG,&X,pin,&TOKEN,&SEC,pxID,pxCID,pPERMIT,NULL,timeValue,&Y);
+
+        iterations++;
+        elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
+    }
+    while (elapsed<MIN_TIME || iterations<MIN_ITERS);
+    elapsed=1000.0*elapsed/iterations;
+    printf("MPIN Client              - %8d iterations  ",iterations);
+    printf(" %8.2lf ms per iteration\n",elapsed);
+
+
+    MPIN_ZZZ_GET_G1_MULTIPLE(RNG,1,&R,&HCID,&Z);  /* Also Send Z=r.ID to 
Server, remember random r */
+
+    iterations=0;
+    start=clock();
+    do
+    {
+        rtn = 
MPIN_ZZZ_SERVER(HASH_TYPE_ZZZ,date,pHID,pHTID,&Y,&SST,pxID,pxCID,&SEC,pE,pF,&CLIENT_ID,NULL,timeValue,NULL);
+
+        iterations++;
+        elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
+    }
+    while (elapsed<MIN_TIME || iterations<MIN_ITERS);
+    elapsed=1000.0*elapsed/iterations;
+    printf("MPIN Server              - %8d iterations  ",iterations);
+    printf(" %8.2lf ms per iteration\n",elapsed);
+
+    HASH_ID(HASH_TYPE_ZZZ,&CLIENT_ID,&HSID);  // new
+    MPIN_ZZZ_GET_G1_MULTIPLE(RNG,0,&W,prHID,&T);  /* Also send T=w.ID to 
client, remember random w  */
+
+    if (rtn!=0)
+    {
+        printf("Server says - Bad Pin.\n");
+        return 1;
+    }
+    else
+    {
+        printf("Server says - PIN is good! You really are ");
+        OCT_output_string(&CLIENT_ID);
+        printf(".\n");
+    }
+
+    HASH_ALL(HASH_TYPE_ZZZ,&HCID,pxID,pxCID,&SEC,&Y,&Z,&T,&H);  // new
+    MPIN_ZZZ_CLIENT_KEY(HASH_TYPE_ZZZ,&G1,&G2,pin,&R,&X,&H,&T,&CK);      // 
new H
+    printf("Client Key = ");
+    OCT_output(&CK);
+
+    HASH_ALL(HASH_TYPE_ZZZ,&HSID,pxID,pxCID,&SEC,&Y,&Z,&T,&H);
+    MPIN_ZZZ_SERVER_KEY(HASH_TYPE_ZZZ,&Z,&SST,&W,&H,pHID,pxID,pxCID,&SK); // 
new H,pHID
+    printf("Server Key = ");
+    OCT_output(&SK);
+
+    /* clear memory */
+    OCT_clear(&S);
+    OCT_clear(&X);
+    OCT_clear(&Y);
+    OCT_clear(&H);
+    OCT_clear(&CLIENT_ID);
+    OCT_clear(&SST);
+    OCT_clear(&TOKEN);
+    OCT_clear(&SEC);
+    OCT_clear(&PERMIT);
+    OCT_clear(&xCID);
+    OCT_clear(&xID);
+    OCT_clear(&HCID);
+    OCT_clear(&HSID);
+    OCT_clear(&HID);
+    OCT_clear(&HTID);
+    OCT_clear(&E);
+    OCT_clear(&F);
+    OCT_clear(&R);
+    OCT_clear(&Z);
+    OCT_clear(&W);
+    OCT_clear(&T);
+    OCT_clear(&G1);
+    OCT_clear(&G2);
+    OCT_clear(&SK);
+    OCT_clear(&CK);
+
+    return 0;
+}
+
+int main()
+{
+    int i;
+    unsigned long ran;
+
+    char raw[100];
+    octet RAW= {0,sizeof(raw),raw};
+    /* Crypto Strong RNG */
+    csprng RNG;
+
+    time((time_t *)&ran);
+
+    /* fake random seed source */
+    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+1;
+
+    /* initialise strong RNG */
+    CREATE_CSPRNG(&RNG,&RAW);
+
+    mpin(&RNG);
+
+    KILL_CSPRNG(&RNG);
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/benchmark/benchtest_pair_ZZZ.c.in
----------------------------------------------------------------------
diff --git a/benchmark/benchtest_pair_ZZZ.c.in 
b/benchmark/benchtest_pair_ZZZ.c.in
new file mode 100644
index 0000000..60eafd8
--- /dev/null
+++ b/benchmark/benchtest_pair_ZZZ.c.in
@@ -0,0 +1,281 @@
+/**
+ * @file test_mpin_sign.c
+ * @author Mike Scott
+ * @brief Test and benchmark pairing functions
+ *
+ * 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 <time.h>
+#include "config_curve_ZZZ.h"
+#if CURVE_SECURITY_ZZZ == 128
+#include "pair_ZZZ.h"
+#elif CURVE_SECURITY_ZZZ == 192
+#include "pair192_ZZZ.h"
+#elif CURVE_SECURITY_ZZZ == 256
+#include "pair256_ZZZ.h"
+#endif
+
+#define N_ITER 16
+
+// Renamings for multiple security level support
+#if CURVE_SECURITY_ZZZ == 128
+#define ECPG2_ZZZ_generator ECP2_ZZZ_generator
+#define ECPG2_ZZZ_set ECP2_ZZZ_set
+#define ECPG2_ZZZ_copy ECP2_ZZZ_copy
+#define ECPG2_ZZZ_mul ECP2_ZZZ_mul
+#define ECPG2_ZZZ_isinf ECP2_ZZZ_isinf
+#define GT_ZZZ_copy FP12_YYY_copy
+#define GT_ZZZ_isunity FP12_YYY_isunity
+#define GT_ZZZ_equals FP12_YYY_equals
+#define GT_ZZZ_compow FP12_YYY_compow
+#elif CURVE_SECURITY_ZZZ == 192
+#define ECPG2_ZZZ_generator ECP4_ZZZ_generator
+#define ECPG2_ZZZ_set ECP4_ZZZ_set
+#define ECPG2_ZZZ_copy ECP4_ZZZ_copy
+#define ECPG2_ZZZ_mul ECP4_ZZZ_mul
+#define ECPG2_ZZZ_isinf ECP4_ZZZ_isinf
+#define GT_ZZZ_copy FP24_YYY_copy
+#define GT_ZZZ_isunity FP24_YYY_isunity
+#define GT_ZZZ_equals FP24_YYY_equals
+#define GT_ZZZ_compow FP24_YYY_compow
+#elif CURVE_SECURITY_ZZZ == 256
+#define ECPG2_ZZZ_generator ECP8_ZZZ_generator
+#define ECPG2_ZZZ_set ECP8_ZZZ_set
+#define ECPG2_ZZZ_copy ECP8_ZZZ_copy
+#define ECPG2_ZZZ_mul ECP8_ZZZ_mul
+#define ECPG2_ZZZ_isinf ECP8_ZZZ_isinf
+#define GT_ZZZ_copy FP48_YYY_copy
+#define GT_ZZZ_isunity FP48_YYY_isunity
+#define GT_ZZZ_equals FP48_YYY_equals
+#define GT_ZZZ_compow FP48_YYY_compow
+#endif
+
+#define MIN_TIME 10.0
+#define MIN_ITERS 10
+
+int main()
+{
+    csprng RNG;
+    unsigned long ran;
+    char pr[10];
+
+    printf("Bechmark test PAIR - ZZZ Curve\n");
+
+#if CHUNK==16
+    printf("16-bit Build\n\n");
+#endif
+#if CHUNK==32
+    printf("32-bit Build\n\n");
+#endif
+#if CHUNK==64
+    printf("64-bit Build\n\n");
+#endif
+
+    time((time_t *)&ran);
+    pr[0]=ran;
+    pr[1]=ran>>8;
+    pr[2]=ran>>16;
+    pr[3]=ran>>24;
+    for (int i=4; i<10; i++) pr[i]=i;
+
+    RAND_seed(&RNG,10,pr);
+
+    int iterations;
+    clock_t start;
+    double elapsed;
+
+    ECP_ZZZ P,G;
+#if CURVE_SECURITY_ZZZ == 128
+    ECP2_ZZZ Q,W;
+    FP12_YYY g,w;
+    FP4_YYY cm;
+#elif CURVE_SECURITY_ZZZ == 192
+    ECP4_ZZZ Q,W;
+    FP24_YYY g,w;
+    FP8_YYY cm;
+#elif CURVE_SECURITY_ZZZ == 256
+    ECP8_ZZZ Q,W;
+    FP48_YYY g,w;
+    FP16_YYY cm;
+#endif
+
+    BIG_XXX s,r;
+    printf("\nTesting/Timing ZZZ Pairings\n");
+
+    ECP_ZZZ_generator(&G);
+
+    BIG_XXX_rcopy(r,CURVE_Order_ZZZ);
+    BIG_XXX_randomnum(s,r,&RNG);
+    ECP_ZZZ_copy(&P,&G);
+    PAIR_ZZZ_G1mul(&P,r);
+
+    if (!ECP_ZZZ_isinf(&P))
+    {
+        printf("FAILURE - rG!=O\n");
+        return 0;
+    }
+
+    iterations=0;
+    start=clock();
+    do
+    {
+        ECP_ZZZ_copy(&P,&G);
+        PAIR_ZZZ_G1mul(&P,s);
+
+        iterations++;
+        elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
+    }
+    while (elapsed<MIN_TIME || iterations<MIN_ITERS);
+    elapsed=1000.0*elapsed/iterations;
+    printf("G1 mul              - %8d iterations  ",iterations);
+    printf(" %8.2lf ms per iteration\n",elapsed);
+
+    ECPG2_ZZZ_generator(&W);
+
+    ECPG2_ZZZ_copy(&Q,&W);
+    ECPG2_ZZZ_mul(&Q,r);
+
+    if (!ECPG2_ZZZ_isinf(&Q))
+    {
+        printf("FAILURE - rQ!=O\n");
+        return 0;
+    }
+
+    iterations=0;
+    start=clock();
+    do
+    {
+        ECPG2_ZZZ_copy(&Q,&W);
+        PAIR_ZZZ_G2mul(&Q,s);
+
+        iterations++;
+        elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
+    }
+    while (elapsed<MIN_TIME || iterations<MIN_ITERS);
+    elapsed=1000.0*elapsed/iterations;
+    printf("G2 mul              - %8d iterations  ",iterations);
+    printf(" %8.2lf ms per iteration\n",elapsed);
+
+    PAIR_ZZZ_ate(&w,&Q,&P);
+    PAIR_ZZZ_fexp(&w);
+
+    GT_ZZZ_copy(&g,&w);
+
+    PAIR_ZZZ_GTpow(&g,r);
+
+    if (!GT_ZZZ_isunity(&g))
+    {
+        printf("FAILURE - g^r!=1\n");
+        return 0;
+    }
+
+    iterations=0;
+    start=clock();
+    do
+    {
+        GT_ZZZ_copy(&g,&w);
+        PAIR_ZZZ_GTpow(&g,s);
+
+        iterations++;
+        elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
+    }
+    while (elapsed<MIN_TIME || iterations<MIN_ITERS);
+    elapsed=1000.0*elapsed/iterations;
+    printf("GT pow              - %8d iterations  ",iterations);
+    printf(" %8.2lf ms per iteration\n",elapsed);
+
+    GT_ZZZ_copy(&g,&w);
+
+    iterations=0;
+    start=clock();
+    do
+    {
+        GT_ZZZ_compow(&cm,&g,s,r);
+        iterations++;
+        elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
+    }
+    while (elapsed<MIN_TIME || iterations<MIN_ITERS);
+    elapsed=1000.0*elapsed/iterations;
+    printf("GT pow (compressed) - %8d iterations  ",iterations);
+    printf(" %8.2lf ms per iteration\n",elapsed);
+
+    iterations=0;
+    start=clock();
+    do
+    {
+        PAIR_ZZZ_ate(&w,&Q,&P);
+        iterations++;
+        elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
+    }
+    while (elapsed<MIN_TIME || iterations<MIN_ITERS);
+    elapsed=1000.0*elapsed/iterations;
+    printf("PAIRing ATE         - %8d iterations  ",iterations);
+    printf(" %8.2lf ms per iteration\n",elapsed);
+
+    iterations=0;
+    start=clock();
+    do
+    {
+        GT_ZZZ_copy(&g,&w);
+        PAIR_ZZZ_fexp(&g);
+        iterations++;
+        elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
+    }
+    while (elapsed<MIN_TIME || iterations<MIN_ITERS);
+    elapsed=1000.0*elapsed/iterations;
+    printf("PAIRing FEXP        - %8d iterations  ",iterations);
+    printf(" %8.2lf ms per iteration\n",elapsed);
+
+    ECP_ZZZ_copy(&P,&G);
+    ECPG2_ZZZ_copy(&Q,&W);
+
+    PAIR_ZZZ_G1mul(&P,s);
+    PAIR_ZZZ_ate(&g,&Q,&P);
+    PAIR_ZZZ_fexp(&g);
+
+    ECP_ZZZ_copy(&P,&G);
+
+    PAIR_ZZZ_G2mul(&Q,s);
+    PAIR_ZZZ_ate(&w,&Q,&P);
+    PAIR_ZZZ_fexp(&w);
+
+    if (!GT_ZZZ_equals(&g,&w))
+    {
+        printf("FAILURE - e(sQ,p)!=e(Q,sP) \n");
+        return 1;
+    }
+
+    ECPG2_ZZZ_copy(&Q,&W);
+    PAIR_ZZZ_ate(&g,&Q,&P);
+    PAIR_ZZZ_fexp(&g);
+
+    PAIR_ZZZ_GTpow(&g,s);
+
+    if (!GT_ZZZ_equals(&g,&w))
+    {
+        printf("FAILURE - e(sQ,p)!=e(Q,P)^s \n");
+        return 1;
+    }
+    printf("SUCCESS BENCHMARK TEST OF PAIRING FUNCTIONS PASSED\n");
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/benchmark/benchtest_rsa_WWW.c.in
----------------------------------------------------------------------
diff --git a/benchmark/benchtest_rsa_WWW.c.in b/benchmark/benchtest_rsa_WWW.c.in
new file mode 100644
index 0000000..f04345e
--- /dev/null
+++ b/benchmark/benchtest_rsa_WWW.c.in
@@ -0,0 +1,127 @@
+/**
+ * @file test_mpin_sign.c
+ * @author Mike Scott
+ * @brief est and benchmark and RSA functions
+ *
+ * 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 <time.h>
+
+#include "rsa_WWW.h"
+
+#define MIN_TIME 10.0
+#define MIN_ITERS 10
+
+int main()
+{
+    csprng RNG;
+    int i,iterations;
+    clock_t start;
+    double elapsed;
+    char pr[10];
+    unsigned long ran;
+    rsa_public_key_WWW pub;
+    rsa_private_key_WWW priv;
+    char m[RFS_WWW],d[RFS_WWW],c[RFS_WWW];
+    octet M= {0,sizeof(m),m};
+    octet D= {0,sizeof(d),d};
+    octet C= {0,sizeof(c),c};
+
+    printf("\nBechmark test RSA - ");
+
+#if CHUNK==16
+    printf("16-bit Build\n\n");
+#endif
+#if CHUNK==32
+    printf("32-bit Build\n\n");
+#endif
+#if CHUNK==64
+    printf("64-bit Build\n\n");
+#endif
+
+    time((time_t *)&ran);
+    pr[0]=ran;
+    pr[1]=ran>>8;
+    pr[2]=ran>>16;
+    pr[3]=ran>>24;
+    for (i=4; i<10; i++) pr[i]=i;
+    RAND_seed(&RNG,10,pr);
+
+    printf("Generating %d-bit RSA public/private key 
pair\n",FFLEN_WWW*BIGBITS_XXX);
+
+    iterations=0;
+    start=clock();
+    do
+    {
+        RSA_WWW_KEY_PAIR(&RNG,65537,&priv,&pub,NULL,NULL);
+        iterations++;
+        elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
+    }
+    while (elapsed<MIN_TIME || iterations<MIN_ITERS);
+    elapsed=1000.0*elapsed/iterations;
+    printf("RSA gen - %8d iterations  ",iterations);
+    printf(" %8.2lf ms per iteration\n",elapsed);
+
+    //FF_randomnum(plain,pub.n,&RNG,FFLEN);
+
+    M.len=RFS_WWW;
+    for (i=0; i<RFS_WWW; i++) M.val[i]=i%128;
+
+    iterations=0;
+    start=clock();
+    do
+    {
+        RSA_WWW_ENCRYPT(&pub,&M,&C);
+        iterations++;
+        elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
+    }
+    while (elapsed<MIN_TIME || iterations<MIN_ITERS);
+    elapsed=1000.0*elapsed/iterations;
+    printf("RSA enc - %8d iterations  ",iterations);
+    printf(" %8.2lf ms per iteration\n",elapsed);
+
+    iterations=0;
+    start=clock();
+    do
+    {
+        RSA_WWW_DECRYPT(&priv,&C,&D);
+        iterations++;
+        elapsed=(clock()-start)/(double)CLOCKS_PER_SEC;
+    }
+    while (elapsed<MIN_TIME || iterations<MIN_ITERS);
+    elapsed=1000.0*elapsed/iterations;
+    printf("RSA dec - %8d iterations  ",iterations);
+    printf(" %8.2lf ms per iteration\n",elapsed);
+
+    for (i=0; i<RFS_WWW; i++)
+    {
+        if (M.val[i]!=D.val[i])
+        {
+            printf("FAILURE - RSA decryption\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+
+    printf("\nSUCCESS BENCHMARK TEST OF RSA FUNCTIONS PASSED\n\n");
+    exit(EXIT_SUCCESS);
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/buildMulti.sh
----------------------------------------------------------------------
diff --git a/buildMulti.sh b/buildMulti.sh
new file mode 100755
index 0000000..cf359f8
--- /dev/null
+++ b/buildMulti.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+#
+# buildMulti.sh
+#
+# Build test with multiple curves and RSA security levels
+
+# @author Kealan McCusker <[email protected]>
+
+set -e
+
+# Build default - see config.mk
+make clean
+make
+
+# Build example with multiple curves and RSA security level
+gcc -O2 -std=c99 ./examples/testall.c -I./include/ -I./target/default/include/ 
-L./target/default/lib/ -lamcl_core -lamcl_curve_BN254CX -lamcl_curve_ED25519 
-lamcl_curve_GOLDILOCKS -lamcl_curve_NIST256 -lamcl_mpin_BN254CX 
-lamcl_pairing_BN254CX -lamcl_rsa_2048 -lamcl_rsa_3072 -lamcl_wcc_BN254CX 
-lamcl_x509 -o testall
+
+# Run code
+export LD_LIBRARY_PATH=./target/default/lib
+./testall
+
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/cmake/AMCLExpand.cmake
----------------------------------------------------------------------
diff --git a/cmake/AMCLExpand.cmake b/cmake/AMCLExpand.cmake
new file mode 100644
index 0000000..69fe76e
--- /dev/null
+++ b/cmake/AMCLExpand.cmake
@@ -0,0 +1,104 @@
+# 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.
+
+cmake_minimum_required(VERSION 3.1)
+
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
+include(AMCLParameters)
+
+# Copies a file <source> to file <target> and substitutes variable
+# values referenced as @VAR@, WWW, XXX, YYY, and ZZZ in the file
+# content.  These variables must be set in the caller's scope.
+#
+# If <source> is a relative path it is evaluated with respect to the
+# current source directory.  If <target> is a relative path it is
+# evaluated with respect to the current binary directory.
+#
+# The full path of the target file is appended to <targets_list>.
+#
+macro(__amcl_configure_file source target targets_list)
+  get_filename_component(target_full "${target}" ABSOLUTE
+    BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+  set(AMCL_CHUNK ${WORD_SIZE})
+  set(WL ${WORD_SIZE})
+
+  configure_file("${source}" "${target_full}" @ONLY)
+  file(READ "${target_full}" temp)
+  string(REPLACE WWW "${TFF}" temp "${temp}")
+  string(REPLACE XXX "${BD}"  temp "${temp}")
+  string(REPLACE YYY "${TF}"  temp "${temp}")
+  string(REPLACE ZZZ "${TC}"  temp "${temp}")
+  file(WRITE "${target_full}" "${temp}")
+
+  list(APPEND "${targets_list}" "${target_full}")
+  set("${targets_list}" "${${targets_list}}" PARENT_SCOPE)
+endmacro()
+
+######################################################################
+# Expands an AMCL template file. No RSA or curve params are set.
+function(amcl_configure_file_core source target targets_list)
+  __amcl_configure_file("${source}" "${target}" "${targets_list}")
+endfunction()
+
+# Expands an AMCL template file, including the RSA params for the
+# specified level.
+function(amcl_configure_file_rsa source target level targets_list)
+  amcl_load_rsa(${level})
+  __amcl_configure_file("${source}" "${target}" "${targets_list}")
+endfunction()
+
+# Expands an AMCL template file, including the curve params for the
+# specified curve.
+function(amcl_configure_file_curve source target curve targets_list)
+  amcl_load_curve(${curve})
+  __amcl_configure_file("${source}" "${target}" "${targets_list}")
+endfunction()
+
+# Expands an AMCL template file, including the rsa and curve params
+# for the specified level and curve.
+function(amcl_configure_file_rsa_curve source target level curve targets_list)
+  amcl_load_rsa(${level})
+  amcl_load_curve(${curve})
+  __amcl_configure_file("${source}" "${target}" "${targets_list}")
+endfunction()
+
+######################################################################
+# Generates the SC variable (#defined of supported curves) for
+# version.h.in
+function(amcl_generate_SC SC)
+  set(text "")
+  
+  foreach(curve ${AMCL_CURVE})
+    amcl_curve_field(TC ${curve})
+    set(text "${text}#define ${TC}_VER\n")
+  endforeach()
+
+  set("${SC}" "${text}" PARENT_SCOPE)
+endfunction()
+
+# Generates the RSL variable (#defines of supported RSA security
+# level) for version.h.in
+function(amcl_generate_RSL RSL)
+  set(${text} "")
+
+  foreach(level ${AMCL_RSA})
+    amcl_rsa_field(TFF ${level})
+    set(text "${text}#define RSA_SECURITY_LEVEL_${TFF}_VER\n")
+  endforeach()
+
+  set("${RSL}" "${text}" PARENT_SCOPE)
+endfunction()

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/cmake/AMCLParameters.cmake
----------------------------------------------------------------------
diff --git a/cmake/AMCLParameters.cmake b/cmake/AMCLParameters.cmake
new file mode 100644
index 0000000..b9f8a93
--- /dev/null
+++ b/cmake/AMCLParameters.cmake
@@ -0,0 +1,205 @@
+# 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.
+
+cmake_minimum_required(VERSION 3.1)
+
+# This file defines the parameters for the various curves and RSA
+# levels supported by AMCL.
+#
+# The parameters can be accessed individually by name using the
+# `amcl_curve_field(<field> <curve>)` and `amcl_rsa_field(<field>
+# <level>)` functions in this file.
+#
+# The parameters can be loaded into the variables using the
+# `amcl_load_curve(<curve>)` and `amcl_load_rsa(<level>)` macros in
+# this file.
+#
+# The sister module `AMCLExpand.cmake` contains helper functions to
+# expand template sources with the parameters defined here.
+
+#######################################
+# AMCL Curve parameters
+#######################################
+set(AMCL_CURVE_FIELDS        TB  TF         TC         NB  BASE NBT M8 MT      
             CT          PF  ST     SX        CS )
+set(AMCL_CURVE_64_ED25519    256 25519      ED25519    32  56   255 5  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_64_C25519     256 25519      C25519     32  56   255 5  
PSEUDO_MERSENNE      MONTGOMERY  NOT .      .         128)
+set(AMCL_CURVE_64_NIST256    256 NIST256    NIST256    32  56   256 7  
NOT_SPECIAL          WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_64_BRAINPOOL  256 BRAINPOOL  BRAINPOOL  32  56   256 7  
NOT_SPECIAL          WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_64_ANSSI      256 ANSSI      ANSSI      32  56   256 7  
NOT_SPECIAL          WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_64_HIFIVE     336 HIFIVE     HIFIVE     42  60   336 5  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_64_GOLDILOCKS 448 GOLDILOCKS GOLDILOCKS 56  58   448 7  
GENERALISED_MERSENNE EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_64_NIST384    384 NIST384    NIST384    48  56   384 7  
NOT_SPECIAL          WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_64_C41417     416 C41417     C41417     52  60   414 7  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_64_NIST521    528 NIST521    NIST521    66  60   521 7  
PSEUDO_MERSENNE      WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_64_NUMS256W   256 256PMW     NUMS256W   32  56   256 3  
PSEUDO_MERSENNE      WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_64_NUMS256E   256 256PME     NUMS256E   32  56   256 3  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_64_NUMS384W   384 384PM      NUMS384W   48  56   384 3  
PSEUDO_MERSENNE      WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_64_NUMS384E   384 384PM      NUMS384E   48  56   384 3  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_64_NUMS512W   512 512PM      NUMS512W   64  56   512 7  
PSEUDO_MERSENNE      WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_64_NUMS512E   512 512PM      NUMS512E   64  56   512 7  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_64_SECP256K1  256 SECP256K1  SECP256K1  32  56   256 7  
NOT_SPECIAL          WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_64_BN254      256 BN254      BN254      32  56   254 3  
NOT_SPECIAL          WEIERSTRASS BN  D_TYPE NEGATIVEX 128)
+set(AMCL_CURVE_64_BN254CX    256 BN254CX    BN254CX    32  56   254 3  
NOT_SPECIAL          WEIERSTRASS BN  D_TYPE NEGATIVEX 128)
+set(AMCL_CURVE_64_BLS381     384 BLS381     BLS381     48  58   381 3  
NOT_SPECIAL          WEIERSTRASS BLS M_TYPE NEGATIVEX 128)
+set(AMCL_CURVE_64_BLS383     384 BLS383     BLS383     48  58   383 3  
NOT_SPECIAL          WEIERSTRASS BLS M_TYPE POSITIVEX 128)
+set(AMCL_CURVE_64_BLS24      480 BLS24      BLS24      60  56   479 3  
NOT_SPECIAL          WEIERSTRASS BLS M_TYPE POSITIVEX 192)
+set(AMCL_CURVE_64_BLS48      560 BLS48      BLS48      70  58   556 3  
NOT_SPECIAL          WEIERSTRASS BLS M_TYPE POSITIVEX 256)
+set(AMCL_CURVE_64_FP256BN    256 FP256BN    FP256BN    32  56   256 3  
NOT_SPECIAL          WEIERSTRASS BN  M_TYPE NEGATIVEX 128)
+set(AMCL_CURVE_64_FP512BN    512 FP512BN    FP512BN    64  60   512 3  
NOT_SPECIAL          WEIERSTRASS BN  M_TYPE POSITIVEX 128)
+set(AMCL_CURVE_64_BLS461     464 BLS461     BLS461     58  60   461 3  
NOT_SPECIAL          WEIERSTRASS BLS M_TYPE NEGATIVEX 128)
+#  (                         TB  TF         TC         NB  BASE NBT M8 MT      
             CT          PF  ST     SX        CS )
+set(AMCL_CURVE_32_ED25519    256 25519      ED25519    32  29   255 5  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_32_C25519     256 25519      C25519     32  29   255 5  
PSEUDO_MERSENNE      MONTGOMERY  NOT .      .         128)
+set(AMCL_CURVE_32_NIST256    256 NIST256    NIST256    32  28   256 7  
NOT_SPECIAL          WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_32_BRAINPOOL  256 BRAINPOOL  BRAINPOOL  32  28   256 7  
NOT_SPECIAL          WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_32_ANSSI      256 ANSSI      ANSSI      32  28   256 7  
NOT_SPECIAL          WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_32_HIFIVE     336 HIFIVE     HIFIVE     42  29   336 5  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_32_GOLDILOCKS 448 GOLDILOCKS GOLDILOCKS 56  29   448 7  
GENERALISED_MERSENNE EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_32_NIST384    384 NIST384    NIST384    48  29   384 7  
NOT_SPECIAL          WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_32_C41417     416 C41417     C41417     52  29   414 7  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_32_NIST521    528 NIST521    NIST521    66  28   521 7  
PSEUDO_MERSENNE      WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_32_NUMS256W   256 256PMW     NUMS256W   32  28   256 3  
PSEUDO_MERSENNE      WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_32_NUMS256E   256 256PME     NUMS256E   32  29   256 3  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_32_NUMS384W   384 384PM      NUMS384W   48  29   384 3  
PSEUDO_MERSENNE      WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_32_NUMS384E   384 384PM      NUMS384E   48  29   384 3  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_32_NUMS512W   512 512PM      NUMS512W   64  29   512 7  
PSEUDO_MERSENNE      WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_32_NUMS512E   512 512PM      NUMS512E   64  29   512 7  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_32_SECP256K1  256 SECP256K1  SECP256K1  32  28   256 7  
NOT_SPECIAL          WEIERSTRASS NOT .      .         128)
+set(AMCL_CURVE_32_BN254      256 BN254      BN254      32  28   254 3  
NOT_SPECIAL          WEIERSTRASS BN  D_TYPE NEGATIVEX 128)
+set(AMCL_CURVE_32_BN254CX    256 BN254CX    BN254CX    32  28   254 3  
NOT_SPECIAL          WEIERSTRASS BN  D_TYPE NEGATIVEX 128)
+set(AMCL_CURVE_32_BLS381     384 BLS381     BLS381     48  29   381 3  
NOT_SPECIAL          WEIERSTRASS BLS M_TYPE NEGATIVEX 128)
+set(AMCL_CURVE_32_BLS383     384 BLS383     BLS383     48  29   383 3  
NOT_SPECIAL          WEIERSTRASS BLS M_TYPE POSITIVEX 128)
+set(AMCL_CURVE_32_BLS24      480 BLS24      BLS24      60  29   479 3  
NOT_SPECIAL          WEIERSTRASS BLS M_TYPE POSITIVEX 192)
+set(AMCL_CURVE_32_BLS48      560 BLS48      BLS48      70  29   556 3  
NOT_SPECIAL          WEIERSTRASS BLS M_TYPE POSITIVEX 256)
+set(AMCL_CURVE_32_FP256BN    256 FP256BN    FP256BN    32  28   256 3  
NOT_SPECIAL          WEIERSTRASS BN  M_TYPE NEGATIVEX 128)
+set(AMCL_CURVE_32_FP512BN    512 FP512BN    FP512BN    64  29   512 3  
NOT_SPECIAL          WEIERSTRASS BN  M_TYPE POSITIVEX 128)
+set(AMCL_CURVE_32_BLS461     464 BLS461     BLS461     58  28   461 3  
NOT_SPECIAL          WEIERSTRASS BLS M_TYPE NEGATIVEX 128)
+#  (                         TB  TF         TC         NB  BASE NBT M8 MT      
             CT          PF  ST     SX        CS )
+set(AMCL_CURVE_16_ED25519    256 25519      ED25519    32  13   255 5  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_16_NUMS256E   256 256PME     NUMS256E   32  13   256 3  
PSEUDO_MERSENNE      EDWARDS     NOT .      .         128)
+set(AMCL_CURVE_16_BN254      256 BN254      BN254      32  13   254 3  
NOT_SPECIAL          WEIERSTRASS BN  D_TYPE NEGATIVEX 128)
+set(AMCL_CURVE_16_BN254CX    256 BN254CX    BN254CX    32  13   254 3  
NOT_SPECIAL          WEIERSTRASS BN  D_TYPE NEGATIVEX 128)
+
+#######################################
+# AMCL RSA parameters
+#######################################
+set(AMCL_RSA_FIELDS          TB   TFF  NB  BASE ML)
+set(AMCL_RSA_64_2048         1024 2048 128 58   2 )
+set(AMCL_RSA_64_3072         384  3072 48  56   8 )
+set(AMCL_RSA_64_4096         512  4096 64  60   8 )
+#  (                         TB   TFF  NB  BASE ML)
+set(AMCL_RSA_32_2048         1024 2048 128 28   2 )
+set(AMCL_RSA_32_3072         384  3072 48  28   8 )
+set(AMCL_RSA_32_4096         512  4096 64  29   8 )
+#  (                         TB   TFF  NB  BASE ML)
+set(AMCL_RSA_16_2048         256  2048 32  13   8 )
+
+########################################
+# Get supported curves and RSA levels
+########################################
+function(amcl_supported_curves output word_size)
+  get_cmake_property(_allvars VARIABLES)
+  string(REGEX MATCHALL "AMCL_CURVE_${word_size}_[a-zA-Z0-9]*" 
_amcl_curve_vars "${_allvars}")
+  string(REGEX REPLACE "AMCL_CURVE_[0-9][0-9]_" "" _names 
"${_amcl_curve_vars}")
+  list(REMOVE_DUPLICATES _names)
+  set("${output}" "${_names}" PARENT_SCOPE)
+endfunction()
+
+function(amcl_supported_rsa_levels output word_size)
+  get_cmake_property(_allvars VARIABLES)
+  string(REGEX MATCHALL "AMCL_RSA_${word_size}_[0-9]*" _amcl_rsa_vars 
"${_allvars}")
+  string(REGEX REPLACE "AMCL_RSA_[0-9][0-9]_" "" _names "${_amcl_rsa_vars}")
+  list(REMOVE_DUPLICATES _names)
+  set("${output}" "${_names}" PARENT_SCOPE)
+endfunction()
+
+#######################################
+# AMCL parameters accessors
+#######################################
+
+# Loads the parameters for <curve> into variables in the calling
+# scope.
+macro(amcl_load_curve curve)
+  if(NOT AMCL_CURVE_${WORD_SIZE}_${curve})
+    message(FATAL_ERROR "Invalid curve: ${curve} for word size ${WORD_SIZE}")
+  endif()
+
+  # Export all predefined fields
+  foreach(field ${AMCL_CURVE_FIELDS})
+    list(FIND AMCL_CURVE_FIELDS "${field}" index)
+    list(GET  AMCL_CURVE_${WORD_SIZE}_${curve} ${index} ${field})
+  endforeach()
+
+  # Export computed fields
+  # - BD
+  set(BD "${TB}_${BASE}")
+
+  # - SH
+  math(EXPR SH "${BASE} * (1 + ((8 * ${NB} - 1) / ${BASE})) - ${NBT}")
+  if (SH GREATER "30")
+    set(SH "30")
+  endif()
+endmacro()
+
+# Loads the parameters for RSA <level> into variables in the calling
+# scope.
+macro(amcl_load_rsa level)
+  if(NOT AMCL_RSA_${WORD_SIZE}_${level})
+    message(FATAL_ERROR "Invalid RSA level: ${level} for word size 
${WORD_SIZE}")
+  endif()
+
+  # Export all predefined fields
+  foreach(field ${AMCL_RSA_FIELDS})
+    list(FIND AMCL_RSA_FIELDS "${field}" index)
+    list(GET  AMCL_RSA_${WORD_SIZE}_${level} ${index} ${field})
+  endforeach()
+
+  # Export computed fields
+  # - BD
+  set(BD "${TB}_${BASE}")
+
+endmacro()
+
+# Retrieves the value of <field> for <curve>.
+#
+# If the optional `DEST <name>` argument is supplied, the value is
+# saved to <name> in the calling scope. Otherwise, it is saved to
+# <field> in the calling scope.
+function(amcl_curve_field field curve)
+  cmake_parse_arguments(amcl_curve_field "" "DEST" "" ${ARGN})
+  if(NOT amcl_curve_field_DEST)
+    set(amcl_curve_field_DEST ${field})
+  endif()
+
+  amcl_load_curve(${curve})
+  set("${amcl_curve_field_DEST}" "${${field}}" PARENT_SCOPE)
+endfunction()
+
+# Retrieves the value of <field> for RSA <level>.
+#
+# If the optional `DEST <name>` argument is supplied, the value is
+# saved to <name> in the calling scope. Otherwise, it is saved to
+# <field> in the calling scope.
+function(amcl_rsa_field field level)
+  cmake_parse_arguments(amcl_rsa_field "" "DEST" "" ${ARGN})
+  if(NOT amcl_rsa_field_DEST)
+    set(amcl_rsa_field_DEST ${field})
+  endif()
+
+  amcl_load_rsa(${level})
+  set("${amcl_rsa_field_DEST}" "${${field}}" PARENT_SCOPE)
+endfunction()

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/cmake/DetermineWordSize.cmake
----------------------------------------------------------------------
diff --git a/cmake/DetermineWordSize.cmake b/cmake/DetermineWordSize.cmake
new file mode 100644
index 0000000..8d90a4c
--- /dev/null
+++ b/cmake/DetermineWordSize.cmake
@@ -0,0 +1,47 @@
+# 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.
+
+function(DETERMINE_WORD_SIZE word_size)
+
+# Check if 64-bit
+  try_compile(COMPILE_SUCCESS "${CMAKE_CURRENT_BINARY_DIR}"
+    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/determine_word_size/check_64.c")
+
+  if(COMPILE_SUCCESS)
+    set(${word_size} 64 PARENT_SCOPE)
+    return()
+  endif()
+
+# Check if 32-bit
+  try_compile(COMPILE_SUCCESS "${CMAKE_CURRENT_BINARY_DIR}"
+    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/determine_word_size/check_32.c")
+
+  if(COMPILE_SUCCESS)
+    set(${word_size} 32 PARENT_SCOPE)
+    return()
+  endif()
+
+# Check if 16-bit
+  try_compile(COMPILE_SUCCESS "${CMAKE_CURRENT_BINARY_DIR}"
+    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/determine_word_size/check_16.c")
+
+  if(COMPILE_SUCCESS)
+    set(${word_size} 16 PARENT_SCOPE)
+    return()
+  endif()
+
+endfunction()

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/cmake/PythonSiteDirs.cmake
----------------------------------------------------------------------
diff --git a/cmake/PythonSiteDirs.cmake b/cmake/PythonSiteDirs.cmake
new file mode 100644
index 0000000..ea57c06
--- /dev/null
+++ b/cmake/PythonSiteDirs.cmake
@@ -0,0 +1,29 @@
+# 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.
+
+cmake_minimum_required(VERSION 3.1)
+
+execute_process(COMMAND
+  python -c "from distutils.sysconfig import get_python_lib; print 
get_python_lib()"
+  OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
+  OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+execute_process(COMMAND
+  python -c "from distutils.sysconfig import get_python_lib; from os.path 
import dirname; print dirname(get_python_lib())"
+  OUTPUT_VARIABLE PYTHON_SITE_LIB
+)

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/cmake/SetOSVariable.cmake
----------------------------------------------------------------------
diff --git a/cmake/SetOSVariable.cmake b/cmake/SetOSVariable.cmake
new file mode 100644
index 0000000..9ea835b
--- /dev/null
+++ b/cmake/SetOSVariable.cmake
@@ -0,0 +1,28 @@
+# 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.
+
+cmake_minimum_required(VERSION 3.1)
+
+if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+  set(OS "Mac OS X")
+elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+  set(OS "Linux")
+elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
+  set(OS "Windows")
+else()
+  set(OS "Unknown")
+endif()

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/cmake/determine_word_size/check_16.c
----------------------------------------------------------------------
diff --git a/cmake/determine_word_size/check_16.c 
b/cmake/determine_word_size/check_16.c
new file mode 100644
index 0000000..1651b48
--- /dev/null
+++ b/cmake/determine_word_size/check_16.c
@@ -0,0 +1,9 @@
+#include <stdint.h>
+
+int main() {
+#if (__WORDSIZE == 16)
+    return 0;
+#else
+#error "Wordsize is not 16"
+#endif
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/cmake/determine_word_size/check_32.c
----------------------------------------------------------------------
diff --git a/cmake/determine_word_size/check_32.c 
b/cmake/determine_word_size/check_32.c
new file mode 100644
index 0000000..d980b1d
--- /dev/null
+++ b/cmake/determine_word_size/check_32.c
@@ -0,0 +1,11 @@
+#include <stdint.h>
+
+int main() {
+#if (__WORDSIZE == 32)
+    return 0;
+#elif (defined(_WIN32) && !defined(_WIN64))
+    return 0;
+#else
+#error "Wordsize is not 32"
+#endif
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/cmake/determine_word_size/check_64.c
----------------------------------------------------------------------
diff --git a/cmake/determine_word_size/check_64.c 
b/cmake/determine_word_size/check_64.c
new file mode 100644
index 0000000..41fc86e
--- /dev/null
+++ b/cmake/determine_word_size/check_64.c
@@ -0,0 +1,11 @@
+#include <stdint.h>
+
+int main() {
+#if (__WORDSIZE == 64)
+    return 0;
+#elif defined(_WIN64)
+    return 0;
+#else
+#error "Wordsize is not 64"
+#endif
+}

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/cmake_uninstall.cmake.in
----------------------------------------------------------------------
diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in
new file mode 100644
index 0000000..2037e36
--- /dev/null
+++ b/cmake_uninstall.cmake.in
@@ -0,0 +1,21 @@
+if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+  message(FATAL_ERROR "Cannot find install manifest: 
@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+  message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+  if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+    exec_program(
+      "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+      OUTPUT_VARIABLE rm_out
+      RETURN_VALUE rm_retval
+      )
+    if(NOT "${rm_retval}" STREQUAL 0)
+      message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+    endif(NOT "${rm_retval}" STREQUAL 0)
+  else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+    message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+  endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/config.mk
----------------------------------------------------------------------
diff --git a/config.mk b/config.mk
new file mode 100644
index 0000000..494ab6b
--- /dev/null
+++ b/config.mk
@@ -0,0 +1,52 @@
+# This file sets the default build of the library and is run by typing "make"
+
+# size of chunk in bits which is wordlength of computer = 16, 32 or 64.  (see 
arch.h)
+WORD_SIZE:=64
+
+# Current choice of Elliptic Curve NIST256 C25519 ED25519 BRAINPOOL ANSSI 
NUMS256E NUMS256W NUMS384E NUMS384W NUMS512E NUMS512W HIFIVE GOLDILOCKS NIST384 
C41417 NIST521 BN254 BN254CX BLS383 FP256BN FP512BN BLS461
+AMCL_CURVE:=ED25519,NIST256,GOLDILOCKS,BN254CX
+
+# RSA security level: 2048 3072 4096
+AMCL_RSA:=2048,3072
+
+# Build type Debug Release Coverage ASan Check CheckFull
+CMAKE_BUILD_TYPE:=Release
+
+# Install path
+CMAKE_INSTALL_PATH:=/opt/amcl
+
+# Run tests
+AMCL_TEST:=ON
+
+# Build Shared Libraries ON/OFF
+AMCL_BUILD_SHARED_LIBS:=ON
+
+# Build Python wrapper ON/OFF
+AMCL_BUILD_PYTHON:=OFF
+
+# Build MPIN ON/OFF
+AMCL_BUILD_MPIN:=ON
+
+# Build WCC ON/OFF
+AMCL_BUILD_WCC:=ON
+
+# Build Doxygen ON/OFF
+AMCL_BUILD_DOCS:=ON
+
+# Configure PIN 
+AMCL_MAXPIN:=10000
+AMCL_PBLEN:=14
+
+# Print debug message for field reduction ON/OFF
+DEBUG_REDUCE:=OFF
+
+# Detect digit overflow ON/OFF
+DEBUG_NORM:=OFF
+
+# Architecture
+CMAKE_C_FLAGS=
+
+# Tool chain 
+# options: ../../resources/cmake/mingw64-cross.cmake
+#          ../../resources/cmake/mingw32-cross.cmake
+CMAKE_TOOLCHAIN_FILE=

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/doc/AMCL.dox
----------------------------------------------------------------------
diff --git a/doc/AMCL.dox b/doc/AMCL.dox
new file mode 100644
index 0000000..be30a98
--- /dev/null
+++ b/doc/AMCL.dox
@@ -0,0 +1,278 @@
+/*
+  This file contains NO source code, just some documentation for doxygen to 
parse.
+*/
+
+/*!
+  \mainpage Apache Milagro Crypto Library (AMCL)
+
+ AMCL is a standards compliant C cryptographic library with no external 
dependencies, specifically designed to support the Internet of Things (IoT).
+
+ For a detailed explanation about this library please read: <a 
href="AMCL.pdf">AMCL.pdf</a>
+
+ AMCL is provided in *C* language but includes a <a 
href="https://www.python.org";>Python</a> wrapper.for some components as an aid 
for development work.
+
+  \section homepage Project page
+  The official project page is hosted at 
+       <a href="http://milagro.apache.org/";>Apache Milagro (incubating)</a>
+
+  \section license 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.
+
+  \section platforms Platforms
+
+  The software can be compiled and installed for these operating systems;
+
+<ul type="disc">
+  <li>Linux</li>
+  <li>Windows</li>
+  <li>Mac OS</li>
+</ul>
+
+
+
+  \section downloads Downloads
+
+  The source code is available from here;
+
+  git clone https://github.com/milagro-crypto/milagro-crypto-c
+
+  \section installonmainpage Installation
+ 
+  There are instructions for building for \ref linux, \ref mac and \ref 
windows.
+
+*/
+
+
+/*!
+  \page linux Linux 
+
+<h2>Software dependencies</h2>
+
+CMake is required to build the library and can usually be installed from
+the operating system package manager.
+
+<ul type="disc">
+  <li>sudo apt-get install cmake</li>
+</ul>
+
+If not, then you can download it from www.cmake.org
+
+In order to use the Python language wrapper install <a 
href="https://www.python.org";>Python</a>
+
+The C Foreign Function Interface for Python <a 
href="https://cffi.readthedocs.org/en/latest/";>CFFI</a> module
+is also required if you wish to use the Python module.
+
+<ul type="disc">
+  <li>sudo pip install cffi</li>
+</ul>
+
+In order to build the documentation <a 
href="http://www.stack.nl/~dimitri/doxygen/";>doxygen</a> is required.
+
+<h2>Quick Start</h2>
+
+<p>A Makefile is present at the project root that reads the options defined in
+config.mk. Change these options and then type  ```make``` to build and test
+the library.</p>
+
+<p>If <a href="https://www.docker.com/";>docker</a> is installed then type 
```make dbuild``` to build and test
+the library in a docker container.</p>
+
+<h2>Manual build</h2>
+
+<p>The default build is for 64 bit machines, Elliptic curve BN254CX and curve 
type Weierstrass</p>
+
+<ol type="disc">
+  <li>mkdir target/build</li>
+  <li>cd target/build</li>
+  <li>cmake -D CMAKE_INSTALL_PREFIX=/opt/amcl ../..
+  <li>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:./
+  <li>make</li>
+  <li>make test</li>
+  <li>make doc</li>
+  <li>sudo make install</li>
+</ol>
+
+<p>The build can be configured using by setting flags on the command line 
i.e.</p>
+
+<ol type="disc">
+  <li>cmake  -D CMAKE_INSTALL_PREFIX=/opt/amcl -D WORD_LENGTH=32 ../..</li>
+</ol>
+
+<p>list available CMake options</p>
+
+<ol type="disc">
+  <li>cmake -LH</li>
+</ol>
+
+<h2>Uninstall software</h2>
+
+<ul type="disc">
+  <li>sudo make uninstall</li>
+</ul>
+
+<h2>Building an installer</h2>
+
+<p>After having built the libraries you can build a binary installer and a 
source distribution by running this command</p>
+
+<ul type="disc">
+  <li>make package</li>
+</ul>
+
+*/
+
+
+
+
+/*!
+  \page mac Mac OS 
+
+<h2>Software dependencies</h2>
+
+Install <a href="http://brew.sh/";>Homebrew</a>
+
+<ul type="disc">
+  <li>ruby -e "$(curl -fsSL 
https://raw.githubusercontent.com/Homebrew/install/master/install)"</li>
+</ul>
+
+Install  <a href="http://www.cmake.org/download/";>cmake</a>
+
+<ul type="disc">
+  <li>brew install cmake</li>
+</ul>
+
+In order to use the Python language wrapper install <a 
href="https://www.python.org";>Python</a>
+
+The C Foreign Function Interface for Python <a 
href="https://cffi.readthedocs.org/en/latest/";>CFFI</a> module
+is also required if you wish to use the Python module.
+
+<ul type="disc">
+  <li>brew install pkg-config libffi</li>
+  <li>sudo pip install cffi</li>
+</ul>
+
+In order to build the documentation <a 
href="http://www.stack.nl/~dimitri/doxygen/";>doxygen</a> is required.
+
+<ul type="disc">
+  <li>brew install doxygen</li>
+</ul>
+
+<h2>Build Instructions</h2>
+
+<p>The default build is for 64 bit machines, Elliptic curve BN254CX and curve 
type Weierstrass</p>
+
+<ol type="disc">
+  <li>mkdir -p target/build</li>
+  <li>cd target/build</li>
+  <li>cmake ../..</li>
+  <li>make</li>
+  <li>make test</li>
+  <li>make doc</li>
+  <li>sudo make install</li>
+</ol>
+
+<p>The build can be configured using by setting flags on the command line 
i.e.</p>
+
+<ol type="disc">
+  <li>cmake -DWORD_LENGTH=32 ../..</li>
+</ol>
+
+<h2>Uninstall software</h2>
+
+<ul type="disc">
+  <li>sudo make uninstall</li>
+</ul>
+
+*/
+
+/*!
+  \page windows Windows
+
+<h2>Software dependencies</h2>
+
+<p>Minimalist GNU for Windows <a href="http://www.mingw.org/";>MinGW</a> 
provides the 
+tool set used to build the library and should be installed. When the MinGW 
installer
+starts select the mingw32-base and mingw32-gcc-g++ components. From the menu 
select
+"Installation" -> "Apply Changes", then click "Apply". Finally add 
C:\\MinGW\\bin
+to the PATH variable.</p>
+
+<p>CMake is required to build the library and can be downloaded from 
www.cmake.org</p>
+
+In order to use the Python language wrapper install <a 
href="https://www.python.org";>Python</a> 
+
+<p>The C Foreign Function Interface for Python <a 
href="https://cffi.readthedocs.org/en/latest/";>CFFI</a> module
+is also required, if you wish to use the Python module.</p>
+
+<ul type="disc">
+  <li>pip install cffi</li>
+</ul>
+
+In order to build the documentation <a 
href="http://www.stack.nl/~dimitri/doxygen/";>doxygen</a> is required.
+
+<h2>Build Instructions</h2>
+
+<p>Start a command prompt as an administrator</p>
+
+<p>The default build is for 64 bit machines, Elliptic curve BN254CX and curve 
type Weierstrass</p>
+
+<ol type="disc">
+  <li>mkdir target\\build</li>
+  <li>cd target\\build</li>
+  <li>cmake -G "MinGW Makefiles" ..\\..</li>
+  <li>mingw32-make</li>
+  <li>mingw32-make test</li>
+  <li>mingw32-make doc</li>
+  <li>mingw32-make install</li>
+</ol>
+
+<p>
+
+Post install append the PATH system variable to point to the install ./lib.
+
+My Computer -> Properties -> Advanced > Environment Variables
+
+</p>
+
+
+<p>The build can be configured using by setting flags on the command line 
i.e.</p>
+
+<ol type="disc">
+  <li>cmake -G "MinGW Makefiles" -DWORD_LENGTH=32 ../..</li>
+</ol>
+
+<h2>Uninstall software</h2>
+
+<ul type="disc">
+  <li>mingw32-make uninstall</li>
+</ul>
+
+<h2>Building an installer</h2>
+
+<p>After having built the libraries you can build a Windows installer using 
this command</p>
+
+<ul type="disc">
+  <li>sudo mingw32-make package</li>
+</ul>
+
+<p>In order for this to work <a 
href="http://nsis.sourceforge.net/Download";>NSSI</a> has
+to have been installed</p>
+
+*/
+
+
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/doc/AMCL.pdf
----------------------------------------------------------------------
diff --git a/doc/AMCL.pdf b/doc/AMCL.pdf
new file mode 100644
index 0000000..e4fa685
Binary files /dev/null and b/doc/AMCL.pdf differ

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto-c/blob/8d28d2c3/doc/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
new file mode 100644
index 0000000..4a99c21
--- /dev/null
+++ b/doc/CMakeLists.txt
@@ -0,0 +1,19 @@
+# Build Documentation
+
+find_package(Doxygen QUIET)
+if(NOT DOXYGEN_FOUND)
+  message(STATUS "Doxygen not found. Documentation will not be built.")
+else()
+  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile 
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
+
+  add_custom_target(doc
+    ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
+    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+    COMMENT "Generating documentation with Doxygen" VERBATIM)
+
+  file(COPY ${PROJECT_SOURCE_DIR}/doc/AMCL.pdf  DESTINATION 
"${CMAKE_CURRENT_BINARY_DIR}/html/")
+endif()
+
+
+
+

Reply via email to