primitives/sharing/authenticated/batched/
scalar_keys.rs1use std::ops::Mul;
2
3use crate::{
4 algebra::elliptic_curve::{BaseField, Curve, Point, ScalarField},
5 sharing::{CurveKeys, FieldShareKeys},
6 types::{heap_array::curve_arrays::CurvePoints, Positive},
7};
8
9pub type ScalarKeys<C, M> = FieldShareKeys<ScalarField<C>, M>;
10pub type BaseKeys<C, M> = FieldShareKeys<BaseField<C>, M>;
11
12#[macros::op_variants(owned, borrowed, flipped)]
15impl<'a, C: Curve, M: Positive> Mul<&'a CurvePoints<C, M>> for ScalarKeys<C, M> {
16 type Output = CurveKeys<C, M>;
17
18 #[inline]
19 fn mul(self, other: &'a CurvePoints<C, M>) -> Self::Output {
20 CurveKeys {
21 alpha: self.alpha.clone(),
22 betas: self.betas * other,
23 }
24 }
25}
26
27#[macros::op_variants(owned, borrowed, flipped)]
30impl<'a, C: Curve, M: Positive> Mul<&'a Point<C>> for ScalarKeys<C, M> {
31 type Output = CurveKeys<C, M>;
32
33 #[inline]
34 fn mul(self, other: &'a Point<C>) -> CurveKeys<C, M> {
35 CurveKeys {
36 alpha: self.alpha,
37 betas: self.betas * other,
38 }
39 }
40}
41
42#[macros::op_variants(owned, borrowed, flipped)]
45impl<'a, C: Curve, M: Positive> Mul<&'a ScalarKeys<C, M>> for CurvePoints<C, M> {
46 type Output = CurveKeys<C, M>;
47
48 #[inline]
49 fn mul(self, other: &'a ScalarKeys<C, M>) -> CurveKeys<C, M> {
50 CurveKeys {
51 alpha: other.alpha.clone(),
52 betas: self * &other.betas,
53 }
54 }
55}
56
57#[macros::op_variants(owned, borrowed, flipped)]
60impl<'a, C: Curve, M: Positive> Mul<&'a ScalarKeys<C, M>> for Point<C> {
61 type Output = CurveKeys<C, M>;
62
63 #[inline]
64 fn mul(self, other: &'a ScalarKeys<C, M>) -> CurveKeys<C, M> {
65 CurveKeys {
66 alpha: other.alpha.clone(),
67 betas: &other.betas * self,
68 }
69 }
70}