|
@@ -24,6 +24,12 @@ TwistBipoint::TwistBipoint(twistpoint_fp2_t p1, twistpoint_fp2_t p2)
|
|
twistpoint_fp2_set(point[1], p2);
|
|
twistpoint_fp2_set(point[1], p2);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+CurveBipoint::CurveBipoint(const Curvepoint& p1, const Curvepoint& p2)
|
|
|
|
+{
|
|
|
|
+ curvepoint_fp_set(point[0], p1.toCurvepointFpT());
|
|
|
|
+ curvepoint_fp_set(point[1], p2.toCurvepointFpT());
|
|
|
|
+}
|
|
|
|
+
|
|
curvepoint_fp_t& CurveBipoint::operator[](int n)
|
|
curvepoint_fp_t& CurveBipoint::operator[](int n)
|
|
{
|
|
{
|
|
return point[n];
|
|
return point[n];
|
|
@@ -76,6 +82,44 @@ TwistBipoint TwistBipoint::operator+(const TwistBipoint& b) const
|
|
return retval;
|
|
return retval;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+CurveBipoint CurveBipoint::operator-(const CurveBipoint& b) const
|
|
|
|
+{
|
|
|
|
+ CurveBipoint retval, inverseB;
|
|
|
|
+
|
|
|
|
+ if (!equal(point[0], b[0]))
|
|
|
|
+ {
|
|
|
|
+ curvepoint_fp_neg(inverseB[0], b[0]);
|
|
|
|
+ curvepoint_fp_add_vartime(retval[0], point[0], inverseB[0]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!equal(point[1], b[1]))
|
|
|
|
+ {
|
|
|
|
+ curvepoint_fp_neg(inverseB[1], b[1]);
|
|
|
|
+ curvepoint_fp_add_vartime(retval[1], point[1], inverseB[1]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return retval;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+TwistBipoint TwistBipoint::operator-(const TwistBipoint& b) const
|
|
|
|
+{
|
|
|
|
+ TwistBipoint retval, inverseB;
|
|
|
|
+
|
|
|
|
+ if (!equal(point[0], b[0]))
|
|
|
|
+ {
|
|
|
|
+ twistpoint_fp2_neg(inverseB[0], b[0]);
|
|
|
|
+ twistpoint_fp2_add_vartime(retval[0], point[0], inverseB[0]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!equal(point[1], b[1]))
|
|
|
|
+ {
|
|
|
|
+ twistpoint_fp2_neg(inverseB[1], b[1]);
|
|
|
|
+ twistpoint_fp2_add_vartime(retval[1], point[1], inverseB[1]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return retval;
|
|
|
|
+}
|
|
|
|
+
|
|
CurveBipoint CurveBipoint::operator*(const Scalar& exp) const
|
|
CurveBipoint CurveBipoint::operator*(const Scalar& exp) const
|
|
{
|
|
{
|
|
CurveBipoint retval;
|
|
CurveBipoint retval;
|