primitives/sharing/authenticated/
scalar_share.rs1use std::ops::Mul;
2
3use super::{FieldShare, OpenFieldShare, PointShare};
4use crate::algebra::{
5 elliptic_curve::{BaseField, Curve, Point, ScalarField},
6 field::binary::Gf2_128,
7};
8
9pub type OpenScalarShare<C> = OpenFieldShare<ScalarField<C>>;
12pub type OpenBaseFieldShare<C> = OpenFieldShare<BaseField<C>>;
13pub type OpenBitShare = OpenFieldShare<Gf2_128>;
14
15pub type ScalarShare<C> = FieldShare<ScalarField<C>>;
16pub type BaseFieldShare<C> = FieldShare<BaseField<C>>;
17pub type BitShare = FieldShare<Gf2_128>;
18
19#[macros::op_variants(owned, borrowed, flipped)]
22impl<'a, C: Curve> Mul<&'a Point<C>> for ScalarShare<C> {
23 type Output = PointShare<C>;
24
25 #[inline]
26 fn mul(self, other: &'a Point<C>) -> PointShare<C> {
27 PointShare {
28 value: self.value * other,
29 keys: self.keys.iter().map(|key| key * other).collect(),
30 macs: self.macs.iter().map(|mac| mac * other).collect(),
31 }
32 }
33}
34
35#[macros::op_variants(owned, borrowed, flipped)]
36impl<'a, C: Curve> Mul<&'a ScalarShare<C>> for Point<C> {
37 type Output = PointShare<C>;
38
39 #[inline]
40 fn mul(self, other: &'a ScalarShare<C>) -> PointShare<C> {
41 PointShare {
42 value: other.value * self,
43 macs: other.macs.iter().map(|mac| mac * self).collect(),
44 keys: other.keys.iter().map(|key| key * self).collect(),
45 }
46 }
47}