/usr/include/eclib/ffmod.h is in libec-dev 20160720-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | // ffmod.h: declaration of class ffmodq and Weil pairing functions
//////////////////////////////////////////////////////////////////////////
//
// Copyright 1990-2012 John Cremona
//
// This file is part of the eclib package.
//
// eclib is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version.
//
// eclib 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 General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License
// along with eclib; if not, write to the Free Software Foundation,
// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
//
//////////////////////////////////////////////////////////////////////////
// ffmodq is the function field of an elliptic curve mod a prime q
// (or more precisely the affine coordinate ring Fq[x,y])
// allow for multiple includes
#ifndef _FFMOD_
#define _FFMOD_
#include "curve.h"
#include "curvemod.h"
#include "pointsmod.h"
class ffmodq{
public:
static galois_field Fq; // the constant field
static curvemodq E; // the curve mod q
static FqPoly f1, f2; // f2=a1*x+a3, f2=x^3+a2*x^2+a4*x+a6
FqPoly h1, h2; // for h1+y*h2
public:
// constructors
// special one to initialize the curve and field only:
ffmodq(const curvemodq& EE);
// normal ones:
ffmodq(void)
{
init_h1h2();
FqPolyAssign0(h1);
FqPolyAssign0(h2);
}
ffmodq(const gf_element& c)
{
init_h1h2();
FqPolyAssignGF(h1,c);
FqPolyAssign0(h2);
}
ffmodq(const bigint& c)
{
init_h1h2();
FqPolyAssignZ(h1,c);
FqPolyAssign0(h2);
}
ffmodq(const FqPoly& hh1)
{
init_h1h2();
h1=hh1;
FqPolyAssign0(h2);
}
ffmodq(const FqPoly& hh1, const FqPoly& hh2) {h1=hh1; h2=hh2;}
// initialization
void init_f1f2(void);
void init_h1h2(void)
{
FqPolySetField(h1,Fq);
FqPolySetField(h2,Fq);
}
// assignment
void operator=(const ffmodq& a) {h1=a.h1; h2=a.h2;}
// equality test
int operator==(const ffmodq& b) const;
int operator!=(const ffmodq& b) const {return !((*this)==b);}
// output
void output(ostream& os) const;
// addition, subtraction, multiplication
ffmodq operator+(const ffmodq& b) const;
ffmodq operator-(const ffmodq& b) const;
ffmodq operator*(const ffmodq& b) const;
ffmodq operator*(const FqPoly& h) const;
// division
ffmodq operator/(const FqPoly& h) const;
ffmodq operator/(const ffmodq& b) const;
// evaluation at a point:
gf_element evaluate(const pointmodq& P) const;
gf_element operator()(const pointmodq& P) const {return this->evaluate(P);}
// vertical line through a point:
friend ffmodq vertical(const pointmodq& P);
// tangent at a point:
friend ffmodq tangent(const pointmodq& P);
// chord between points:
friend ffmodq chord(const pointmodq& P, const pointmodq& Q);
};
// weil_pol(T,m): T is a point of finite order m; returns a function
// f_T whose divisor is m(T)-m(0).
// The second version evaluates that at another point S without
// actually computing the polynomial
ffmodq weil_pol(const pointmodq& T, int m);
gf_element evaluate_weil_pol(const pointmodq& T, int m, const pointmodq& S);
gf_element weil_pairing(const pointmodq& S, const pointmodq& T, int m);
inline ostream& operator<<(ostream& os, const ffmodq& f)
{
f.output(os);
return os;
}
#endif
|