MCPcopy Create free account
hub / github.com/docknetwork/crypto / scale_vector

Function scale_vector

legogroth16/src/link/utils.rs:128–138  ·  view source on GitHub ↗

Scale given vector `v` by scalar `a`

(
    a: &PE::ScalarField,
    v: &[PE::ScalarField],
)

Source from the content-addressed store, hash-verified

126
127/// Scale given vector `v` by scalar `a`
128pub fn scale_vector<PE: Pairing>(
129 a: &PE::ScalarField,
130 v: &[PE::ScalarField],
131) -> Vec<PE::ScalarField> {
132 let mut res: Vec<PE::ScalarField> = Vec::with_capacity(v.len());
133 for i in 0..v.len() {
134 let x: PE::ScalarField = a.mul(&v[i]);
135 res.push(x);
136 }
137 res
138}
139
140/// Given a group element `g` and vector `multiples` of scalars, returns a vector with elements `v_i * g`
141pub fn multiples_of_g<G: AffineRepr>(g: &G, multiples: &[G::ScalarField]) -> Vec<G> {

Callers

nothing calls this directly

Calls 2

mulMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected