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

Function amortized_response

compressed_sigma/src/utils.rs:37–56  ·  view source on GitHub ↗

Return the response of an amortized sigma protocol

(
    max_size: u32,
    c_powers: &[F],
    r: &[F],
    x: Vec<&[F]>,
)

Source from the content-addressed store, hash-verified

35
36/// Return the response of an amortized sigma protocol
37pub fn amortized_response<F: PrimeField>(
38 max_size: u32,
39 c_powers: &[F],
40 r: &[F],
41 x: Vec<&[F]>,
42) -> Vec<F> {
43 let s = x.len();
44 let mut z = vec![];
45 for i in 0..max_size as usize {
46 // z_i = r_i + \sum_{j in 1..s}({x_j}_i * {c_powers}_j)
47 let mut z_i = r[i];
48 for j in 0..s {
49 if s > j && x[j].len() > i {
50 z_i += c_powers[j] * x[j][i];
51 }
52 }
53 z.push(z_i);
54 }
55 z
56}
57
58/// Given `elem` and number `n`, return `n` powers of `elem` as `[elem, elem^2, elem^3, ..., elem^n]`
59pub fn get_n_powers<F: PrimeField>(elem: F, n: usize) -> Vec<F> {

Callers 2

responseMethod · 0.85
responseMethod · 0.85

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected