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

Function powers_starting_from

utils/src/ff.rs:88–97  ·  view source on GitHub ↗

Powers of a finite field as `[start, start*exp, start * exp^2, .. start * exp^{num-1}]`

(start: F, exp: &F, num: u32)

Source from the content-addressed store, hash-verified

86
87/// Powers of a finite field as `[start, start*exp, start * exp^2, .. start * exp^{num-1}]`
88pub fn powers_starting_from<F: Field>(start: F, exp: &F, num: u32) -> Vec<F> {
89 let mut powers = Vec::with_capacity(num as usize);
90 if num > 0 {
91 powers.push(start);
92 for i in 1..num as usize {
93 powers.push(powers[i - 1] * exp);
94 }
95 }
96 powers
97}
98
99/// SUM of a geometric progression
100/// SUM a^i = (1 - a^n) / (1 - a) = -(1-a^n)/-(1-a)

Callers 4

check_powersFunction · 0.85
round_3Method · 0.85
verifyMethod · 0.85
newMethod · 0.85

Calls

no outgoing calls

Tested by 1

check_powersFunction · 0.68