Skip to main content

Base64UrlSafe

Struct Base64UrlSafe 

Source
pub struct Base64UrlSafe {
    pub decoded: Vec<Wire>,
    pub encoded: Vec<Wire>,
    pub len_bytes: Wire,
}
Expand description

Base64 encoding (URL-safe, without trailing padding characters) encoding verification.

Verifies that encoded data is a valid base64 URL-safe encoding (without trailing padding characters) of decoded data.

This encoding is defined in the JSON Web Signature (JWS) spec: https://datatracker.ietf.org/doc/html/rfc7515#section-2 (Base64url Encoding)

§Base64 URL-Safe Alphabet (RFC 4648 §5)

  • Characters 0-61: Same as standard base64 (A-Z, a-z, 0-9)
  • Character 62: ‘-’ (minus) instead of ‘+’
  • Character 63: ‘_’ (underscore) instead of ‘/’

§Circuit Behavior

The circuit performs the following validations:

  • encoded is valid base64 URL-safe encoding of decoded
  • len_decoded is the actual length of data in decoded (in bytes)
  • len_decoded ≤ max_len_decoded (compile-time maximum)

§Input Packing

  • decoded: Pack 8 bytes per 64-bit word in little-endian format
  • encoded: Pack 8 base64 characters per 64-bit word in little-endian format
  • len_decoded: Single 64-bit word containing byte count

Fields§

§decoded: Vec<Wire>

Decoded data array (packed 8 bytes per word).

§encoded: Vec<Wire>

Encoded base64 array (packed 8 chars per word).

§len_bytes: Wire

Actual length of decoded data in bytes.

Implementations§

Source§

impl Base64UrlSafe

Source

pub fn new( builder: &CircuitBuilder, decoded: Vec<Wire>, encoded: Vec<Wire>, len_bytes: Wire, ) -> Self

Creates a new Base64UrlSafe verifier.

§Arguments
  • builder - Circuit builder for constructing constraints
  • decoded - raw byte array wires
  • encoded - Base64 encoded array wires
  • len_bytes - Wire containing actual length of raw data in bytes
§Panics
  • If decoded.len() is not a multiple of 3
§Implementation Notes

The requirement that decoded.len() be a multiple of 3 ensures:

  • Word alignment: divisible by 8 for packing bytes into 64-bit words
  • Base64 group alignment: divisible by 3 for processing complete groups
  • Exact array sizing with no rounding needed
Source

pub fn populate_len_bytes(&self, w: &mut WitnessFiller<'_>, len_bytes: usize)

Populates the length wire with the actual decoded data length.

§Arguments
  • w - Witness filler to populate
  • length - Actual length of decoded data in bytes
Source

pub fn populate_decoded(&self, w: &mut WitnessFiller<'_>, data: &[u8])

Populates the decoded data array from a byte slice.

§Arguments
  • w - Witness filler to populate
  • data - Decoded bytes
§Panics

Panics if data.len() exceeds the maximum size specified during construction.

Source

pub fn populate_encoded(&self, w: &mut WitnessFiller<'_>, data: &[u8])

Populates the encoded base64 array from a byte slice.

§Arguments
  • w - Witness filler to populate
  • data - Base64-encoded bytes
§Panics

Panics if data.len() exceeds the maximum size specified during construction.

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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