http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/big.h
----------------------------------------------------------------------
diff --git a/version3/cpp/big.h b/version3/cpp/big.h
new file mode 100644
index 0000000..1f4f451
--- /dev/null
+++ b/version3/cpp/big.h
@@ -0,0 +1,595 @@
+#ifndef BIG_XXX_H
+#define BIG_XXX_H
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include "arch.h"
+#include "amcl.h"
+#include "config_big_XXX.h"
+
+using namespace amcl;
+
+
+//#define UNWOUND
+
+#define BIGBITS_XXX (8*MODBYTES_XXX)
+#define NLEN_XXX (1+((8*MODBYTES_XXX-1)/BASEBITS_XXX))
+#define DNLEN_XXX 2*NLEN_XXX
+#define BMASK_XXX (((chunk)1<<BASEBITS_XXX)-1) /**< Mask = 2^BASEBITS-1 */
+#define NEXCESS_XXX (1<<(CHUNK-BASEBITS_XXX-1))           /**< 
2^(CHUNK-BASEBITS-1) - digit cannot be multiplied by more than this before 
normalisation */
+
+#define HBITS_XXX (BASEBITS_XXX/2)      /**< Number of bits in number base 
divided by 2 */
+#define HMASK_XXX (((chunk)1<<HBITS_XXX)-1)    /**< Mask = 2^HBITS-1 */
+
+//#define DEBUG_NORM
+
+#ifdef DEBUG_NORM  /* Add an extra location to track chunk extension */
+#define MPV_XXX NLEN_XXX
+#define MNV_XXX (NLEN_XXX+1)
+#define DMPV_XXX DNLEN_XXX
+#define DMNV_XXX (DNLEN_XXX+1)
+
+#endif
+
+namespace XXX {
+
+#ifdef DEBUG_NORM 
+typedef chunk BIG[NLEN_XXX+2];   /**< Define type BIG as array of chunks */
+typedef chunk DBIG[DNLEN_XXX+2]; /**< Define type DBIG as array of chunks */
+#else
+typedef chunk BIG[NLEN_XXX];     /**< Define type BIG as array of chunks */
+typedef chunk DBIG[DNLEN_XXX];   /**< Define type DBIG as array of chunks */
+#endif
+
+/* BIG number prototypes */
+
+/**    @brief Tests for BIG equal to zero
+ *
+       @param x a BIG number
+       @return 1 if zero, else returns 0
+ */
+extern int BIG_iszilch(BIG x);
+/**    @brief Tests for BIG equal to one
+ *
+       @param x a BIG number
+       @return 1 if one, else returns 0
+ */
+extern int BIG_isunity(BIG x);
+/**    @brief Tests for DBIG equal to zero
+ *
+       @param x a DBIG number
+       @return 1 if zero, else returns 0
+ */
+extern int BIG_diszilch(DBIG x);
+/**    @brief Outputs a BIG number to the console
+ *
+       @param x a BIG number
+ */
+extern void BIG_output(BIG x);
+/**    @brief Outputs a BIG number to the console in raw form (for debugging)
+ *
+       @param x a BIG number
+ */
+extern void BIG_rawoutput(BIG x);
+/**    @brief Conditional constant time swap of two BIG numbers
+ *
+       Conditionally swaps parameters in constant time (without branching)
+       @param x a BIG number
+       @param y another BIG number
+       @param s swap takes place if not equal to 0
+ */
+extern void BIG_cswap(BIG x,BIG y,int s);
+/**    @brief Conditional copy of BIG number
+ *
+       Conditionally copies second parameter to the first (without branching)
+       @param x a BIG number
+       @param y another BIG number
+       @param s copy takes place if not equal to 0
+ */
+extern void BIG_cmove(BIG x,BIG y,int s);
+/**    @brief Conditional copy of DBIG number
+ *
+       Conditionally copies second parameter to the first (without branching)
+       @param x a DBIG number
+       @param y another DBIG number
+       @param s copy takes place if not equal to 0
+ */
+extern void BIG_dcmove(BIG x,BIG y,int s);
+/**    @brief Convert from BIG number to byte array
+ *
+       @param a byte array
+       @param x BIG number
+ */
+extern void BIG_toBytes(char *a,BIG x);
+/**    @brief Convert to BIG number from byte array
+ *
+       @param x BIG number
+       @param a byte array
+ */
+extern void BIG_fromBytes(BIG x,char *a);
+/**    @brief Convert to BIG number from byte array of given length
+ *
+       @param x BIG number
+       @param a byte array
+       @param s byte array length
+ */
+extern void BIG_fromBytesLen(BIG x,char *a,int s);
+/**@brief Convert to DBIG number from byte array of given length
+ *
+   @param x DBIG number
+   @param a byte array
+   @param s byte array length
+ */
+extern void BIG_dfromBytesLen(DBIG x,char *a,int s);
+/**    @brief Outputs a DBIG number to the console
+ *
+       @param x a DBIG number
+ */
+extern void BIG_doutput(DBIG x);
+
+/**    @brief Outputs a DBIG number to the console
+ *
+       @param x a DBIG number
+ */
+extern void BIG_drawoutput(DBIG x);
+
+/**    @brief Copy BIG from Read-Only Memory to a BIG
+ *
+       @param x BIG number
+       @param y BIG number in ROM
+ */
+extern void BIG_rcopy(BIG x,const BIG y);
+/**    @brief Copy BIG to another BIG
+ *
+       @param x BIG number
+       @param y BIG number to be copied
+ */
+extern void BIG_copy(BIG x,BIG y);
+/**    @brief Copy DBIG to another DBIG
+ *
+       @param x DBIG number
+       @param y DBIG number to be copied
+ */
+extern void BIG_dcopy(DBIG x,DBIG y);
+/**    @brief Copy BIG to upper half of DBIG
+ *
+       @param x DBIG number
+       @param y BIG number to be copied
+ */
+extern void BIG_dsucopy(DBIG x,BIG y);
+/**    @brief Copy BIG to lower half of DBIG
+ *
+       @param x DBIG number
+       @param y BIG number to be copied
+ */
+extern void BIG_dscopy(DBIG x,BIG y);
+/**    @brief Copy lower half of DBIG to a BIG
+ *
+       @param x BIG number
+       @param y DBIG number to be copied
+ */
+extern void BIG_sdcopy(BIG x,DBIG y);
+/**    @brief Copy upper half of DBIG to a BIG
+ *
+       @param x BIG number
+       @param y DBIG number to be copied
+ */
+extern void BIG_sducopy(BIG x,DBIG y);
+/**    @brief Set BIG to zero
+ *
+       @param x BIG number to be set to zero
+ */
+extern void BIG_zero(BIG x);
+/**    @brief Set DBIG to zero
+ *
+       @param x DBIG number to be set to zero
+ */
+extern void BIG_dzero(DBIG x);
+/**    @brief Set BIG to one (unity)
+ *
+       @param x BIG number to be set to one.
+ */
+extern void BIG_one(BIG x);
+/**    @brief Set BIG to inverse mod 2^256
+ *
+       @param x BIG number to be inverted
+ */
+extern void BIG_invmod2m(BIG x);
+/**    @brief Set BIG to sum of two BIGs - output not normalised
+ *
+       @param x BIG number, sum of other two
+       @param y BIG number
+       @param z BIG number
+ */
+extern void BIG_add(BIG x,BIG y,BIG z);
+
+/**    @brief Set BIG to logical or of two BIGs - output normalised
+ *
+       @param x BIG number, or of other two
+       @param y BIG number
+       @param z BIG number
+ */
+extern void BIG_or(BIG x,BIG y,BIG z);
+
+/**    @brief Increment BIG by a small integer - output not normalised
+ *
+       @param x BIG number to be incremented
+       @param i integer
+ */
+extern void BIG_inc(BIG x,int i);
+/**    @brief Set BIG to difference of two BIGs
+ *
+       @param x BIG number, difference of other two - output not normalised
+       @param y BIG number
+       @param z BIG number
+ */
+extern void BIG_sub(BIG x,BIG y,BIG z);
+/**    @brief Decrement BIG by a small integer - output not normalised
+ *
+       @param x BIG number to be decremented
+       @param i integer
+ */
+extern void BIG_dec(BIG x,int i);
+/**    @brief Set DBIG to sum of two DBIGs
+ *
+       @param x DBIG number, sum of other two - output not normalised
+       @param y DBIG number
+       @param z DBIG number
+ */
+extern void BIG_dadd(DBIG x,DBIG y,DBIG z);
+/**    @brief Set DBIG to difference of two DBIGs
+ *
+       @param x DBIG number, difference of other two - output not normalised
+       @param y DBIG number
+       @param z DBIG number
+ */
+extern void BIG_dsub(DBIG x,DBIG y,DBIG z);
+/**    @brief Multiply BIG by a small integer - output not normalised
+ *
+       @param x BIG number, product of other two
+       @param y BIG number
+       @param i small integer
+ */
+extern void BIG_imul(BIG x,BIG y,int i);
+/**    @brief Multiply BIG by not-so-small small integer - output normalised
+ *
+       @param x BIG number, product of other two
+       @param y BIG number
+       @param i small integer
+       @return Overflowing bits
+ */
+extern chunk BIG_pmul(BIG x,BIG y,int i);
+/**    @brief Divide BIG by 3 - output normalised
+ *
+       @param x BIG number
+       @return Remainder
+ */
+extern int BIG_div3(BIG x);
+/**    @brief Multiply BIG by even bigger small integer resulting in a DBIG - 
output normalised
+ *
+       @param x DBIG number, product of other two
+       @param y BIG number
+       @param i small integer
+ */
+extern void BIG_pxmul(DBIG x,BIG y,int i);
+/**    @brief Multiply BIG by another BIG resulting in DBIG - inputs 
normalised and output normalised
+ *
+       @param x DBIG number, product of other two
+       @param y BIG number
+       @param z BIG number
+ */
+extern void BIG_mul(DBIG x,BIG y,BIG z);
+/**    @brief Multiply BIG by another BIG resulting in another BIG - inputs 
normalised and output normalised
+ *
+       Note that the product must fit into a BIG, and x must be distinct from 
y and z
+       @param x BIG number, product of other two
+       @param y BIG number
+       @param z BIG number
+ */
+extern void BIG_smul(BIG x,BIG y,BIG z);
+/**    @brief Square BIG resulting in a DBIG - input normalised and output 
normalised
+ *
+       @param x DBIG number, square of a BIG
+       @param y BIG number to be squared
+ */
+extern void BIG_sqr(DBIG x,BIG y);
+
+/**    @brief Montgomery reduction of a DBIG to a BIG  - input normalised and 
output normalised
+ *
+       @param a BIG number, reduction of a BIG
+       @param md BIG number, the modulus
+       @param MC the Montgomery Constant
+       @param d DBIG number to be reduced
+ */
+extern void BIG_monty(BIG a,BIG md,chunk MC,DBIG d);
+
+/**    @brief Shifts a BIG left by any number of bits - input must be 
normalised, output normalised
+ *
+       @param x BIG number to be shifted
+       @param s Number of bits to shift
+ */
+extern void BIG_shl(BIG x,int s);
+/**    @brief Fast shifts a BIG left by a small number of bits - input must be 
normalised, output will be normalised
+ *
+       The number of bits to be shifted must be less than BASEBITS
+       @param x BIG number to be shifted
+       @param s Number of bits to shift
+       @return Overflow bits
+ */
+extern int BIG_fshl(BIG x,int s);
+/**    @brief Shifts a DBIG left by any number of bits - input must be 
normalised, output normalised
+ *
+       @param x DBIG number to be shifted
+       @param s Number of bits to shift
+ */
+extern void BIG_dshl(DBIG x,int s);
+/**    @brief Shifts a BIG right by any number of bits - input must be 
normalised, output normalised
+ *
+       @param x BIG number to be shifted
+       @param s Number of bits to shift
+ */
+extern void BIG_shr(BIG x,int s);
+
+
+/**    @brief Fast time-critical combined shift by 1 bit, subtract and 
normalise
+ *
+       @param r BIG number normalised output
+       @param a BIG number to be subtracted from
+       @param m BIG number to be shifted and subtracted
+       @return sign of r
+ */
+extern int BIG_ssn(BIG r,BIG a, BIG m);
+
+/**    @brief Fast shifts a BIG right by a small number of bits - input must 
be normalised, output will be normalised
+ *
+       The number of bits to be shifted must be less than BASEBITS
+       @param x BIG number to be shifted
+       @param s Number of bits to shift
+       @return Shifted out bits
+ */
+extern int BIG_fshr(BIG x,int s);
+/**    @brief Shifts a DBIG right by any number of bits - input must be 
normalised, output normalised
+ *
+       @param x DBIG number to be shifted
+       @param s Number of bits to shift
+ */
+extern void BIG_dshr(DBIG x,int s);
+/**    @brief Splits a DBIG into two BIGs - input must be normalised, outputs 
normalised
+ *
+       Internal function. The value of s must be approximately in the middle 
of the DBIG.
+       Typically used to extract z mod 2^MODBITS and z/2^MODBITS
+       @param x BIG number, top half of z
+       @param y BIG number, bottom half of z
+       @param z DBIG number to be split in two.
+       @param s Bit position at which to split
+       @return carry-out from top half
+ */
+extern chunk BIG_split(BIG x,BIG y,DBIG z,int s);
+/**    @brief Normalizes a BIG number - output normalised
+ *
+       All digits of the input BIG are reduced mod 2^BASEBITS
+       @param x BIG number to be normalised
+ */
+extern chunk BIG_norm(BIG x);
+/**    @brief Normalizes a DBIG number - output normalised
+ *
+       All digits of the input DBIG are reduced mod 2^BASEBITS
+       @param x DBIG number to be normalised
+ */
+extern void BIG_dnorm(DBIG x);
+/**    @brief Compares two BIG numbers. Inputs must be normalised externally
+ *
+       @param x first BIG number to be compared
+       @param y second BIG number to be compared
+       @return -1 is x<y, 0 if x=y, 1 if x>y
+ */
+extern int BIG_comp(BIG x,BIG y);
+/**    @brief Compares two DBIG numbers. Inputs must be normalised externally
+ *
+       @param x first DBIG number to be compared
+       @param y second DBIG number to be compared
+       @return -1 is x<y, 0 if x=y, 1 if x>y
+ */
+extern int BIG_dcomp(DBIG x,DBIG y);
+/**    @brief Calculate number of bits in a BIG - output normalised
+ *
+       @param x BIG number
+       @return Number of bits in x
+ */
+extern int BIG_nbits(BIG x);
+/**    @brief Calculate number of bits in a DBIG - output normalised
+ *
+       @param x DBIG number
+       @return Number of bits in x
+ */
+extern int BIG_dnbits(DBIG x);
+/**    @brief Reduce x mod n - input and output normalised
+ *
+       Slow but rarely used
+       @param x BIG number to be reduced mod n
+       @param n The modulus
+ */
+extern void BIG_mod(BIG x,BIG n);
+/**    @brief Divide x by n - output normalised
+ *
+       Slow but rarely used
+       @param x BIG number to be divided by n
+       @param n The Divisor
+ */
+extern void BIG_sdiv(BIG x,BIG n);
+/**    @brief  x=y mod n - output normalised
+ *
+       Slow but rarely used. y is destroyed.
+       @param x BIG number, on exit = y mod n
+       @param y DBIG number
+       @param n Modulus
+ */
+extern void BIG_dmod(BIG x,DBIG y,BIG n);
+/**    @brief  x=y/n - output normalised
+ *
+       Slow but rarely used. y is destroyed.
+       @param x BIG number, on exit = y/n
+       @param y DBIG number
+       @param n Modulus
+ */
+extern void BIG_ddiv(BIG x,DBIG y,BIG n);
+/**    @brief  return parity of BIG, that is the least significant bit
+ *
+       @param x BIG number
+       @return 0 or 1
+ */
+extern int BIG_parity(BIG x);
+/**    @brief  return i-th of BIG
+ *
+       @param x BIG number
+       @param i the bit of x to be returned
+       @return 0 or 1
+ */
+extern int BIG_bit(BIG x,int i);
+/**    @brief  return least significant bits of a BIG
+ *
+       @param x BIG number
+       @param n number of bits to return. Assumed to be less than BASEBITS.
+       @return least significant n bits as an integer
+ */
+extern int BIG_lastbits(BIG x,int n);
+/**    @brief  Create a random BIG from a random number generator
+ *
+       Assumes that the random number generator has been suitably initialised
+       @param x BIG number, on exit a random number
+       @param r A pointer to a Cryptographically Secure Random Number Generator
+ */
+extern void BIG_random(BIG x,csprng *r);
+/**    @brief  Create an unbiased random BIG from a random number generator, 
reduced with respect to a modulus
+ *
+       Assumes that the random number generator has been suitably initialised
+       @param x BIG number, on exit a random number
+       @param n The modulus
+       @param r A pointer to a Cryptographically Secure Random Number Generator
+ */
+extern void BIG_randomnum(BIG x,BIG n,csprng *r);
+/**    brief  return NAF (Non-Adjacent-Form) value as +/- 1, 3 or 5, inputs 
must be normalised
+ *
+       Given x and 3*x extracts NAF value from given bit position, and returns 
number of bits processed, and number of trailing zeros detected if any
+       param x BIG number
+       param x3 BIG number, three times x
+       param i bit position
+       param nbs pointer to integer returning number of bits processed
+       param nzs pointer to integer returning number of trailing 0s
+       return + or - 1, 3 or 5
+*/
+
+/**    @brief  Calculate x=y*z mod n
+ *
+       Slow method for modular multiplication
+       @param x BIG number, on exit = y*z mod n
+       @param y BIG number
+       @param z BIG number
+       @param n The BIG Modulus
+ */
+extern void BIG_modmul(BIG x,BIG y,BIG z,BIG n);
+/**    @brief  Calculate x=y/z mod n
+ *
+       Slow method for modular division
+       @param x BIG number, on exit = y/z mod n
+       @param y BIG number
+       @param z BIG number
+       @param n The BIG Modulus
+ */
+extern void BIG_moddiv(BIG x,BIG y,BIG z,BIG n);
+/**    @brief  Calculate x=y^2 mod n
+ *
+       Slow method for modular squaring
+       @param x BIG number, on exit = y^2 mod n
+       @param y BIG number
+       @param n The BIG Modulus
+ */
+extern void BIG_modsqr(BIG x,BIG y,BIG n);
+/**    @brief  Calculate x=-y mod n
+ *
+       Modular negation
+       @param x BIG number, on exit = -y mod n
+       @param y BIG number
+       @param n The BIG Modulus
+ */
+extern void BIG_modneg(BIG x,BIG y,BIG n);
+/**    @brief  Calculate jacobi Symbol (x/y)
+ *
+       @param x BIG number
+       @param y BIG number
+       @return Jacobi symbol, -1,0 or 1
+ */
+extern int BIG_jacobi(BIG x,BIG y);
+/**    @brief  Calculate x=1/y mod n
+ *
+       Modular Inversion - This is slow. Uses binary method.
+       @param x BIG number, on exit = 1/y mod n
+       @param y BIG number
+       @param n The BIG Modulus
+ */
+extern void BIG_invmodp(BIG x,BIG y,BIG n);
+/** @brief Calculate x=x mod 2^m
+ *
+       Truncation
+       @param x BIG number, on reduced mod 2^m
+       @param m new truncated size
+*/
+extern void BIG_mod2m(BIG x,int m);
+
+/**    @brief Calculates a*b+c+*d
+ *
+       Calculate partial product of a.b, add in carry c, and add total to d
+       @param a multiplier
+       @param b multiplicand
+       @param c carry
+       @param d pointer to accumulated bottom half of result
+       @return top half of result
+ */
+
+#ifdef dchunk
+
+/* Method required to calculate x*y+c+r, bottom half in r, top half returned */
+inline chunk muladd(chunk x,chunk y,chunk c,chunk *r)
+{
+    dchunk prod=(dchunk)x*y+c+*r;
+    *r=(chunk)prod&BMASK_XXX;
+    return (chunk)(prod>>BASEBITS_XXX);
+}
+
+#else
+
+/* No integer type available that can store double the wordlength */
+/* accumulate partial products */
+
+inline chunk muladd(chunk x,chunk y,chunk c,chunk *r)
+{
+    chunk x0,x1,y0,y1;
+    chunk bot,top,mid,carry;
+    x0=x&HMASK;
+    x1=(x>>HBITS_XXX);
+    y0=y&HMASK_XXX;
+    y1=(y>>HBITS_XXX);
+    bot=x0*y0;
+    top=x1*y1;
+    mid=x0*y1+x1*y0;
+    x0=mid&HMASK_XXX;
+    x1=(mid>>HBITS_XXX);
+    bot+=x0<<HBITS_XXX;
+    bot+=*r;
+    bot+=c;
+
+    top+=x1;
+    carry=bot>>BASEBITS_XXX;
+    bot&=BMASK_XXX;
+    top+=carry;
+
+    *r=bot;
+    return top;
+}
+
+#endif
+
+}
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/bls.cpp
----------------------------------------------------------------------
diff --git a/version3/cpp/bls.cpp b/version3/cpp/bls.cpp
new file mode 100644
index 0000000..ded8b3c
--- /dev/null
+++ b/version3/cpp/bls.cpp
@@ -0,0 +1,92 @@
+/*
+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.
+*/
+
+/* Boneh-Lynn-Shacham signature 128-bit API */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "bls_ZZZ.h"
+
+using namespace XXX;
+using namespace YYY;
+
+/* hash a message to an ECP point, using SHA3 */
+
+static void BLS_HASHIT(ECP *P,char *m)
+{
+       int i;
+    sha3 hs;
+       char h[MODBYTES_XXX];
+    octet HM= {0,sizeof(h),h};
+       SHA3_init(&hs,SHAKE256);
+    for (i=0;m[i]!=0;i++) SHA3_process(&hs,m[i]);
+    SHA3_shake(&hs,HM.val,MODBYTES_XXX);
+       HM.len=MODBYTES_XXX;
+       ECP_mapit(P,&HM);
+}
+
+/* generate key pair, private key S, public key W */
+
+int ZZZ::BLS_KEY_PAIR_GENERATE(csprng *RNG,octet* S,octet *W)
+{
+       ECP2 G;
+       BIG s,q;
+    BIG_rcopy(q,CURVE_Order);
+       ECP2_generator(&G);
+       BIG_randomnum(s,q,RNG);
+    BIG_toBytes(S->val,s);
+    S->len=MODBYTES_XXX;
+    PAIR_G2mul(&G,s);
+       ECP2_toOctet(W,&G);
+       return BLS_OK;
+}
+
+/* Sign message m using private key S to produce signature SIG */
+
+int ZZZ::BLS_SIGN(octet *SIG,char *m,octet *S)
+{
+       BIG s;
+       ECP D;
+       BLS_HASHIT(&D,m);
+       BIG_fromBytes(s,S->val);
+       PAIR_G1mul(&D,s);
+       ECP_toOctet(SIG,&D,true); /* compress output */
+       return BLS_OK;
+}
+
+/* Verify signature given message m, the signature SIG, and the public key W */
+
+int ZZZ::BLS_VERIFY(octet *SIG,char *m,octet *W)
+{
+       FP12 v;
+       ECP2 G,PK;
+       ECP D,HM;
+       BLS_HASHIT(&HM,m);
+       ECP_fromOctet(&D,SIG);
+       ECP2_generator(&G);
+       ECP2_fromOctet(&PK,W);
+       ECP_neg(&D);
+    PAIR_double_ate(&v,&G,&D,&PK,&HM);
+    PAIR_fexp(&v);
+    if (FP12_isunity(&v)) return BLS_OK;
+       return BLS_FAIL;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/bls.h
----------------------------------------------------------------------
diff --git a/version3/cpp/bls.h b/version3/cpp/bls.h
new file mode 100644
index 0000000..fee3d27
--- /dev/null
+++ b/version3/cpp/bls.h
@@ -0,0 +1,80 @@
+/*
+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.
+*/
+
+/**
+ * @file bls.h
+ * @author Mike Scott
+ * @date 28th Novemebr 2018
+ * @brief BLS Header file
+ *
+ * Allows some user configuration
+ * defines structures
+ * declares functions
+ *
+ */
+
+#ifndef BLS_ZZZ_H
+#define BLS_ZZZ_H
+
+#include "pair_ZZZ.h"
+
+using namespace amcl;
+
+namespace ZZZ {
+
+/* Field size is assumed to be greater than or equal to group size */
+
+#define BGS_ZZZ MODBYTES_XXX  /**< BLS Group Size */
+#define BFS_ZZZ MODBYTES_XXX  /**< BLS Field Size */
+
+#define BLS_OK           0  /**< Function completed without error */
+#define BLS_FAIL               -1      /**< Point is NOT on the curve */
+
+/* BLS API functions */
+
+/**    @brief Generate Key Pair
+ *
+       @param RNG is a pointer to a cryptographically secure random number 
generator
+       @param S on output a private key
+       @param V on output a private key = S*G, where G is fixed generator
+       @return BLS_OK
+ */
+int BLS_KEY_PAIR_GENERATE(csprng *RNG,octet* S,octet *W);
+
+/**    @brief Calculate a signature
+ *
+       @param SIG the ouput signature
+       @param m is the message to be signed
+       @param S an input private key
+       @return BLS_OK
+ */
+int BLS_SIGN(octet *SIG,char *m,octet *S);
+
+/**    @brief Verify a signature
+ *
+       @param SIG an input signature
+       @param m is the message whose signature is to be verified.
+       @param W an public key
+       @return BLS_OK if verified, otherwise BLS_FAIL
+ */
+int BLS_VERIFY(octet *SIG,char *m,octet *W);
+}
+
+#endif
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/bls192.cpp
----------------------------------------------------------------------
diff --git a/version3/cpp/bls192.cpp b/version3/cpp/bls192.cpp
new file mode 100644
index 0000000..683405c
--- /dev/null
+++ b/version3/cpp/bls192.cpp
@@ -0,0 +1,92 @@
+/*
+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.
+*/
+
+/* Boneh-Lynn-Shacham signature 192-bit API */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "bls192_ZZZ.h"
+
+using namespace XXX;
+using namespace YYY;
+
+/* hash a message to an ECP point, using SHA3 */
+
+static void BLS_HASHIT(ECP *P,char *m)
+{
+       int i;
+    sha3 hs;
+       char h[MODBYTES_XXX];
+    octet HM= {0,sizeof(h),h};
+       SHA3_init(&hs,SHAKE256);
+    for (i=0;m[i]!=0;i++) SHA3_process(&hs,m[i]);
+    SHA3_shake(&hs,HM.val,MODBYTES_XXX);
+       HM.len=MODBYTES_XXX;
+       ECP_mapit(P,&HM);
+}
+
+/* generate key pair, private key S, public key W */
+
+int ZZZ::BLS_KEY_PAIR_GENERATE(csprng *RNG,octet* S,octet *W)
+{
+       ECP4 G;
+       BIG s,q;
+    BIG_rcopy(q,CURVE_Order);
+       ECP4_generator(&G);
+       BIG_randomnum(s,q,RNG);
+    BIG_toBytes(S->val,s);
+    S->len=MODBYTES_XXX;
+    PAIR_G2mul(&G,s);
+       ECP4_toOctet(W,&G);
+       return BLS_OK;
+}
+
+/* Sign message m using private key S to produce signature SIG */
+
+int ZZZ::BLS_SIGN(octet *SIG,char *m,octet *S)
+{
+       BIG s;
+       ECP D;
+       BLS_HASHIT(&D,m);
+       BIG_fromBytes(s,S->val);
+       PAIR_G1mul(&D,s);
+       ECP_toOctet(SIG,&D,true); /* compress output */
+       return BLS_OK;
+}
+
+/* Verify signature given message m, the signature SIG, and the public key W */
+
+int ZZZ::BLS_VERIFY(octet *SIG,char *m,octet *W)
+{
+       FP24 v;
+       ECP4 G,PK;
+       ECP D,HM;
+       BLS_HASHIT(&HM,m);
+       ECP_fromOctet(&D,SIG);
+       ECP4_generator(&G);
+       ECP4_fromOctet(&PK,W);
+       ECP_neg(&D);
+    PAIR_double_ate(&v,&G,&D,&PK,&HM);
+    PAIR_fexp(&v);
+    if (FP24_isunity(&v)) return BLS_OK;
+       return BLS_FAIL;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/bls192.h
----------------------------------------------------------------------
diff --git a/version3/cpp/bls192.h b/version3/cpp/bls192.h
new file mode 100644
index 0000000..aaa44aa
--- /dev/null
+++ b/version3/cpp/bls192.h
@@ -0,0 +1,80 @@
+/*
+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.
+*/
+
+/**
+ * @file bls192.h
+ * @author Mike Scott
+ * @date 28th Novemebr 2018
+ * @brief BLS Header file
+ *
+ * Allows some user configuration
+ * defines structures
+ * declares functions
+ *
+ */
+
+#ifndef BLS192_ZZZ_H
+#define BLS192_ZZZ_H
+
+#include "pair192_ZZZ.h"
+
+using namespace amcl;
+
+namespace ZZZ {
+
+/* Field size is assumed to be greater than or equal to group size */
+
+#define BGS_ZZZ MODBYTES_XXX  /**< BLS Group Size */
+#define BFS_ZZZ MODBYTES_XXX  /**< BLS Field Size */
+
+#define BLS_OK           0  /**< Function completed without error */
+#define BLS_FAIL               -1      /**< Point is NOT on the curve */
+
+/* BLS API functions */
+
+/**    @brief Generate Key Pair
+ *
+       @param RNG is a pointer to a cryptographically secure random number 
generator
+       @param S on output a private key
+       @param V on output a private key = S*G, where G is fixed generator
+       @return BLS_OK
+ */
+int BLS_KEY_PAIR_GENERATE(csprng *RNG,octet* S,octet *W);
+
+/**    @brief Calculate a signature
+ *
+       @param SIG the ouput signature
+       @param m is the message to be signed
+       @param S an input private key
+       @return BLS_OK
+ */
+int BLS_SIGN(octet *SIG,char *m,octet *S);
+
+/**    @brief Verify a signature
+ *
+       @param SIG an input signature
+       @param m is the message whose signature is to be verified.
+       @param W an public key
+       @return BLS_OK if verified, otherwise BLS_FAIL
+ */
+int BLS_VERIFY(octet *SIG,char *m,octet *W);
+}
+
+#endif
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/bls256.cpp
----------------------------------------------------------------------
diff --git a/version3/cpp/bls256.cpp b/version3/cpp/bls256.cpp
new file mode 100644
index 0000000..24aacc2
--- /dev/null
+++ b/version3/cpp/bls256.cpp
@@ -0,0 +1,92 @@
+/*
+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.
+*/
+
+/* Boneh-Lynn-Shacham signature 256-bit API */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include "bls256_ZZZ.h"
+
+using namespace XXX;
+using namespace YYY;
+
+/* hash a message to an ECP point, using SHA3 */
+
+static void BLS_HASHIT(ECP *P,char *m)
+{
+       int i;
+    sha3 hs;
+       char h[MODBYTES_XXX];
+    octet HM= {0,sizeof(h),h};
+       SHA3_init(&hs,SHAKE256);
+    for (i=0;m[i]!=0;i++) SHA3_process(&hs,m[i]);
+    SHA3_shake(&hs,HM.val,MODBYTES_XXX);
+       HM.len=MODBYTES_XXX;
+       ECP_mapit(P,&HM);
+}
+
+/* generate key pair, private key S, public key W */
+
+int ZZZ::BLS_KEY_PAIR_GENERATE(csprng *RNG,octet* S,octet *W)
+{
+       ECP8 G;
+       BIG s,q;
+    BIG_rcopy(q,CURVE_Order);
+       ECP8_generator(&G);
+       BIG_randomnum(s,q,RNG);
+    BIG_toBytes(S->val,s);
+    S->len=MODBYTES_XXX;
+    PAIR_G2mul(&G,s);
+       ECP8_toOctet(W,&G);
+       return BLS_OK;
+}
+
+/* Sign message m using private key S to produce signature SIG */
+
+int ZZZ::BLS_SIGN(octet *SIG,char *m,octet *S)
+{
+       BIG s;
+       ECP D;
+       BLS_HASHIT(&D,m);
+       BIG_fromBytes(s,S->val);
+       PAIR_G1mul(&D,s);
+       ECP_toOctet(SIG,&D,true); /* compress output */
+       return BLS_OK;
+}
+
+/* Verify signature of message m, the signature SIG, and the public key W */
+
+int ZZZ::BLS_VERIFY(octet *SIG,char *m,octet *W)
+{
+       FP48 v;
+       ECP8 G,PK;
+       ECP D,HM;
+       BLS_HASHIT(&HM,m);
+       ECP_fromOctet(&D,SIG);
+       ECP8_generator(&G);
+       ECP8_fromOctet(&PK,W);
+       ECP_neg(&D);
+    PAIR_double_ate(&v,&G,&D,&PK,&HM);
+    PAIR_fexp(&v);
+    if (FP48_isunity(&v)) return BLS_OK;
+       return BLS_FAIL;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/bls256.h
----------------------------------------------------------------------
diff --git a/version3/cpp/bls256.h b/version3/cpp/bls256.h
new file mode 100644
index 0000000..a1b47f9
--- /dev/null
+++ b/version3/cpp/bls256.h
@@ -0,0 +1,80 @@
+/*
+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.
+*/
+
+/**
+ * @file bls256.h
+ * @author Mike Scott
+ * @date 28th Novemebr 2018
+ * @brief BLS Header file
+ *
+ * Allows some user configuration
+ * defines structures
+ * declares functions
+ *
+ */
+
+#ifndef BLS256_ZZZ_H
+#define BLS256_ZZZ_H
+
+#include "pair256_ZZZ.h"
+
+using namespace amcl;
+
+namespace ZZZ {
+
+/* Field size is assumed to be greater than or equal to group size */
+
+#define BGS_ZZZ MODBYTES_XXX  /**< BLS Group Size */
+#define BFS_ZZZ MODBYTES_XXX  /**< BLS Field Size */
+
+#define BLS_OK           0  /**< Function completed without error */
+#define BLS_FAIL               -1      /**< Point is NOT on the curve */
+
+/* BLS API functions */
+
+/**    @brief Generate Key Pair
+ *
+       @param RNG is a pointer to a cryptographically secure random number 
generator
+       @param S on output a private key
+       @param V on output a private key = S*G, where G is fixed generator
+       @return BLS_OK
+ */
+int BLS_KEY_PAIR_GENERATE(csprng *RNG,octet* S,octet *W);
+
+/**    @brief Calculate a signature
+ *
+       @param SIG the ouput signature
+       @param m is the message to be signed
+       @param S an input private key
+       @return BLS_OK
+ */
+int BLS_SIGN(octet *SIG,char *m,octet *S);
+
+/**    @brief Verify a signature
+ *
+       @param SIG an input signature
+       @param m is the message whose signature is to be verified.
+       @param W an public key
+       @return BLS_OK if verified, otherwise BLS_FAIL
+ */
+int BLS_VERIFY(octet *SIG,char *m,octet *W);
+}
+
+#endif
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/config16.py
----------------------------------------------------------------------
diff --git a/version3/cpp/config16.py b/version3/cpp/config16.py
new file mode 100644
index 0000000..f683b38
--- /dev/null
+++ b/version3/cpp/config16.py
@@ -0,0 +1,386 @@
+import os
+import sys
+
+deltext=""
+if sys.platform.startswith("linux")  :
+       deltext="rm"
+       copytext="cp"
+if sys.platform.startswith("darwin")  :
+       deltext="rm"
+       copytext="cp"
+if sys.platform.startswith("win") :
+       deltext="del"
+       copytext="copy"
+
+def replace(namefile,oldtext,newtext):
+       f = open(namefile,'r')
+       filedata = f.read()
+       f.close()
+
+       newdata = filedata.replace(oldtext,newtext)
+
+       f = open(namefile,'w')
+       f.write(newdata)
+       f.close()
+
+
+def rsaset(tb,tff,nb,base,ml) :
+       bd="B"+tb+"_"+base
+       fnameh="config_big_"+bd+".h"
+       os.system(copytext+" config_big.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"@NB@",nb)
+       replace(fnameh,"@BASE@",base)
+
+       fnameh="config_ff_"+tff+".h"
+       os.system(copytext+" config_ff.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"WWW",tff)
+       replace(fnameh,"@ML@",ml)
+
+       fnamec="big_"+bd+".cpp"
+       fnameh="big_"+bd+".h"
+
+       os.system(copytext+" big.cpp "+fnamec)
+       os.system(copytext+" big.h "+fnameh)
+
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       fnamec="ff_"+tff+".cpp"
+       fnameh="ff_"+tff+".h"
+
+       os.system(copytext+" ff.cpp "+fnamec)
+       os.system(copytext+" ff.h "+fnameh)
+
+       replace(fnamec,"WWW",tff)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"WWW",tff)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       fnamec="rsa_"+tff+".cpp"
+       fnameh="rsa_"+tff+".h"
+
+       os.system(copytext+" rsa.cpp "+fnamec)
+       os.system(copytext+" rsa.h "+fnameh)
+
+       replace(fnamec,"WWW",tff)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"WWW",tff)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+def curveset(tb,tf,tc,nb,base,nbt,m8,mt,ct,pf,stw,sx,cs) :
+       bd="B"+tb+"_"+base
+       fnameh="config_big_"+bd+".h"
+       os.system(copytext+" config_big.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"@NB@",nb)
+       replace(fnameh,"@BASE@",base)
+
+       fnameh="config_field_"+tf+".h"
+       os.system(copytext+" config_field.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"@NBT@",nbt)
+       replace(fnameh,"@M8@",m8)
+       replace(fnameh,"@MT@",mt)
+
+       ib=int(base)
+       inb=int(nb)
+       inbt=int(nbt)
+       sh=ib*(1+((8*inb-1)//ib))-inbt
+
+       if sh > 6 :
+               sh=6
+       replace(fnameh,"@SH@",str(sh))
+
+       fnameh="config_curve_"+tc+".h"  
+       os.system(copytext+" config_curve.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"ZZZ",tc)
+       replace(fnameh,"@CT@",ct)
+       replace(fnameh,"@PF@",pf)
+
+       replace(fnameh,"@ST@",stw)
+       replace(fnameh,"@SX@",sx)
+       replace(fnameh,"@CS@",cs)
+
+
+       fnamec="big_"+bd+".cpp"
+       fnameh="big_"+bd+".h"
+
+       os.system(copytext+" big.cpp "+fnamec)
+       os.system(copytext+" big.h "+fnameh)
+
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       fnamec="fp_"+tf+".cpp"
+       fnameh="fp_"+tf+".h"
+
+       os.system(copytext+" fp.cpp "+fnamec)
+       os.system(copytext+" fp.h "+fnameh)
+
+       replace(fnamec,"YYY",tf)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       os.system("g++ -O3 -c rom_field_"+tf+".cpp")
+
+       fnamec="ecp_"+tc+".cpp"
+       fnameh="ecp_"+tc+".h"
+
+       os.system(copytext+" ecp.cpp "+fnamec)
+       os.system(copytext+" ecp.h "+fnameh)
+
+       replace(fnamec,"ZZZ",tc)
+       replace(fnamec,"YYY",tf)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"ZZZ",tc)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       fnamec="ecdh_"+tc+".cpp"
+       fnameh="ecdh_"+tc+".h"
+
+       os.system(copytext+" ecdh.cpp "+fnamec)
+       os.system(copytext+" ecdh.h "+fnameh)
+
+       replace(fnamec,"ZZZ",tc)
+       replace(fnamec,"YYY",tf)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"ZZZ",tc)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       os.system("g++ -O3 -c rom_curve_"+tc+".cpp")
+
+       if pf != "NOT" :
+               fnamec="fp2_"+tf+".cpp"
+               fnameh="fp2_"+tf+".h"
+
+               os.system(copytext+" fp2.cpp "+fnamec)
+               os.system(copytext+" fp2.h "+fnameh)
+               replace(fnamec,"YYY",tf)
+               replace(fnamec,"XXX",bd)
+               replace(fnameh,"YYY",tf)
+               replace(fnameh,"XXX",bd)
+               os.system("g++ -O3 -c "+fnamec)
+
+               fnamec="fp4_"+tf+".cpp"
+               fnameh="fp4_"+tf+".h"
+
+               os.system(copytext+" fp4.cpp "+fnamec)
+               os.system(copytext+" fp4.h "+fnameh)
+               replace(fnamec,"YYY",tf)
+               replace(fnamec,"XXX",bd)
+               replace(fnamec,"ZZZ",tc)
+               replace(fnameh,"YYY",tf)
+               replace(fnameh,"XXX",bd)
+               replace(fnameh,"ZZZ",tc)
+               os.system("g++ -O3 -c "+fnamec)
+
+               fnamec="fp12_"+tf+".cpp"
+               fnameh="fp12_"+tf+".h"
+
+               os.system(copytext+" fp12.cpp "+fnamec)
+               os.system(copytext+" fp12.h "+fnameh)
+               replace(fnamec,"YYY",tf)
+               replace(fnamec,"XXX",bd)
+               replace(fnameh,"YYY",tf)
+               replace(fnameh,"XXX",bd)
+               os.system("g++ -O3 -c "+fnamec)
+
+               fnamec="ecp2_"+tc+".cpp"
+               fnameh="ecp2_"+tc+".h"
+
+               os.system(copytext+" ecp2.cpp "+fnamec)
+               os.system(copytext+" ecp2.h "+fnameh)
+               replace(fnamec,"ZZZ",tc)
+               replace(fnamec,"YYY",tf)
+               replace(fnamec,"XXX",bd)
+               replace(fnameh,"ZZZ",tc)
+               replace(fnameh,"YYY",tf)
+               replace(fnameh,"XXX",bd)
+               os.system("g++ -O3 -c "+fnamec)
+
+               fnamec="pair_"+tc+".cpp"
+               fnameh="pair_"+tc+".h"
+
+               os.system(copytext+" pair.cpp "+fnamec)
+               os.system(copytext+" pair.h "+fnameh)
+               replace(fnamec,"ZZZ",tc)
+               replace(fnamec,"YYY",tf)
+               replace(fnamec,"XXX",bd)
+               replace(fnameh,"ZZZ",tc)
+               replace(fnameh,"YYY",tf)
+               replace(fnameh,"XXX",bd)
+               os.system("g++ -O3 -c "+fnamec)
+
+               fnamec="mpin_"+tc+".cpp"
+               fnameh="mpin_"+tc+".h"
+
+               os.system(copytext+" mpin.cpp "+fnamec)
+               os.system(copytext+" mpin.h "+fnameh)
+               replace(fnamec,"ZZZ",tc)
+               replace(fnamec,"YYY",tf)
+               replace(fnamec,"XXX",bd)
+               replace(fnameh,"ZZZ",tc)
+               replace(fnameh,"YYY",tf)
+               replace(fnameh,"XXX",bd)
+               os.system("g++ -O3 -c "+fnamec)
+
+               fnamec="bls_"+tc+".cpp"
+               fnameh="bls_"+tc+".h"
+
+               os.system(copytext+" bls.cpp "+fnamec)
+               os.system(copytext+" bls.h "+fnameh)
+               replace(fnamec,"ZZZ",tc)
+               replace(fnamec,"YYY",tf)
+               replace(fnamec,"XXX",bd)
+               replace(fnameh,"ZZZ",tc)
+               replace(fnameh,"YYY",tf)
+               replace(fnameh,"XXX",bd)
+               os.system("g++ -O3 -c "+fnamec)
+
+
+
+replace("arch.h","@WL@","16")
+print("Elliptic Curves")
+print("1. ED25519")
+print("2. NUMS256E")
+
+print("Pairing-Friendly Elliptic Curves")
+print("3. BN254")
+print("4. BN254CX")
+
+print("RSA")
+print("5. RSA2048")
+
+
+selection=[]
+ptr=0
+max=6
+
+curve_selected=False
+pfcurve_selected=False
+rsa_selected=False
+
+while ptr<max:
+       x=int(input("Choose a Scheme to support - 0 to finish: "))
+       if x == 0:
+               break
+#      print("Choice= ",x)
+       already=False
+       for i in range(0,ptr):
+               if x==selection[i]:
+                       already=True
+                       break
+       if already:
+               continue
+       
+       selection.append(x)
+       ptr=ptr+1
+
+# 
curveset(big,field,curve,big_length_bytes,bits_in_base,modulus_bits,modulus_mod_8,modulus_type,curve_type,pairing_friendly)
+# for each curve give names for big, field and curve. In many cases the latter 
two will be the same. 
+# Typically "big" is the size in bits, always a multiple of 8, "field" 
describes the modulus, and "curve" is the common name for the elliptic curve   
+# big_length_bytes is "big" divided by 8
+# Next give the number base used for 16 bit architectures, as n where the base 
is 2^n (note that these must be fixed for the same "big" name, if is ever 
re-used for another curve)
+# modulus_bits is the bit length of the modulus, typically the same or 
slightly smaller than "big"
+# modulus_mod_8 is the remainder when the modulus is divided by 8
+# modulus_type is NOT_SPECIAL, or PSEUDO_MERSENNE, or MONTGOMERY_Friendly, or 
GENERALISED_MERSENNE (supported for GOLDILOCKS only)
+# curve_type is WEIERSTRASS, EDWARDS or MONTGOMERY
+# pairing_friendly is BN, BLS or NOT (if not pairing friendly)
+# if pairing friendly. M or D type twist, and sign of the family parameter x
+
+
+       if x==1:
+               
curveset("256","F25519","ED25519","32","13","255","5","PSEUDO_MERSENNE","EDWARDS","NOT","","","128")
+               curve_selected=True
+       if x==2:
+               
curveset("256","F256PME","NUMS256E","32","13","256","3","PSEUDO_MERSENNE","EDWARDS","NOT","","","128")
+               curve_selected=True
+
+
+       if x==3:
+               
curveset("256","BN254","BN254","32","13","254","3","NOT_SPECIAL","WEIERSTRASS","BN","D_TYPE","NEGATIVEX","128")
+               pfcurve_selected=True
+       if x==4:
+               
curveset("256","BN254CX","BN254CX","32","13","254","3","NOT_SPECIAL","WEIERSTRASS","BN","D_TYPE","NEGATIVEX","128")
+               pfcurve_selected=True
+
+# rsaset(big,ring,big_length_bytes,bits_in_base,multiplier)
+# for each choice give distinct names for "big" and "ring".
+# Typically "big" is the length in bits of the underlying big number type
+# "ring" is the RSA modulus size = "big" times 2^m
+# big_length_bytes is "big" divided by 8
+# Next give the number base used for 16 bit architectures, as n where the base 
is 2^n
+# multiplier is 2^m (see above)
+
+# There are choices here, different ways of getting the same result, but some 
faster than others
+       if x==5:
+               #256 is slower but may allow reuse of 256-bit BIGs used for 
elliptic curve
+               #512 is faster.. but best is 1024
+               rsaset("256","RSA2048","32","13","8")
+               rsa_selected=True
+
+
+os.system(deltext+" big.*")
+os.system(deltext+" fp.*")
+os.system(deltext+" ecp.*")
+os.system(deltext+" ecdh.*")
+os.system(deltext+" ff.*")
+os.system(deltext+" rsa.*")
+os.system(deltext+" config_big.h")
+os.system(deltext+" config_field.h")
+os.system(deltext+" config_curve.h")
+os.system(deltext+" config_ff.h")
+os.system(deltext+" fp2.*")
+os.system(deltext+" fp4.*")
+os.system(deltext+" fp12.*")
+os.system(deltext+" ecp2.*")
+os.system(deltext+" pair.*")
+os.system(deltext+" mpin.*")
+os.system(deltext+" bls.*")
+
+# create library
+os.system("g++ -O3 -c randapi.cpp")
+if curve_selected :
+       os.system("g++ -O3 -c ecdh_support.cpp")
+if rsa_selected :
+       os.system("g++ -O3 -c rsa_support.cpp")
+if pfcurve_selected :
+       os.system("g++ -O3 -c pbc_support.cpp")
+
+os.system("g++ -O3 -c hash.cpp")
+os.system("g++ -O3 -c rand.cpp")
+os.system("g++ -O3 -c oct.cpp")
+os.system("g++ -O3 -c aes.cpp")
+os.system("g++ -O3 -c gcm.cpp")
+os.system("g++ -O3 -c newhope.cpp")
+
+if sys.platform.startswith("win") :
+       os.system("for %i in (*.o) do @echo %~nxi >> f.list")
+       os.system("ar rc amcl.a @f.list")
+       os.system(deltext+" f.list")
+
+else :
+       os.system("ar rc amcl.a *.o")
+
+os.system(deltext+" *.o")
+
+
+#print("Your section was ")
+#for i in range(0,ptr):
+#      print (selection[i])
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/config32.py
----------------------------------------------------------------------
diff --git a/version3/cpp/config32.py b/version3/cpp/config32.py
new file mode 100644
index 0000000..c4c1758
--- /dev/null
+++ b/version3/cpp/config32.py
@@ -0,0 +1,686 @@
+import os
+import sys
+
+deltext=""
+if sys.platform.startswith("linux")  :
+       deltext="rm"
+       copytext="cp"
+if sys.platform.startswith("darwin")  :
+       deltext="rm"
+       copytext="cp"
+if sys.platform.startswith("win") :
+       deltext="del"
+       copytext="copy"
+
+def replace(namefile,oldtext,newtext):
+       f = open(namefile,'r')
+       filedata = f.read()
+       f.close()
+
+       newdata = filedata.replace(oldtext,newtext)
+
+       f = open(namefile,'w')
+       f.write(newdata)
+       f.close()
+
+
+def rsaset(tb,tff,nb,base,ml) :
+       bd="B"+tb+"_"+base
+       fnameh="config_big_"+bd+".h"
+       os.system(copytext+" config_big.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"@NB@",nb)
+       replace(fnameh,"@BASE@",base)
+
+       fnameh="config_ff_"+tff+".h"
+       os.system(copytext+" config_ff.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"WWW",tff)
+       replace(fnameh,"@ML@",ml)
+
+       fnamec="big_"+bd+".cpp"
+       fnameh="big_"+bd+".h"
+
+       os.system(copytext+" big.cpp "+fnamec)
+       os.system(copytext+" big.h "+fnameh)
+
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       fnamec="ff_"+tff+".cpp"
+       fnameh="ff_"+tff+".h"
+
+       os.system(copytext+" ff.cpp "+fnamec)
+       os.system(copytext+" ff.h "+fnameh)
+
+       replace(fnamec,"WWW",tff)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"WWW",tff)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       fnamec="rsa_"+tff+".cpp"
+       fnameh="rsa_"+tff+".h"
+
+       os.system(copytext+" rsa.cpp "+fnamec)
+       os.system(copytext+" rsa.h "+fnameh)
+
+       replace(fnamec,"WWW",tff)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"WWW",tff)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+def curveset(tb,tf,tc,nb,base,nbt,m8,mt,ct,pf,stw,sx,cs) :
+       bd="B"+tb+"_"+base
+       fnameh="config_big_"+bd+".h"
+       os.system(copytext+" config_big.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"@NB@",nb)
+       replace(fnameh,"@BASE@",base)
+
+       fnameh="config_field_"+tf+".h"
+       os.system(copytext+" config_field.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"@NBT@",nbt)
+       replace(fnameh,"@M8@",m8)
+       replace(fnameh,"@MT@",mt)
+
+       ib=int(base)
+       inb=int(nb)
+       inbt=int(nbt)
+       sh=ib*(1+((8*inb-1)//ib))-inbt
+
+       if sh > 14 :
+               sh=14
+       replace(fnameh,"@SH@",str(sh))
+
+       fnameh="config_curve_"+tc+".h"  
+       os.system(copytext+" config_curve.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"ZZZ",tc)
+       replace(fnameh,"@CT@",ct)
+       replace(fnameh,"@PF@",pf)
+
+       replace(fnameh,"@ST@",stw)
+       replace(fnameh,"@SX@",sx)
+       replace(fnameh,"@CS@",cs)
+
+       fnamec="big_"+bd+".cpp"
+       fnameh="big_"+bd+".h"
+
+       os.system(copytext+" big.cpp "+fnamec)
+       os.system(copytext+" big.h "+fnameh)
+
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       fnamec="fp_"+tf+".cpp"
+       fnameh="fp_"+tf+".h"
+
+       os.system(copytext+" fp.cpp "+fnamec)
+       os.system(copytext+" fp.h "+fnameh)
+
+       replace(fnamec,"YYY",tf)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       os.system("g++ -O3 -c rom_field_"+tf+".cpp")
+
+       fnamec="ecp_"+tc+".cpp"
+       fnameh="ecp_"+tc+".h"
+
+       os.system(copytext+" ecp.cpp "+fnamec)
+       os.system(copytext+" ecp.h "+fnameh)
+
+       replace(fnamec,"ZZZ",tc)
+       replace(fnamec,"YYY",tf)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"ZZZ",tc)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       fnamec="ecdh_"+tc+".cpp"
+       fnameh="ecdh_"+tc+".h"
+
+       os.system(copytext+" ecdh.cpp "+fnamec)
+       os.system(copytext+" ecdh.h "+fnameh)
+
+       replace(fnamec,"ZZZ",tc)
+       replace(fnamec,"YYY",tf)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"ZZZ",tc)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       os.system("g++ -O3 -c rom_curve_"+tc+".cpp")
+
+       if pf != "NOT" :
+               fnamec="fp2_"+tf+".cpp"
+               fnameh="fp2_"+tf+".h"
+
+               os.system(copytext+" fp2.cpp "+fnamec)
+               os.system(copytext+" fp2.h "+fnameh)
+               replace(fnamec,"YYY",tf)
+               replace(fnamec,"XXX",bd)
+               replace(fnameh,"YYY",tf)
+               replace(fnameh,"XXX",bd)
+               os.system("g++ -O3 -c "+fnamec)
+
+               fnamec="fp4_"+tf+".cpp"
+               fnameh="fp4_"+tf+".h"
+
+               os.system(copytext+" fp4.cpp "+fnamec)
+               os.system(copytext+" fp4.h "+fnameh)
+               replace(fnamec,"YYY",tf)
+               replace(fnamec,"XXX",bd)
+               replace(fnamec,"ZZZ",tc)
+               replace(fnameh,"YYY",tf)
+               replace(fnameh,"XXX",bd)
+               replace(fnameh,"ZZZ",tc)
+               os.system("g++ -O3 -c "+fnamec)
+
+               if cs == "128" :
+                       fnamec="fp12_"+tf+".cpp"
+                       fnameh="fp12_"+tf+".h"
+
+                       os.system(copytext+" fp12.cpp "+fnamec)
+                       os.system(copytext+" fp12.h "+fnameh)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="ecp2_"+tc+".cpp"
+                       fnameh="ecp2_"+tc+".h"
+
+                       os.system(copytext+" ecp2.cpp "+fnamec)
+                       os.system(copytext+" ecp2.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="pair_"+tc+".cpp"
+                       fnameh="pair_"+tc+".h"
+
+                       os.system(copytext+" pair.cpp "+fnamec)
+                       os.system(copytext+" pair.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="mpin_"+tc+".cpp"
+                       fnameh="mpin_"+tc+".h"
+
+                       os.system(copytext+" mpin.cpp "+fnamec)
+                       os.system(copytext+" mpin.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+                       fnamec="bls_"+tc+".cpp"
+                       fnameh="bls_"+tc+".h"
+
+                       os.system(copytext+" bls.cpp "+fnamec)
+                       os.system(copytext+" bls.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+               if cs == "192" :
+                       fnamec="fp8_"+tf+".cpp"
+                       fnameh="fp8_"+tf+".h"
+
+                       os.system(copytext+" fp8.cpp "+fnamec)
+                       os.system(copytext+" fp8.h "+fnameh)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+                       fnamec="fp24_"+tf+".cpp"
+                       fnameh="fp24_"+tf+".h"
+
+                       os.system(copytext+" fp24.cpp "+fnamec)
+                       os.system(copytext+" fp24.h "+fnameh)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="ecp4_"+tc+".cpp"
+                       fnameh="ecp4_"+tc+".h"
+
+                       os.system(copytext+" ecp4.cpp "+fnamec)
+                       os.system(copytext+" ecp4.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="pair192_"+tc+".cpp"
+                       fnameh="pair192_"+tc+".h"
+
+                       os.system(copytext+" pair192.cpp "+fnamec)
+                       os.system(copytext+" pair192.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="mpin192_"+tc+".cpp"
+                       fnameh="mpin192_"+tc+".h"
+
+                       os.system(copytext+" mpin192.cpp "+fnamec)
+                       os.system(copytext+" mpin192.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="bls192_"+tc+".cpp"
+                       fnameh="bls192_"+tc+".h"
+
+                       os.system(copytext+" bls192.cpp "+fnamec)
+                       os.system(copytext+" bls192.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+               if cs == "256" :
+
+                       fnamec="fp8_"+tf+".cpp"
+                       fnameh="fp8_"+tf+".h"
+
+                       os.system(copytext+" fp8.cpp "+fnamec)
+                       os.system(copytext+" fp8.h "+fnameh)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+                       fnamec="ecp8_"+tc+".cpp"
+                       fnameh="ecp8_"+tc+".h"
+
+                       os.system(copytext+" ecp8.cpp "+fnamec)
+                       os.system(copytext+" ecp8.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+                       fnamec="fp16_"+tf+".cpp"
+                       fnameh="fp16_"+tf+".h"
+
+                       os.system(copytext+" fp16.cpp "+fnamec)
+                       os.system(copytext+" fp16.h "+fnameh)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+                       fnamec="fp48_"+tf+".cpp"
+                       fnameh="fp48_"+tf+".h"
+
+                       os.system(copytext+" fp48.cpp "+fnamec)
+                       os.system(copytext+" fp48.h "+fnameh)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+                       fnamec="pair256_"+tc+".cpp"
+                       fnameh="pair256_"+tc+".h"
+
+                       os.system(copytext+" pair256.cpp "+fnamec)
+                       os.system(copytext+" pair256.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="mpin256_"+tc+".cpp"
+                       fnameh="mpin256_"+tc+".h"
+
+                       os.system(copytext+" mpin256.cpp "+fnamec)
+                       os.system(copytext+" mpin256.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+                       fnamec="bls256_"+tc+".cpp"
+                       fnameh="bls256_"+tc+".h"
+
+                       os.system(copytext+" bls256.cpp "+fnamec)
+                       os.system(copytext+" bls256.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+replace("arch.h","@WL@","32")
+print("Elliptic Curves")
+print("1. ED25519")
+print("2. C25519")
+print("3. NIST256")
+print("4. BRAINPOOL")
+print("5. ANSSI")
+print("6. HIFIVE")
+print("7. GOLDILOCKS")
+print("8. NIST384")
+print("9. C41417")
+print("10. NIST521\n")
+print("11. NUMS256W")
+print("12. NUMS256E")
+print("13. NUMS384W")
+print("14. NUMS384E")
+print("15. NUMS512W")
+print("16. NUMS512E")
+print("17. SECP256K1\n")
+
+print("Pairing-Friendly Elliptic Curves")
+print("18. BN254")
+print("19. BN254CX")
+print("20. BLS383")
+print("21. BLS381")
+print("22. FP256BN")
+print("23. FP512BN")
+print("24. BLS461\n")
+print("25. BLS24")
+print("26. BLS48\n")
+
+print("RSA")
+print("27. RSA2048")
+print("28. RSA3072")
+print("29. RSA4096")
+
+selection=[]
+ptr=0
+max=30
+
+
+curve_selected=False
+pfcurve_selected=False
+rsa_selected=False
+
+while ptr<max:
+       x=int(input("Choose a Scheme to support - 0 to finish: "))
+       if x == 0:
+               break
+#      print("Choice= ",x)
+       already=False
+       for i in range(0,ptr):
+               if x==selection[i]:
+                       already=True
+                       break
+       if already:
+               continue
+       
+       selection.append(x)
+       ptr=ptr+1
+
+# 
curveset(big,field,curve,big_length_bytes,bits_in_base,modulus_bits,modulus_mod_8,modulus_type,curve_type,pairing_friendly,sextic
 twist,sign of x,curve security)
+# for each curve give names for big, field and curve. In many cases the latter 
two will be the same. 
+# Typically "big" is the size in bits, always a multiple of 8, "field" 
describes the modulus, and "curve" is the common name for the elliptic curve   
+# big_length_bytes is "big" divided by 8
+# Next give the number base used for 32 bit architecture, as n where the base 
is 2^n (note that these must be fixed for the same "big" name, if is ever 
re-used for another curve)
+# modulus_bits is the bit length of the modulus, typically the same or 
slightly smaller than "big"
+# modulus_mod_8 is the remainder when the modulus is divided by 8
+# modulus_type is NOT_SPECIAL, or PSEUDO_MERSENNE, or MONTGOMERY_Friendly, or 
GENERALISED_MERSENNE (supported for GOLDILOCKS only)
+# curve_type is WEIERSTRASS, EDWARDS or MONTGOMERY
+# pairing_friendly is BN, BLS or NOT (if not pairing friendly)
+# if pairing friendly. M or D type twist, and sign of the family parameter x
+# curve security is AES equiavlent, rounded up.
+
+       if x==1:
+               
curveset("256","F25519","ED25519","32","29","255","5","PSEUDO_MERSENNE","EDWARDS","NOT","","","128")
+               curve_selected=True
+       if x==2:
+               
curveset("256","F25519","C25519","32","29","255","5","PSEUDO_MERSENNE","MONTGOMERY","NOT","","","128")
+               curve_selected=True
+       if x==3:
+               
curveset("256","NIST256","NIST256","32","28","256","7","NOT_SPECIAL","WEIERSTRASS","NOT","","","128")
+               curve_selected=True
+       if x==4:
+               
curveset("256","BRAINPOOL","BRAINPOOL","32","28","256","7","NOT_SPECIAL","WEIERSTRASS","NOT","","","128")
+               curve_selected=True
+       if x==5:
+               
curveset("256","ANSSI","ANSSI","32","28","256","7","NOT_SPECIAL","WEIERSTRASS","NOT","","","128")
+               curve_selected=True
+
+       if x==6:
+               
curveset("336","HIFIVE","HIFIVE","42","29","336","5","PSEUDO_MERSENNE","EDWARDS","NOT","","","192")
+               curve_selected=True
+       if x==7:
+               
curveset("448","GOLDILOCKS","GOLDILOCKS","56","29","448","7","GENERALISED_MERSENNE","EDWARDS","NOT","","","256")
+               curve_selected=True
+       if x==8:
+               
curveset("384","NIST384","NIST384","48","29","384","7","NOT_SPECIAL","WEIERSTRASS","NOT","","","192")
+               curve_selected=True
+       if x==9:
+               
curveset("416","C41417","C41417","52","29","414","7","PSEUDO_MERSENNE","EDWARDS","NOT","","","256")
+               curve_selected=True
+       if x==10:
+               
curveset("528","NIST521","NIST521","66","28","521","7","PSEUDO_MERSENNE","WEIERSTRASS","NOT","","","256")
+               curve_selected=True
+
+       if x==11:
+               
curveset("256","F256PMW","NUMS256W","32","28","256","3","PSEUDO_MERSENNE","WEIERSTRASS","NOT","","","128")
+               curve_selected=True
+       if x==12:
+               
curveset("256","F256PME","NUMS256E","32","29","256","3","PSEUDO_MERSENNE","EDWARDS","NOT","","","128")
+               curve_selected=True
+       if x==13:
+               
curveset("384","F384PM","NUMS384W","48","29","384","3","PSEUDO_MERSENNE","WEIERSTRASS","NOT","","","192")
+               curve_selected=True
+       if x==14:
+               
curveset("384","F384PM","NUMS384E","48","29","384","3","PSEUDO_MERSENNE","EDWARDS","NOT","","","192")
+               curve_selected=True
+       if x==15:
+               
curveset("512","F512PM","NUMS512W","64","29","512","7","PSEUDO_MERSENNE","WEIERSTRASS","NOT","","","256")
+               curve_selected=True
+       if x==16:
+               
curveset("512","F512PM","NUMS512E","64","29","512","7","PSEUDO_MERSENNE","EDWARDS","NOT","","","256")
+               curve_selected=True
+
+       if x==17:
+               
curveset("256","SECP256K1","SECP256K1","32","28","256","7","NOT_SPECIAL","WEIERSTRASS","NOT","","","128")
+               curve_selected=True
+
+       if x==18:
+               
curveset("256","BN254","BN254","32","28","254","3","NOT_SPECIAL","WEIERSTRASS","BN","D_TYPE","NEGATIVEX","128")
+               pfcurve_selected=True
+       if x==19:
+               
curveset("256","BN254CX","BN254CX","32","28","254","3","NOT_SPECIAL","WEIERSTRASS","BN","D_TYPE","NEGATIVEX","128")
+               pfcurve_selected=True
+       if x==20:
+               
curveset("384","BLS383","BLS383","48","29","383","3","NOT_SPECIAL","WEIERSTRASS","BLS","M_TYPE","POSITIVEX","128")
+               pfcurve_selected=True
+
+       if x==21:
+               
curveset("384","BLS381","BLS381","48","29","381","3","NOT_SPECIAL","WEIERSTRASS","BLS","M_TYPE","NEGATIVEX","128")
+               pfcurve_selected=True
+
+
+       if x==22:
+               
curveset("256","FP256BN","FP256BN","32","28","256","3","NOT_SPECIAL","WEIERSTRASS","BN","M_TYPE","NEGATIVEX","128")
+               pfcurve_selected=True
+       if x==23:
+               
curveset("512","FP512BN","FP512BN","64","29","512","3","NOT_SPECIAL","WEIERSTRASS","BN","M_TYPE","POSITIVEX","128")
+               pfcurve_selected=True
+# https://eprint.iacr.org/2017/334.pdf
+       if x==24:
+               
curveset("464","BLS461","BLS461","58","28","461","3","NOT_SPECIAL","WEIERSTRASS","BLS","M_TYPE","NEGATIVEX","128")
+               pfcurve_selected=True
+
+       if x==25:
+               
curveset("480","BLS24","BLS24","60","29","479","3","NOT_SPECIAL","WEIERSTRASS","BLS","M_TYPE","POSITIVEX","192")
+               pfcurve_selected=True
+
+
+       if x==26:
+               
curveset("560","BLS48","BLS48","70","29","556","3","NOT_SPECIAL","WEIERSTRASS","BLS","M_TYPE","POSITIVEX","256")
+               pfcurve_selected=True
+
+
+# rsaset(big,ring,big_length_bytes,bit_bits_in_base,multiplier)
+# for each choice give distinct names for "big" and "ring".
+# Typically "big" is the length in bits of the underlying big number type
+# "ring" is the RSA modulus size = "big" times 2^m
+# big_length_bytes is "big" divided by 8
+# Next give the number base used for 32 bit architectures, as n where the base 
is 2^n
+# multiplier is 2^m (see above)
+
+# There are choices here, different ways of getting the same result, but some 
faster than others
+       if x==27:
+               #256 is slower but may allow reuse of 256-bit BIGs used for 
elliptic curve
+               #512 is faster.. but best is 1024
+               rsaset("1024","RSA2048","128","28","2")
+               #rsaset("512","RSA2048","64","29","4")
+               #rsaset("256","RSA2048","32","29","8")
+               rsa_selected=True
+       if x==28:
+               rsaset("384","RSA3072","48","28","8")
+               rsa_selected=True
+       if x==29:
+               #rsaset("256","RSA4096","32","29","16")
+               rsaset("512","RSA4096","64","29","8")
+               rsa_selected=True
+
+
+os.system(deltext+" big.*")
+os.system(deltext+" fp.*")
+os.system(deltext+" ecp.*")
+os.system(deltext+" ecdh.*")
+os.system(deltext+" ff.*")
+os.system(deltext+" rsa.*")
+os.system(deltext+" config_big.h")
+os.system(deltext+" config_field.h")
+os.system(deltext+" config_curve.h")
+os.system(deltext+" config_ff.h")
+os.system(deltext+" fp2.*")
+os.system(deltext+" fp4.*")
+os.system(deltext+" fp8.*")
+os.system(deltext+" fp16.*")
+
+os.system(deltext+" fp12.*")
+os.system(deltext+" fp24.*")
+os.system(deltext+" fp48.*")
+
+os.system(deltext+" ecp2.*")
+os.system(deltext+" ecp4.*")
+os.system(deltext+" ecp8.*")
+
+os.system(deltext+" pair.*")
+os.system(deltext+" mpin.*")
+os.system(deltext+" bls.*")
+
+os.system(deltext+" pair192.*")
+os.system(deltext+" mpin192.*")
+os.system(deltext+" bls192.*")
+
+os.system(deltext+" pair256.*")
+os.system(deltext+" mpin256.*")
+os.system(deltext+" bls256.*")
+
+# create library
+os.system("g++ -O3 -c randapi.cpp")
+if curve_selected :
+       os.system("g++ -O3 -c ecdh_support.cpp")
+if rsa_selected :
+       os.system("g++ -O3 -c rsa_support.cpp")
+if pfcurve_selected :
+       os.system("g++ -O3 -c pbc_support.cpp")
+
+os.system("g++ -O3 -c hash.cpp")
+os.system("g++ -O3 -c rand.cpp")
+os.system("g++ -O3 -c oct.cpp")
+os.system("g++ -O3 -c aes.cpp")
+os.system("g++ -O3 -c gcm.cpp")
+os.system("g++ -O3 -c newhope.cpp")
+
+if sys.platform.startswith("win") :
+       os.system("for %i in (*.o) do @echo %~nxi >> f.list")
+       os.system("ar rc amcl.a @f.list")
+       os.system(deltext+" f.list")
+
+else :
+       os.system("ar rc amcl.a *.o")
+
+os.system(deltext+" *.o")
+
+
+#print("Your section was ")
+#for i in range(0,ptr):
+#      print (selection[i])
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/config64.py
----------------------------------------------------------------------
diff --git a/version3/cpp/config64.py b/version3/cpp/config64.py
new file mode 100644
index 0000000..7087427
--- /dev/null
+++ b/version3/cpp/config64.py
@@ -0,0 +1,685 @@
+import os
+import sys
+
+deltext=""
+if sys.platform.startswith("linux")  :
+       deltext="rm"
+       copytext="cp"
+if sys.platform.startswith("darwin")  :
+       deltext="rm"
+       copytext="cp"
+if sys.platform.startswith("win") :
+       deltext="del"
+       copytext="copy"
+
+def replace(namefile,oldtext,newtext):
+       f = open(namefile,'r')
+       filedata = f.read()
+       f.close()
+
+       newdata = filedata.replace(oldtext,newtext)
+
+       f = open(namefile,'w')
+       f.write(newdata)
+       f.close()
+
+
+def rsaset(tb,tff,nb,base,ml) :
+       bd="B"+tb+"_"+base
+       fnameh="config_big_"+bd+".h"
+       os.system(copytext+" config_big.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"@NB@",nb)
+       replace(fnameh,"@BASE@",base)
+
+       fnameh="config_ff_"+tff+".h"
+       os.system(copytext+" config_ff.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"WWW",tff)
+       replace(fnameh,"@ML@",ml)
+
+       fnamec="big_"+bd+".cpp"
+       fnameh="big_"+bd+".h"
+
+       os.system(copytext+" big.cpp "+fnamec)
+       os.system(copytext+" big.h "+fnameh)
+
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       fnamec="ff_"+tff+".cpp"
+       fnameh="ff_"+tff+".h"
+
+       os.system(copytext+" ff.cpp "+fnamec)
+       os.system(copytext+" ff.h "+fnameh)
+
+       replace(fnamec,"WWW",tff)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"WWW",tff)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       fnamec="rsa_"+tff+".cpp"
+       fnameh="rsa_"+tff+".h"
+
+       os.system(copytext+" rsa.cpp "+fnamec)
+       os.system(copytext+" rsa.h "+fnameh)
+
+       replace(fnamec,"WWW",tff)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"WWW",tff)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+def curveset(tb,tf,tc,nb,base,nbt,m8,mt,ct,pf,stw,sx,cs) :
+       bd="B"+tb+"_"+base
+       fnameh="config_big_"+bd+".h"
+       os.system(copytext+" config_big.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"@NB@",nb)
+       replace(fnameh,"@BASE@",base)
+
+       fnameh="config_field_"+tf+".h"
+       os.system(copytext+" config_field.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"@NBT@",nbt)
+       replace(fnameh,"@M8@",m8)
+       replace(fnameh,"@MT@",mt)
+
+       ib=int(base)
+       inb=int(nb)
+       inbt=int(nbt)
+       sh=ib*(1+((8*inb-1)//ib))-inbt
+
+       if sh > 30 :
+               sh=30
+       replace(fnameh,"@SH@",str(sh))
+
+       fnameh="config_curve_"+tc+".h"  
+       os.system(copytext+" config_curve.h "+fnameh)
+       replace(fnameh,"XXX",bd)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"ZZZ",tc)
+       replace(fnameh,"@CT@",ct)
+       replace(fnameh,"@PF@",pf)
+
+       replace(fnameh,"@ST@",stw)
+       replace(fnameh,"@SX@",sx)
+       replace(fnameh,"@CS@",cs)
+
+
+       fnamec="big_"+bd+".cpp"
+       fnameh="big_"+bd+".h"
+
+       os.system(copytext+" big.cpp "+fnamec)
+       os.system(copytext+" big.h "+fnameh)
+
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       fnamec="fp_"+tf+".cpp"
+       fnameh="fp_"+tf+".h"
+
+       os.system(copytext+" fp.cpp "+fnamec)
+       os.system(copytext+" fp.h "+fnameh)
+
+       replace(fnamec,"YYY",tf)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       os.system("g++ -O3 -c rom_field_"+tf+".cpp")
+
+       fnamec="ecp_"+tc+".cpp"
+       fnameh="ecp_"+tc+".h"
+
+       os.system(copytext+" ecp.cpp "+fnamec)
+       os.system(copytext+" ecp.h "+fnameh)
+
+       replace(fnamec,"ZZZ",tc)
+       replace(fnamec,"YYY",tf)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"ZZZ",tc)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       fnamec="ecdh_"+tc+".cpp"
+       fnameh="ecdh_"+tc+".h"
+
+       os.system(copytext+" ecdh.cpp "+fnamec)
+       os.system(copytext+" ecdh.h "+fnameh)
+
+       replace(fnamec,"ZZZ",tc)
+       replace(fnamec,"YYY",tf)
+       replace(fnamec,"XXX",bd)
+       replace(fnameh,"ZZZ",tc)
+       replace(fnameh,"YYY",tf)
+       replace(fnameh,"XXX",bd)
+       os.system("g++ -O3 -c "+fnamec)
+
+       os.system("g++ -O3 -c rom_curve_"+tc+".cpp")
+
+       if pf != "NOT" :
+               fnamec="fp2_"+tf+".cpp"
+               fnameh="fp2_"+tf+".h"
+
+               os.system(copytext+" fp2.cpp "+fnamec)
+               os.system(copytext+" fp2.h "+fnameh)
+               replace(fnamec,"YYY",tf)
+               replace(fnamec,"XXX",bd)
+               replace(fnameh,"YYY",tf)
+               replace(fnameh,"XXX",bd)
+               os.system("g++ -O3 -c "+fnamec)
+
+               fnamec="fp4_"+tf+".cpp"
+               fnameh="fp4_"+tf+".h"
+
+               os.system(copytext+" fp4.cpp "+fnamec)
+               os.system(copytext+" fp4.h "+fnameh)
+               replace(fnamec,"YYY",tf)
+               replace(fnamec,"XXX",bd)
+               replace(fnamec,"ZZZ",tc)
+               replace(fnameh,"YYY",tf)
+               replace(fnameh,"XXX",bd)
+               replace(fnameh,"ZZZ",tc)
+               os.system("g++ -O3 -c "+fnamec)
+
+               if cs == "128" :
+                       fnamec="fp12_"+tf+".cpp"
+                       fnameh="fp12_"+tf+".h"
+
+                       os.system(copytext+" fp12.cpp "+fnamec)
+                       os.system(copytext+" fp12.h "+fnameh)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="ecp2_"+tc+".cpp"
+                       fnameh="ecp2_"+tc+".h"
+
+                       os.system(copytext+" ecp2.cpp "+fnamec)
+                       os.system(copytext+" ecp2.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="pair_"+tc+".cpp"
+                       fnameh="pair_"+tc+".h"
+
+                       os.system(copytext+" pair.cpp "+fnamec)
+                       os.system(copytext+" pair.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="mpin_"+tc+".cpp"
+                       fnameh="mpin_"+tc+".h"
+
+                       os.system(copytext+" mpin.cpp "+fnamec)
+                       os.system(copytext+" mpin.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+
+                       fnamec="bls_"+tc+".cpp"
+                       fnameh="bls_"+tc+".h"
+
+                       os.system(copytext+" bls.cpp "+fnamec)
+                       os.system(copytext+" bls.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+               if cs == "192" :
+                       fnamec="fp8_"+tf+".cpp"
+                       fnameh="fp8_"+tf+".h"
+
+                       os.system(copytext+" fp8.cpp "+fnamec)
+                       os.system(copytext+" fp8.h "+fnameh)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+                       fnamec="fp24_"+tf+".cpp"
+                       fnameh="fp24_"+tf+".h"
+
+                       os.system(copytext+" fp24.cpp "+fnamec)
+                       os.system(copytext+" fp24.h "+fnameh)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="ecp4_"+tc+".cpp"
+                       fnameh="ecp4_"+tc+".h"
+
+                       os.system(copytext+" ecp4.cpp "+fnamec)
+                       os.system(copytext+" ecp4.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="pair192_"+tc+".cpp"
+                       fnameh="pair192_"+tc+".h"
+
+                       os.system(copytext+" pair192.cpp "+fnamec)
+                       os.system(copytext+" pair192.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="mpin192_"+tc+".cpp"
+                       fnameh="mpin192_"+tc+".h"
+
+                       os.system(copytext+" mpin192.cpp "+fnamec)
+                       os.system(copytext+" mpin192.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="bls192_"+tc+".cpp"
+                       fnameh="bls192_"+tc+".h"
+
+                       os.system(copytext+" bls192.cpp "+fnamec)
+                       os.system(copytext+" bls192.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+               if cs == "256" :
+
+                       fnamec="fp8_"+tf+".cpp"
+                       fnameh="fp8_"+tf+".h"
+
+                       os.system(copytext+" fp8.cpp "+fnamec)
+                       os.system(copytext+" fp8.h "+fnameh)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+                       fnamec="ecp8_"+tc+".cpp"
+                       fnameh="ecp8_"+tc+".h"
+
+                       os.system(copytext+" ecp8.cpp "+fnamec)
+                       os.system(copytext+" ecp8.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+                       fnamec="fp16_"+tf+".cpp"
+                       fnameh="fp16_"+tf+".h"
+
+                       os.system(copytext+" fp16.cpp "+fnamec)
+                       os.system(copytext+" fp16.h "+fnameh)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+                       fnamec="fp48_"+tf+".cpp"
+                       fnameh="fp48_"+tf+".h"
+
+                       os.system(copytext+" fp48.cpp "+fnamec)
+                       os.system(copytext+" fp48.h "+fnameh)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+
+                       fnamec="pair256_"+tc+".cpp"
+                       fnameh="pair256_"+tc+".h"
+
+                       os.system(copytext+" pair256.cpp "+fnamec)
+                       os.system(copytext+" pair256.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="mpin256_"+tc+".cpp"
+                       fnameh="mpin256_"+tc+".h"
+
+                       os.system(copytext+" mpin256.cpp "+fnamec)
+                       os.system(copytext+" mpin256.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+                       fnamec="bls256_"+tc+".cpp"
+                       fnameh="bls256_"+tc+".h"
+
+                       os.system(copytext+" bls256.cpp "+fnamec)
+                       os.system(copytext+" bls256.h "+fnameh)
+                       replace(fnamec,"ZZZ",tc)
+                       replace(fnamec,"YYY",tf)
+                       replace(fnamec,"XXX",bd)
+                       replace(fnameh,"ZZZ",tc)
+                       replace(fnameh,"YYY",tf)
+                       replace(fnameh,"XXX",bd)
+                       os.system("g++ -O3 -c "+fnamec)
+
+replace("arch.h","@WL@","64")
+print("Elliptic Curves")
+print("1. ED25519")
+print("2. C25519")
+print("3. NIST256")
+print("4. BRAINPOOL")
+print("5. ANSSI")
+print("6. HIFIVE")
+print("7. GOLDILOCKS")
+print("8. NIST384")
+print("9. C41417")
+print("10. NIST521\n")
+print("11. NUMS256W")
+print("12. NUMS256E")
+print("13. NUMS384W")
+print("14. NUMS384E")
+print("15. NUMS512W")
+print("16. NUMS512E")
+print("17. SECP256K1\n")
+
+print("Pairing-Friendly Elliptic Curves")
+print("18. BN254")
+print("19. BN254CX")
+print("20. BLS383")
+print("21. BLS381")
+print("22. FP256BN")
+print("23. FP512BN")
+print("24. BLS461\n")
+print("25. BLS24")
+print("26. BLS48\n")
+
+print("RSA")
+print("27. RSA2048")
+print("28. RSA3072")
+print("29. RSA4096")
+
+selection=[]
+ptr=0
+max=30
+
+curve_selected=False
+pfcurve_selected=False
+rsa_selected=False
+
+while ptr<max:
+       x=int(input("Choose a Scheme to support - 0 to finish: "))
+       if x == 0:
+               break
+#      print("Choice= ",x)
+       already=False
+       for i in range(0,ptr):
+               if x==selection[i]:
+                       already=True
+                       break
+       if already:
+               continue
+       
+       selection.append(x)
+       ptr=ptr+1
+
+# 
curveset(big,field,curve,big_length_bytes,bits_in_base,modulus_bits,modulus_mod_8,modulus_type,curve_type,pairing_friendly,sextic
 twist,sign of x,curve security)
+# for each curve give names for big, field and curve. In many cases the latter 
two will be the same. 
+# Typically "big" is the size in bits, always a multiple of 8, "field" 
describes the modulus, and "curve" is the common name for the elliptic curve   
+# big_length_bytes is "big" divided by 8
+# Next give the number base used for 64 bit architectures, as n where the base 
is 2^n (note that these must be fixed for the same "big" name, if is ever 
re-used for another curve)
+# modulus_bits is the bit length of the modulus, typically the same or 
slightly smaller than "big"
+# modulus_mod_8 is the remainder when the modulus is divided by 8
+# modulus_type is NOT_SPECIAL, or PSEUDO_MERSENNE, or MONTGOMERY_Friendly, or 
GENERALISED_MERSENNE (supported for GOLDILOCKS only)
+# curve_type is WEIERSTRASS, EDWARDS or MONTGOMERY
+# pairing_friendly is BN, BLS or NOT (if not pairing friendly)
+# if pairing friendly. M or D type twist, and sign of the family parameter x
+# curve security is AES equiavlent, rounded up.
+
+
+       if x==1:
+               
curveset("256","F25519","ED25519","32","56","255","5","PSEUDO_MERSENNE","EDWARDS","NOT","","","128")
+               curve_selected=True
+       if x==2:
+               
curveset("256","F25519","C25519","32","56","255","5","PSEUDO_MERSENNE","MONTGOMERY","NOT","","","128")
+               curve_selected=True
+       if x==3:
+               
curveset("256","NIST256","NIST256","32","56","256","7","NOT_SPECIAL","WEIERSTRASS","NOT","","","128")
+               curve_selected=True
+       if x==4:
+               
curveset("256","BRAINPOOL","BRAINPOOL","32","56","256","7","NOT_SPECIAL","WEIERSTRASS","NOT","","","128")
+               curve_selected=True
+       if x==5:
+               
curveset("256","ANSSI","ANSSI","32","56","256","7","NOT_SPECIAL","WEIERSTRASS","NOT","","","128")
+               curve_selected=True
+
+       if x==6:
+               
curveset("336","HIFIVE","HIFIVE","42","60","336","5","PSEUDO_MERSENNE","EDWARDS","NOT","","","192")
+               curve_selected=True
+       if x==7:
+               
curveset("448","GOLDILOCKS","GOLDILOCKS","56","58","448","7","GENERALISED_MERSENNE","EDWARDS","NOT","","","256")
+               curve_selected=True
+       if x==8:
+               
curveset("384","NIST384","NIST384","48","56","384","7","NOT_SPECIAL","WEIERSTRASS","NOT","","","192")
+               curve_selected=True
+       if x==9:
+               
curveset("416","C41417","C41417","52","60","414","7","PSEUDO_MERSENNE","EDWARDS","NOT","","","256")
+               curve_selected=True
+       if x==10:
+               
curveset("528","NIST521","NIST521","66","60","521","7","PSEUDO_MERSENNE","WEIERSTRASS","NOT","","","256")
+               curve_selected=True
+
+       if x==11:
+               
curveset("256","F256PMW","NUMS256W","32","56","256","3","PSEUDO_MERSENNE","WEIERSTRASS","NOT","","","128")
+               curve_selected=True
+       if x==12:
+               
curveset("256","F256PME","NUMS256E","32","56","256","3","PSEUDO_MERSENNE","EDWARDS","NOT","","","128")
+               curve_selected=True
+       if x==13:
+               
curveset("384","F384PM","NUMS384W","48","56","384","3","PSEUDO_MERSENNE","WEIERSTRASS","NOT","","","192")
+               curve_selected=True
+       if x==14:
+               
curveset("384","F384PM","NUMS384E","48","56","384","3","PSEUDO_MERSENNE","EDWARDS","NOT","","","192")
+               curve_selected=True
+       if x==15:
+               
curveset("512","F512PM","NUMS512W","64","56","512","7","PSEUDO_MERSENNE","WEIERSTRASS","NOT","","","256")
+               curve_selected=True
+       if x==16:
+               
curveset("512","F512PM","NUMS512E","64","56","512","7","PSEUDO_MERSENNE","EDWARDS","NOT","","","256")
+               curve_selected=True
+
+       if x==17:
+               
curveset("256","SECP256K1","SECP256K1","32","56","256","7","NOT_SPECIAL","WEIERSTRASS","NOT","","","128")
+               curve_selected=True
+
+       if x==18:
+               
curveset("256","BN254","BN254","32","56","254","3","NOT_SPECIAL","WEIERSTRASS","BN","D_TYPE","NEGATIVEX","128")
+               pfcurve_selected=True
+       if x==19:
+               
curveset("256","BN254CX","BN254CX","32","56","254","3","NOT_SPECIAL","WEIERSTRASS","BN","D_TYPE","NEGATIVEX","128")
+               pfcurve_selected=True
+       if x==20:
+               
curveset("384","BLS383","BLS383","48","58","383","3","NOT_SPECIAL","WEIERSTRASS","BLS","M_TYPE","POSITIVEX","128")
+               pfcurve_selected=True
+
+       if x==21:
+               
curveset("384","BLS381","BLS381","48","58","381","3","NOT_SPECIAL","WEIERSTRASS","BLS","M_TYPE","NEGATIVEX","128")
+               pfcurve_selected=True
+
+       if x==22:
+               
curveset("256","FP256BN","FP256BN","32","56","256","3","NOT_SPECIAL","WEIERSTRASS","BN","M_TYPE","NEGATIVEX","128")
+               pfcurve_selected=True
+       if x==23:
+               
curveset("512","FP512BN","FP512BN","64","60","512","3","NOT_SPECIAL","WEIERSTRASS","BN","M_TYPE","POSITIVEX","128")
+               pfcurve_selected=True
+# https://eprint.iacr.org/2017/334.pdf
+       if x==24:
+               
curveset("464","BLS461","BLS461","58","60","461","3","NOT_SPECIAL","WEIERSTRASS","BLS","M_TYPE","NEGATIVEX","128")
+               pfcurve_selected=True
+
+       if x==25:
+               
curveset("480","BLS24","BLS24","60","56","479","3","NOT_SPECIAL","WEIERSTRASS","BLS","M_TYPE","POSITIVEX","192")
+               pfcurve_selected=True
+
+       if x==26:
+               
curveset("560","BLS48","BLS48","70","58","556","3","NOT_SPECIAL","WEIERSTRASS","BLS","M_TYPE","POSITIVEX","256")
+               pfcurve_selected=True
+
+
+# rsaset(big,ring,big_length_bytes,bits_in_base,multiplier)
+# for each choice give distinct names for "big" and "ring".
+# Typically "big" is the length in bits of the underlying big number type
+# "ring" is the RSA modulus size = "big" times 2^m
+# big_length_bytes is "big" divided by 8
+# Next give the number base used for 64 bit architectures, as n where the base 
is 2^n
+# multiplier is 2^m (see above)
+
+# There are choices here, different ways of getting the same result, but some 
faster than others
+       if x==27:
+               #256 is slower but may allow reuse of 256-bit BIGs used for 
elliptic curve
+               #512 is faster.. but best is 1024
+               rsaset("1024","RSA2048","128","58","2")
+               #rsaset("512","RSA2048","64","60","4")
+               #rsaset("256","RSA2048","32","56","8")
+               rsa_selected=True
+       if x==28:
+               rsaset("384","RSA3072","48","56","8")
+               rsa_selected=True
+       if x==29:
+               #rsaset("256","RSA4096","32","56","16")
+               rsaset("512","RSA4096","64","60","8")
+               rsa_selected=True
+
+
+os.system(deltext+" big.*")
+os.system(deltext+" fp.*")
+os.system(deltext+" ecp.*")
+os.system(deltext+" ecdh.*")
+os.system(deltext+" ff.*")
+os.system(deltext+" rsa.*")
+os.system(deltext+" config_big.h")
+os.system(deltext+" config_field.h")
+os.system(deltext+" config_curve.h")
+os.system(deltext+" config_ff.h")
+os.system(deltext+" fp2.*")
+os.system(deltext+" fp4.*")
+os.system(deltext+" fp8.*")
+os.system(deltext+" fp16.*")
+
+os.system(deltext+" fp12.*")
+os.system(deltext+" fp24.*")
+os.system(deltext+" fp48.*")
+
+os.system(deltext+" ecp2.*")
+os.system(deltext+" ecp4.*")
+os.system(deltext+" ecp8.*")
+
+os.system(deltext+" pair.*")
+os.system(deltext+" mpin.*")
+os.system(deltext+" bls.*")
+
+os.system(deltext+" pair192.*")
+os.system(deltext+" mpin192.*")
+os.system(deltext+" bls192.*")
+
+os.system(deltext+" pair256.*")
+os.system(deltext+" mpin256.*")
+os.system(deltext+" bls256.*")
+
+# create library
+os.system("g++ -O3 -c randapi.cpp")
+if curve_selected :
+       os.system("g++ -O3 -c ecdh_support.cpp")
+if rsa_selected :
+       os.system("g++ -O3 -c rsa_support.cpp")
+if pfcurve_selected :
+       os.system("g++ -O3 -c pbc_support.cpp")
+
+os.system("g++ -O3 -c hash.cpp")
+os.system("g++ -O3 -c rand.cpp")
+os.system("g++ -O3 -c oct.cpp")
+os.system("g++ -O3 -c aes.cpp")
+os.system("g++ -O3 -c gcm.cpp")
+os.system("g++ -O3 -c newhope.cpp")
+
+if sys.platform.startswith("win") :
+       os.system("for %i in (*.o) do @echo %~nxi >> f.list")
+       os.system("ar rc amcl.a @f.list")
+       os.system(deltext+" f.list")
+
+else :
+       os.system("ar rc amcl.a *.o")
+
+os.system(deltext+" *.o")
+
+
+#print("Your section was ")
+#for i in range(0,ptr):
+#      print (selection[i])
+

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/config_big.h
----------------------------------------------------------------------
diff --git a/version3/cpp/config_big.h b/version3/cpp/config_big.h
new file mode 100644
index 0000000..6d12010
--- /dev/null
+++ b/version3/cpp/config_big.h
@@ -0,0 +1,12 @@
+#ifndef CONFIG_BIG_XXX_H
+#define CONFIG_BIG_XXX_H
+
+#include"amcl.h"
+
+// BIG stuff
+
+#define MODBYTES_XXX @NB@  
+#define BASEBITS_XXX @BASE@ 
+
+
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/config_curve.h
----------------------------------------------------------------------
diff --git a/version3/cpp/config_curve.h b/version3/cpp/config_curve.h
new file mode 100644
index 0000000..4f905d5
--- /dev/null
+++ b/version3/cpp/config_curve.h
@@ -0,0 +1,47 @@
+#ifndef CONFIG_CURVE_ZZZ_H
+#define CONFIG_CURVE_ZZZ_H
+
+#include"amcl.h"
+#include"config_field_YYY.h"
+
+// ECP stuff
+
+#define CURVETYPE_ZZZ @CT@  
+#define PAIRING_FRIENDLY_ZZZ @PF@
+#define CURVE_SECURITY_ZZZ @CS@
+
+#if PAIRING_FRIENDLY_ZZZ != NOT
+#define USE_GLV_ZZZ      /**< Note this method is patented (GLV), so maybe you 
want to comment this out */
+#define USE_GS_G2_ZZZ /**< Well we didn't patent it :) But may be covered by 
GLV patent :( */
+#define USE_GS_GT_ZZZ /**< Not patented, so probably safe to always use this */
+
+#define POSITIVEX 0
+#define NEGATIVEX 1
+
+#define SEXTIC_TWIST_ZZZ @ST@
+#define SIGN_OF_X_ZZZ @SX@ 
+
+#endif
+
+
+#if CURVE_SECURITY_ZZZ == 128
+#define AESKEY_ZZZ 16 /**< Symmetric Key size - 128 bits */
+#define HASH_TYPE_ZZZ SHA256  /**< Hash type */
+#endif
+
+#if CURVE_SECURITY_ZZZ == 192
+#define AESKEY_ZZZ 24 /**< Symmetric Key size - 192 bits */
+#define HASH_TYPE_ZZZ SHA384  /**< Hash type */
+#endif
+
+#if CURVE_SECURITY_ZZZ == 256
+#define AESKEY_ZZZ 32 /**< Symmetric Key size - 256 bits */
+#define HASH_TYPE_ZZZ SHA512  /**< Hash type */
+#endif
+
+
+
+namespace ZZZ_BIG=XXX;
+namespace ZZZ_FP=YYY;
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/config_ff.h
----------------------------------------------------------------------
diff --git a/version3/cpp/config_ff.h b/version3/cpp/config_ff.h
new file mode 100644
index 0000000..33cb95a
--- /dev/null
+++ b/version3/cpp/config_ff.h
@@ -0,0 +1,13 @@
+#ifndef CONFIG_RSA_WWW_H
+#define CONFIG_RSA_WWW_H
+
+#include "amcl.h"
+#include "config_big_XXX.h"
+
+// FF stuff
+
+#define FFLEN_WWW @ML@ /**< 2^n multiplier of BIGBITS to specify supported 
Finite Field size, e.g 2048=256*2^3 where BIGBITS=256 */
+
+namespace WWW_BIG=XXX;
+
+#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-milagro-crypto/blob/c25f9e5c/version3/cpp/config_field.h
----------------------------------------------------------------------
diff --git a/version3/cpp/config_field.h b/version3/cpp/config_field.h
new file mode 100644
index 0000000..ab86941
--- /dev/null
+++ b/version3/cpp/config_field.h
@@ -0,0 +1,15 @@
+#ifndef CONFIG_FIELD_YYY_H
+#define CONFIG_FIELD_YYY_H
+
+#include"amcl.h"
+#include "config_big_XXX.h"
+
+// FP stuff
+
+#define MBITS_YYY @NBT@                
+#define MOD8_YYY @M8@   
+#define MODTYPE_YYY @MT@
+#define MAXXES_YYY @SH@
+
+
+#endif
\ No newline at end of file

Reply via email to