1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #include "PublicKey.hpp"
- PublicKey(const Bipoint<curvepoint_fp_t>& g, const Bipoint<twistpoint_fp2_t>& h, const Bipoint<curvepoint_fp_t>& g1, const Bipoint<twistpoint_fp2_t>& h1)
- {
- set(g, h, g1, h1);
- }
- void set(const Bipoint<curvepoint_fp_t>& g, const Bipoint<twistpoint_fp2_t>& h, const Bipoint<curvepoint_fp_t>& g1, const Bipoint<twistpoint_fp2_t>& h1)
- {
- bipoint_curvegen = g;
- bipoint_twistgen = h;
-
- bipoint_curve_subgroup_gen = g1;
- bipoint_twist_subgroup_gen = h1;
- }
- void PublicKey::encrypt(Bipoint<curvepoint_fp_t>& G_element, const Scalar& cleartext) const
- {
- Scalar lambda;
- lambda.set_random();
- Bipoint<curvepoint_fp_t> cleartext_as_element, random_mask;
- cleartext_as_element = get_bipoint_curvegen() * cleartext;
- random_mask = get_bipoint_curve_subgroup_gen() * lambda;
- G_element = cleartext_as_element + random_mask;
- }
- void PublicKey::encrypt(Bipoint<twistpoint_fp2_t>& H_element, const Scalar& cleartext) const
- {
- Scalar lambda;
- lambda.set_random();
- Bipoint<twistpoint_fp2_t> cleartext_as_element, random_mask;
- cleartext_as_element = get_bipoint_twistgen() * cleartext;
- random_mask = get_bipoint_twist_subgroup_gen() * lambda;
- H_element = cleartext_as_element + random_mask;
- }
- void PublicKey::encrypt(Bipoint<curvepoint_fp_t>& G_element, Bipoint<twistpoint_fp2_t>& H_element, const Scalar& cleartext) const
- {
- encrypt(G_element, cleartext);
- encrypt(H_element, cleartext);
- }
- Bipoint<curvepoint_fp_t> PublicKey::get_bipoint_curvegen() const
- {
- return bipoint_curvegen;
- }
- Bipoint<twistpoint_fp2_t> PublicKey::get_bipoint_twistgen() const
- {
- return bipoint_twistgen;
- }
- Bipoint<curvepoint_fp_t> PublicKey::get_bipoint_curve_subgroup_gen() const
- {
- return bipoint_curve_subgroup_gen;
- }
- Bipoint<twistpoint_fp2_t> PublicKey::get_bipoint_twist_subgroup_gen() const
- {
- return bipoint_twist_subgroup_gen;
- }
|