/***************************************************************************
*
Copyright 2013 CertiVox UK Ltd. *
*
This file is part of CertiVox MIRACL Crypto SDK. *
*
The CertiVox MIRACL Crypto SDK provides developers with an *
extensive and efficient set of cryptographic functions. *
For further information about its features and functionalities please *
refer to http://www.certivox.com *
*
* The CertiVox MIRACL Crypto SDK is free software: you can *
redistribute it and/or modify it under the terms of the *
GNU Affero General Public License as published by the *
Free Software Foundation, either version 3 of the License, *
or (at your option) any later version. *
*
* The CertiVox MIRACL Crypto SDK is distributed in the hope *
that it will be useful, but WITHOUT ANY WARRANTY; without even the *
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
See the GNU Affero General Public License for more details. *
*
* You should have received a copy of the GNU Affero General Public *
License along with CertiVox MIRACL Crypto SDK. *
If not, see . *
*
You can be released from the requirements of the license by purchasing *
a commercial license. Buying such a license is mandatory as soon as you *
develop commercial activities involving the CertiVox MIRACL Crypto SDK *
without disclosing the source code of your own applications, or shipping *
the CertiVox MIRACL Crypto SDK with a closed source product. *
*
***************************************************************************/
/*
* MIRACL C++ Header file ZZn4.h
*
* AUTHOR : M. Scott
*
* NOTE: : Must be used in conjunction with zzn2.cpp big.cpp and zzn.cpp
* : This is designed as a "towering extension", so a ZZn4 consists
* : of a pair of ZZn2. An element looks like (a+x^2.b) + x(c+x^2.d)
*
* PURPOSE : Definition of class ZZn4 (Arithmetic over n^4)
*
* WARNING: This class has been cobbled together for a specific use with
* the MIRACL library. It is not complete, and may not work in other
* applications
*
* Note: This code assumes that
* p=5 mod 8
* OR p=3 mod 8
* OR p=7 mod 8, p=2,3 mod 5
*
* Irreducible poly is X^2+n, where n=w+sqrt(m), m= {-1,-2} and w= {0,1,2}
* if p=5 mod 8, n=sqrt(-2)
* if p=3 mod 8, n=1+sqrt(-1)
* if p=7 mod 8, p=2,3 mod 5, n=2+sqrt(-1)
*
*/
#ifndef ZZN4_H
#define ZZN4_H
#include "zzn2.h"
#ifdef ZZNS
#define MR_INIT_ZZN4 {fn.a.a=&at; at.w=a; at.len=UZZNS; fn.a.b=&bt; bt.w=b; bt.len=UZZNS; fn.b.a=&ct; ct.w=c; ct.len=UZZNS; fn.b.b=&dt; dt.w=d; dt.len=UZZNS; fn.unitary=FALSE;}
#define MR_CLONE_ZZN4(x) {fn.unitary=x.fn.unitary; at.len=x.at.len; bt.len=x.bt.len; ct.len=x.ct.len; dt.len=x.dt.len; for (int i=0;i