Module 0x1::sigma_protocol_representation_vec
- Struct
RepresentationVec - Function
new_representation_vec - Function
get_representations - Function
length - Function
for_each_ref - Function
map_ref - Function
scale_all - Function
scale_each
use 0x1::ristretto255;
use 0x1::sigma_protocol_representation;
Struct RepresentationVec
A vector of Representations.
Used to represent the output of the transformation function $f$ and the homomorphism $\psi$
(i.e., a vector in $\mathbb{G}^m$).
struct RepresentationVec has drop
Function 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 } }
Function 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
}
Function 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()
}
Function 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))
}
Function 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))
}
Function scale_all
Multiply all representations by $e$ (i.e., multiply each self.v[i].scalars by $e$).
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));
}
Function scale_each
For all $i$, multiply the $i$th 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])
});
}