//subtract Keys (subtracts curve points)
 //AB = A - B where A, B are curve points
 void subKeys(key & AB, const key &A, const key &B) {
     ge_p3 B2, A2;
     CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&B2, B.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
     CHECK_AND_ASSERT_THROW_MES(ge_frombytes_vartime(&A2, A.bytes) == 0, "ge_frombytes_vartime failed at "+boost::lexical_cast<std::string>(__LINE__));
     ge_cached tmp2;
     ge_p3_to_cached(&tmp2, &B2);
     ge_p1p1 tmp3;
     ge_sub(&tmp3, &A2, &tmp2);
     ge_p1p1_to_p3(&A2, &tmp3);
     ge_p3_tobytes(AB.bytes, &A2);
 }
Beispiel #2
0
 bool crypto_ops::underive_public_key(const key_derivation &derivation, size_t output_index,
   const public_key &derived_key, public_key &base) {
   ec_scalar scalar;
   ge_p3 point1;
   ge_p3 point2;
   ge_cached point3;
   ge_p1p1 point4;
   ge_p2 point5;
   if (ge_frombytes_vartime(&point1, &derived_key) != 0) {
     return false;
   }
   derivation_to_scalar(derivation, output_index, scalar);
   ge_scalarmult_base(&point2, &scalar);
   ge_p3_to_cached(&point3, &point2);
   ge_sub(&point4, &point1, &point3);
   ge_p1p1_to_p2(&point5, &point4);
   ge_tobytes(&base, &point5);
   return true;
 }