pub struct G { /* private fields */ }Expand description
Represents a point in the Banderwagon group.
This group is defined over the BLS12-381 Scalar field.
Because of that, we can efficiently use it in ZK proofs using BLS.
Implementations§
Source§impl G
impl G
Sourcepub fn scalar_mul_x_squared_base(&self, scalar: &Scalar) -> Scalar
pub fn scalar_mul_x_squared_base(&self, scalar: &Scalar) -> Scalar
Out-of-circuit squared affine x-coordinate of [scalar] * self.
We expose the squared abscissa rather than the bare one because the
quotient identifies (x, y) with (-x, -y): a plain x-coordinate flips
sign between the two representatives, whereas its square is a well-defined
function of the group element (no representative to agree on, no
canonicalize needed). The native counterpart of
the in-circuit scalar_mul_x_squared.
Sourcepub fn scalar_mul_x_squared_f(&self, x: &F) -> Scalar
pub fn scalar_mul_x_squared_f(&self, x: &F) -> Scalar
Out-of-circuit squared affine x-coordinate of [x] * self for an F
exponent — the native counterpart of
scalar_mul_x_squared_base, the
square is representative-independent.
Source§impl G
impl G
Sourcepub fn scalar_mul_many_in_circuit<'ctx, const WINDOW: usize>(
bases: &[Self],
bits: &[BoolVar<'ctx, Scalar>],
) -> Vec<GVar<'ctx>>
pub fn scalar_mul_many_in_circuit<'ctx, const WINDOW: usize>( bases: &[Self], bits: &[BoolVar<'ctx, Scalar>], ) -> Vec<GVar<'ctx>>
In-circuit fixed-base scalar multiplication for several public bases sharing one scalar bit decomposition.
WINDOW controls how many bits are selected at a time. Selector
monomials are built once per window and reused across every base.
Sourcepub fn scalar_mul_x_squared<'ctx>(
&self,
ctx: Context<'ctx, Scalar>,
scalar: &Var<'ctx, Scalar>,
) -> Var<'ctx, Scalar>
pub fn scalar_mul_x_squared<'ctx>( &self, ctx: Context<'ctx, Scalar>, scalar: &Var<'ctx, Scalar>, ) -> Var<'ctx, Scalar>
In-circuit squared affine x-coordinate of [scalar] * self.
We expose the squared abscissa rather than the bare one because the
quotient identifies (x, y) with (-x, -y): a plain x-coordinate flips
sign between the two representatives, whereas its square is a well-defined
function of the group element, so the read agrees regardless of which
representative a point happens to hold. The in-circuit counterpart of
scalar_mul_x_squared_base.
Sourcepub fn scalar_mul_bits<'ctx>(
&self,
bits: &[BoolVar<'ctx, Scalar>],
) -> GVar<'ctx>
pub fn scalar_mul_bits<'ctx>( &self, bits: &[BoolVar<'ctx, Scalar>], ) -> GVar<'ctx>
In-circuit [scalar] * self where the scalar is given directly as its
little-endian bits, rather than as a Var to be decomposed.
This is the path for an F exponent (e.g. the eVRF secret): the bits
are the witness, so unlike scalar_mul there is no
recomposition or canonicity constraint — see F for why that is sound
at F::BITS width. The caller must allocate the bits once and reuse the
same slice across operations, so a single exponent is bound everywhere.
Trait Implementations§
Source§impl<'a> AddAssign<&'a G> for G
impl<'a> AddAssign<&'a G> for G
Source§fn add_assign(&mut self, rhs: &'a Self)
fn add_assign(&mut self, rhs: &'a Self)
+= operation. Read moreSource§impl CryptoGroup for G
impl CryptoGroup for G
impl Eq for G
Source§impl HashToGroup for G
impl HashToGroup for G
Source§fn hash_to_group(domain_separator: &[u8], message: &[u8]) -> Self
fn hash_to_group(domain_separator: &[u8], message: &[u8]) -> Self
Hashes (domain_separator, message) to a Banderwagon point.
Uses try-and-increment: for counter = 0, 1, 2, ... we derive a candidate
abscissa x = H(domain_separator, message || counter) and return the
first one that is a valid subgroup serialization. Because the
serialization is a bijection between group elements and valid abscissae,
and each candidate is an independent uniform field element, the result is
a uniformly random group element whose discrete log w.r.t. the generator
is unknown.
We deliberately choose this over a constant-time map (e.g. Elligator-2 on
the Montgomery model of bandersnatch). Try-and-increment is simpler — it
reuses from_x and adds no new trusted constants or rational maps — at
the cost of not being constant-time: the number of attempts (~4 on
average, since roughly 1/4 of field elements are valid abscissae) depends
on the input.
That tradeoff fits our use case. The intended caller is the Golden DKG eVRF, where the hash inputs (public keys and messages) and outputs are public and the secret scalar is only applied afterwards — so the data-dependent timing reveals nothing secret. A future caller that hashes secret material would instead need a constant-time map.
Source§fn rand_to_group(rng: impl CryptoRng) -> Self
fn rand_to_group(rng: impl CryptoRng) -> Self
Source§impl<'a> MulAssign<&'a F> for G
impl<'a> MulAssign<&'a F> for G
Source§fn mul_assign(&mut self, rhs: &'a F)
fn mul_assign(&mut self, rhs: &'a F)
*= operation. Read moreimpl Object for G
Source§impl Read for G
impl Read for G
Source§impl<'a> SubAssign<&'a G> for G
impl<'a> SubAssign<&'a G> for G
Source§fn sub_assign(&mut self, rhs: &'a Self)
fn sub_assign(&mut self, rhs: &'a Self)
-= operation. Read moreSource§impl Write for G
impl Write for G
Source§fn write_bufs(&self, buf: &mut impl BufsMut)
fn write_bufs(&self, buf: &mut impl BufsMut)
BufsMut, allowing existing Bytes chunks to be
appended via BufsMut::push instead of written inline. Must encode
to the same format as Write::write. Defaults to Write::write.Auto Trait Implementations§
impl Freeze for G
impl RefUnwindSafe for G
impl Send for G
impl Sync for G
impl Unpin for G
impl UnsafeUnpin for G
impl UnwindSafe for G
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Codec for T
impl<T> CodecFixed for T
Source§impl<T> DecodeFixed for T
impl<T> DecodeFixed for T
Source§impl<T> Encode for Twhere
T: Write + EncodeSize,
impl<T> Encode for Twhere
T: Write + EncodeSize,
Source§impl<T> EncodeFixed for T
impl<T> EncodeFixed for T
Source§impl<T> EncodeSize for Twhere
T: FixedSize,
impl<T> EncodeSize for Twhere
T: FixedSize,
Source§fn encode_size(&self) -> usize
fn encode_size(&self) -> usize
fn encode_size_slice(values: &[T]) -> usizewhere
T: Sized,
fn encode_inline_size_slice(values: &[T]) -> usizewhere
T: Sized,
Source§fn encode_inline_size(&self) -> usize
fn encode_inline_size(&self) -> usize
BufsMut::push
during Write::write_bufs. Used to size the working buffer for inline
writes. Override alongside Write::write_bufs for types where large
Bytes fields go via push; failing to do so will over-allocate.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T, Rhs, Output> GroupOps<Rhs, Output> for T
impl<T, Rhs, Output> GroupOpsOwned<Rhs, Output> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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