pub struct Ring<F: PrimeField, KzgCurve: Pairing<ScalarField = F>, VrfCurveConfig: TECurveConfig<BaseField = F>> {
pub cx: KzgCurve::G1Affine,
pub cy: KzgCurve::G1Affine,
pub selector: KzgCurve::G1Affine,
pub max_keys: usize,
pub curr_keys: usize,
pub padding: Affine<VrfCurveConfig>,
}Expand description
Commitment to a list of VRF public keys as is used as a public input to the ring proof SNARK verifier.
The VRF keys are (inner) curve points that we represent in the affine Twisted Edwards coordinates.
We commit to the coordinate vectors independently using KZG on the outer curve. To make the commitment
updatable we use SRS in the Lagrangian form: L1, ..., Ln, where Li = L_i(t)G.
The commitment to a vector a1, ..., an is then a1L1 + ... + anLn.
We pad the list of keys with a padding point with unknown dlog up to a certain size.
Additionally, to make the commitment compatible with the snark,
we append the power-of-2 powers of the VRF blinding Pedersen base
H, 2H, 4H, ..., 2^(s-1)H, where s is the bitness of the VRF curve scalar field.
The last IDLE_ROWS = 4 elements are set to (0, 0).
Thus, the vector of points we commit to coordinatewise is
pk1, ..., pkn, padding, ..., padding, H, 2H, ..., 2^(s-1)H, 0, 0, 0, 0
Fields§
§cx: KzgCurve::G1AffineKZG commitment to the x coordinates of the described vector.
cy: KzgCurve::G1AffineKZG commitment to the y coordinates of the described vector.
selector: KzgCurve::G1AffineKZG commitment to a bitvector highlighting the part of the vector corresponding to the public keys.
max_keys: usizeMaximal number of keys the commitment can “store”. For domain of size N it is N - (s + IDLE_ROWS).
curr_keys: usizeNumber of keys “stored” in this commitment.
padding: Affine<VrfCurveConfig>Implementations§
Source§impl<F: PrimeField, KzgCurve: Pairing<ScalarField = F>, VrfCurveConfig: TECurveConfig<BaseField = F>> Ring<F, KzgCurve, VrfCurveConfig>
impl<F: PrimeField, KzgCurve: Pairing<ScalarField = F>, VrfCurveConfig: TECurveConfig<BaseField = F>> Ring<F, KzgCurve, VrfCurveConfig>
Sourcepub fn empty(
piop_params: &PiopParams<F, VrfCurveConfig>,
srs: impl Fn(Range<usize>) -> Result<Vec<KzgCurve::G1Affine>, ()>,
g: KzgCurve::G1,
) -> Self
pub fn empty( piop_params: &PiopParams<F, VrfCurveConfig>, srs: impl Fn(Range<usize>) -> Result<Vec<KzgCurve::G1Affine>, ()>, g: KzgCurve::G1, ) -> Self
Builds the commitment to the vector
padding, ..., padding, H, 2H, ..., 2^(s-1)H, 0, 0, 0, 0.
We compute it as a sum of commitments of 2 vectors:
padding, ..., padding, and
0, ..., 0, (H - padding), (2H - padding), ..., (2^(s-1)H - padding), -padding, -padding, -padding, -padding.
The first one is padding * G, the second requires an (IDLE_ROWS + s)-msm to compute.
piop_params: SNARK parameterssrs: Should returnsrs[range]forrange = (piop_params.keyset_part_size..domain_size)g: Generator used in the SRS
Sourcepub fn append(
&mut self,
keys: &[Affine<VrfCurveConfig>],
srs: impl Fn(Range<usize>) -> Result<Vec<KzgCurve::G1Affine>, ()>,
)
pub fn append( &mut self, keys: &[Affine<VrfCurveConfig>], srs: impl Fn(Range<usize>) -> Result<Vec<KzgCurve::G1Affine>, ()>, )
Appends a set key sequence to the ring.
keys: Keys to append.srs: Should returnsrs[range]forrange = (self.curr_keys..self.curr_keys + keys.len())
Sourcepub fn with_keys(
piop_params: &PiopParams<F, VrfCurveConfig>,
keys: &[Affine<VrfCurveConfig>],
srs: &RingBuilderKey<F, KzgCurve>,
) -> Self
pub fn with_keys( piop_params: &PiopParams<F, VrfCurveConfig>, keys: &[Affine<VrfCurveConfig>], srs: &RingBuilderKey<F, KzgCurve>, ) -> Self
Builds the ring from the keys provided with 2 MSMs of size keys.len() + scalar_bitlen + 5.
In some cases it may be beneficial to cash the empty ring, as updating it costs 2 MSMs of size keys.len().
piop_params: SNARK parameters.srs: full-size Lagrangian SRS.
pub fn slots_left(&self) -> usize
pub const fn empty_unchecked( domain_size: usize, cx: KzgCurve::G1Affine, cy: KzgCurve::G1Affine, selector: KzgCurve::G1Affine, padding: Affine<VrfCurveConfig>, ) -> Self
Trait Implementations§
Source§impl<F: PrimeField, KzgCurve: Pairing<ScalarField = F>, VrfCurveConfig: TECurveConfig<BaseField = F>> CanonicalDeserialize for Ring<F, KzgCurve, VrfCurveConfig>
impl<F: PrimeField, KzgCurve: Pairing<ScalarField = F>, VrfCurveConfig: TECurveConfig<BaseField = F>> CanonicalDeserialize for Ring<F, KzgCurve, VrfCurveConfig>
Source§fn deserialize_with_mode<R: Read>(
reader: R,
compress: Compress,
validate: Validate,
) -> Result<Self, SerializationError>
fn deserialize_with_mode<R: Read>( reader: R, compress: Compress, validate: Validate, ) -> Result<Self, SerializationError>
fn deserialize_compressed<R>(reader: R) -> Result<Self, SerializationError>where
R: Read,
fn deserialize_compressed_unchecked<R>(
reader: R,
) -> Result<Self, SerializationError>where
R: Read,
fn deserialize_uncompressed<R>(reader: R) -> Result<Self, SerializationError>where
R: Read,
fn deserialize_uncompressed_unchecked<R>(
reader: R,
) -> Result<Self, SerializationError>where
R: Read,
Source§impl<F: PrimeField, KzgCurve: Pairing<ScalarField = F>, VrfCurveConfig: TECurveConfig<BaseField = F>> CanonicalSerialize for Ring<F, KzgCurve, VrfCurveConfig>
impl<F: PrimeField, KzgCurve: Pairing<ScalarField = F>, VrfCurveConfig: TECurveConfig<BaseField = F>> CanonicalSerialize for Ring<F, KzgCurve, VrfCurveConfig>
Source§fn serialize_with_mode<W: Write>(
&self,
writer: W,
compress: Compress,
) -> Result<(), SerializationError>
fn serialize_with_mode<W: Write>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
fn serialized_size(&self, compress: Compress) -> usize
fn serialize_compressed<W>(&self, writer: W) -> Result<(), SerializationError>where
W: Write,
fn compressed_size(&self) -> usize
fn serialize_uncompressed<W>(&self, writer: W) -> Result<(), SerializationError>where
W: Write,
fn uncompressed_size(&self) -> usize
Source§impl<F: Clone + PrimeField, KzgCurve: Clone + Pairing<ScalarField = F>, VrfCurveConfig: Clone + TECurveConfig<BaseField = F>> Clone for Ring<F, KzgCurve, VrfCurveConfig>
impl<F: Clone + PrimeField, KzgCurve: Clone + Pairing<ScalarField = F>, VrfCurveConfig: Clone + TECurveConfig<BaseField = F>> Clone for Ring<F, KzgCurve, VrfCurveConfig>
Source§impl<F: PrimeField, KzgCurve: Pairing<ScalarField = F>, VrfCurveConfig: TECurveConfig<BaseField = F>> Debug for Ring<F, KzgCurve, VrfCurveConfig>
impl<F: PrimeField, KzgCurve: Pairing<ScalarField = F>, VrfCurveConfig: TECurveConfig<BaseField = F>> Debug for Ring<F, KzgCurve, VrfCurveConfig>
Source§impl<F: PartialEq + PrimeField, KzgCurve: PartialEq + Pairing<ScalarField = F>, VrfCurveConfig: PartialEq + TECurveConfig<BaseField = F>> PartialEq for Ring<F, KzgCurve, VrfCurveConfig>
impl<F: PartialEq + PrimeField, KzgCurve: PartialEq + Pairing<ScalarField = F>, VrfCurveConfig: PartialEq + TECurveConfig<BaseField = F>> PartialEq for Ring<F, KzgCurve, VrfCurveConfig>
Source§impl<F: PrimeField, KzgCurve: Pairing<ScalarField = F>, VrfCurveConfig: TECurveConfig<BaseField = F>> Valid for Ring<F, KzgCurve, VrfCurveConfig>
impl<F: PrimeField, KzgCurve: Pairing<ScalarField = F>, VrfCurveConfig: TECurveConfig<BaseField = F>> Valid for Ring<F, KzgCurve, VrfCurveConfig>
fn check(&self) -> Result<(), SerializationError>
fn batch_check<'a>(
batch: impl Iterator<Item = &'a Self> + Send,
) -> Result<(), SerializationError>where
Self: 'a,
impl<F: Eq + PrimeField, KzgCurve: Eq + Pairing<ScalarField = F>, VrfCurveConfig: Eq + TECurveConfig<BaseField = F>> Eq for Ring<F, KzgCurve, VrfCurveConfig>
impl<F: PrimeField, KzgCurve: Pairing<ScalarField = F>, VrfCurveConfig: TECurveConfig<BaseField = F>> StructuralPartialEq for Ring<F, KzgCurve, VrfCurveConfig>
Auto Trait Implementations§
impl<F, KzgCurve, VrfCurveConfig> Freeze for Ring<F, KzgCurve, VrfCurveConfig>
impl<F, KzgCurve, VrfCurveConfig> RefUnwindSafe for Ring<F, KzgCurve, VrfCurveConfig>
impl<F, KzgCurve, VrfCurveConfig> Send for Ring<F, KzgCurve, VrfCurveConfig>
impl<F, KzgCurve, VrfCurveConfig> Sync for Ring<F, KzgCurve, VrfCurveConfig>
impl<F, KzgCurve, VrfCurveConfig> Unpin for Ring<F, KzgCurve, VrfCurveConfig>
impl<F, KzgCurve, VrfCurveConfig> UnwindSafe for Ring<F, KzgCurve, VrfCurveConfig>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CanonicalSerializeHashExt for Twhere
T: CanonicalSerialize,
impl<T> CanonicalSerializeHashExt for Twhere
T: CanonicalSerialize,
fn hash<H>(&self) -> GenericArray<u8, <H as OutputSizeUser>::OutputSize>where
H: Digest,
fn hash_uncompressed<H>(
&self,
) -> GenericArray<u8, <H as OutputSizeUser>::OutputSize>where
H: Digest,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more