跳转到内容

sigma_protocol_representation_vec - [devnet]

此内容尚不支持你的语言。

use 0x1::ristretto255;
use 0x1::sigma_protocol_representation;

Structs

RepresentationVec

A vector of Representations. Used to represent the output of the transformation function ff and the homomorphism ψ\psi (i.e., a vector in Gm\mathbb{G}^m).

struct RepresentationVec has drop
Fields
v: vector<sigma_protocol_representation::Representation>

Functions

new_representation_vec

public(friend) fun new_representation_vec(v: vector<sigma_protocol_representation::Representation>): sigma_protocol_representation_vec::RepresentationVec
Implementation
public(friend) fun new_representation_vec(v: vector<Representation>): RepresentationVec { RepresentationVec { v } }

get_representations

Returns all the underlying Representation’s stored in this vector (Public due to forced inlining for functions that take lambda arguments.)

public(friend) fun get_representations(self: &sigma_protocol_representation_vec::RepresentationVec): &vector<sigma_protocol_representation::Representation>
Implementation
public(friend) fun get_representations(self: &RepresentationVec): &vector<Representation> {
&self.v
}

length

Returns the number of representations in the vector.

public(friend) fun length(self: &sigma_protocol_representation_vec::RepresentationVec): u64
Implementation
public(friend) fun length(self: &RepresentationVec): u64 {
self.v.length()
}

for_each_ref

Iterates through every representation in the vector. (Forced inlining for functions that take lambda arguments.)

public(friend) fun for_each_ref(self: &sigma_protocol_representation_vec::RepresentationVec, lambda: |&sigma_protocol_representation::Representation|)
Implementation
public(friend) inline fun for_each_ref(self: &RepresentationVec, lambda: |&Representation|) {
self.get_representations().for_each_ref(|repr| lambda(repr))
}

map_ref

Maps each representation in the vector to a value of type T.

public(friend) fun map_ref<T>(self: &sigma_protocol_representation_vec::RepresentationVec, lambda: |&sigma_protocol_representation::Representation|T): vector<T>
Implementation
public(friend) inline fun map_ref<T>(self: &RepresentationVec, lambda: |&Representation| T): vector<T> {
self.get_representations().map_ref(|repr| lambda(repr))
}

scale_all

Multiply all representations by ee (i.e., multiply each self.v[i].scalars by ee).

public(friend) fun scale_all(self: &mut sigma_protocol_representation_vec::RepresentationVec, e: &ristretto255::Scalar)
Implementation
public(friend) fun scale_all(self: &mut RepresentationVec, e: &Scalar) {
self.v.for_each_mut(|repr| repr.scale(e));
}

scale_each

For all ii, multiply the iith representation by b[i] (i.e., multiply self.v[i].scalars by b[i])

public(friend) fun scale_each(self: &mut sigma_protocol_representation_vec::RepresentationVec, b: &vector<ristretto255::Scalar>)
Implementation
public(friend) fun scale_each(self: &mut RepresentationVec, b: &vector<Scalar>) {
self.v.enumerate_mut(|i, repr| {
repr.scale(&b[i])
});
}