Skip to main content

G

Struct G 

Source
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

Source

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.

Source

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

Source

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.

Source

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.

Source

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> Add<&'a G> for G

Source§

type Output = G

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'a Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> AddAssign<&'a G> for G

Source§

fn add_assign(&mut self, rhs: &'a Self)

Performs the += operation. Read more
Source§

impl Additive for G

Source§

fn zero() -> Self

The neutral element for addition.
Source§

fn double(&mut self)

Add an element to itself. Read more
Source§

fn scale(&self, bits_le: &[u64]) -> Self

Scale this number by a positive integer. Read more
Source§

impl Clone for G

Source§

fn clone(&self) -> G

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl CryptoGroup for G

Source§

fn generator() -> Self

Returns the prime-order Bandersnatch generator in extended coordinates.

Source§

type Scalar = F

Source§

impl Debug for G

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for G

Source§

impl FixedSize for G

Source§

const SIZE: usize = Scalar::SIZE

The size of the encoded value (in bytes).
Source§

impl HashToGroup for G

Source§

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

Convert randomness to a group element, without learning its discrete logarithm. Read more
Source§

impl<'a> Mul<&'a F> for G

Source§

type Output = G

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &'a F) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> MulAssign<&'a F> for G

Source§

fn mul_assign(&mut self, rhs: &'a F)

Performs the *= operation. Read more
Source§

impl Neg for G

Source§

type Output = G

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Object for G

Source§

impl PartialEq for G

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Read for G

Source§

type Cfg = ()

The Cfg type parameter allows passing configuration during the read process. This is crucial for safely decoding untrusted data, for example, by providing size limits for collections or strings. Read more
Source§

fn read_cfg(buf: &mut impl Buf, _: &()) -> Result<Self, CodecError>

Reads a value from the buffer using the provided configuration cfg. Read more
Source§

impl Space<F> for G

Source§

fn msm(points: &[Self], scalars: &[F], _strategy: &impl Strategy) -> Self

Calculate sum_i points[i] * scalars[i]. Read more
Source§

impl<'a> Sub<&'a G> for G

Source§

type Output = G

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'a Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> SubAssign<&'a G> for G

Source§

fn sub_assign(&mut self, rhs: &'a Self)

Performs the -= operation. Read more
Source§

impl Write for G

Source§

fn write(&self, buf: &mut impl BufMut)

Writes the binary representation of self to the provided buffer buf. Read more
Source§

fn write_bufs(&self, buf: &mut impl BufsMut)

Writes to a 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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Codec for T
where T: Encode + Decode,

Source§

impl<T> CodecFixed for T
where T: Codec + FixedSize,

Source§

impl<T> CodecFixedShared for T
where T: CodecFixed<Cfg = ()> + Send + Sync,

Source§

impl<T> CodecShared for T
where T: Codec + Send + Sync,

Source§

impl<T> Decode for T
where T: Read,

Source§

fn decode_cfg(buf: impl Buf, cfg: &Self::Cfg) -> Result<Self, Error>

Decodes a value from buf using cfg, ensuring the entire buffer is consumed. Read more
Source§

impl<X, T> DecodeExt<X> for T
where X: IsUnit, T: Decode<Cfg = X>,

Source§

fn decode(buf: impl Buf) -> Result<Self, Error>

Decodes a value using the default () config.
Source§

impl<T> DecodeFixed for T
where T: Read<Cfg = ()> + FixedSize,

Source§

fn decode_fixed<const N: usize>(bytes: [u8; N]) -> Result<Self, Error>

Decodes a value from a fixed-size byte array [u8; N], ensuring all bytes are consumed. Read more
Source§

impl<T> Encode for T
where T: Write + EncodeSize,

Source§

fn encode(&self) -> Bytes

Encodes self into a new Bytes buffer. Read more
Source§

fn encode_mut(&self) -> BytesMut

Encodes self into a new BytesMut buffer. Read more
Source§

impl<T> EncodeFixed for T
where T: Write + FixedSize,

Source§

fn encode_fixed<const N: usize>(&self) -> [u8; N]

Encodes self into a fixed-size byte array [u8; N]. Read more
Source§

impl<T> EncodeShared for T
where T: Encode + Send + Sync,

Source§

impl<T> EncodeSize for T
where T: FixedSize,

Source§

fn encode_size(&self) -> usize

Returns the encoded size of this value (in bytes).
Source§

fn encode_size_slice(values: &[T]) -> usize
where T: Sized,

Source§

fn encode_inline_size_slice(values: &[T]) -> usize
where T: Sized,

Source§

fn encode_inline_size(&self) -> usize

Returns the encoded size excluding bytes passed to 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
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, Rhs, Output> GroupOps<Rhs, Output> for T
where T: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>,

Source§

impl<T, Rhs, Output> GroupOpsOwned<Rhs, Output> for T
where T: for<'r> GroupOps<&'r Rhs, Output>,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ReadExt for T
where T: Read<Cfg = ()>,

Source§

fn read(buf: &mut impl Buf) -> Result<Self, Error>

Reads a value using the default () config.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T
where T: Mul<Rhs, Output = Output> + MulAssign<Rhs>,

Source§

impl<T, Rhs, Output> ScalarMulOwned<Rhs, Output> for T
where T: for<'r> ScalarMul<&'r Rhs, Output>,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more