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: WireActual length of decoded data in bytes.
Implementations§
Source§impl Base64UrlSafe
impl Base64UrlSafe
Sourcepub fn new(
builder: &CircuitBuilder,
decoded: Vec<Wire>,
encoded: Vec<Wire>,
len_bytes: Wire,
) -> Self
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 constraintsdecoded- raw byte array wiresencoded- Base64 encoded array wireslen_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
Sourcepub fn populate_len_bytes(&self, w: &mut WitnessFiller<'_>, len_bytes: usize)
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 populatelength- Actual length of decoded data in bytes
Sourcepub fn populate_decoded(&self, w: &mut WitnessFiller<'_>, data: &[u8])
pub fn populate_decoded(&self, w: &mut WitnessFiller<'_>, data: &[u8])
Sourcepub fn populate_encoded(&self, w: &mut WitnessFiller<'_>, data: &[u8])
pub fn populate_encoded(&self, w: &mut WitnessFiller<'_>, data: &[u8])
Auto Trait Implementations§
impl Freeze for Base64UrlSafe
impl RefUnwindSafe for Base64UrlSafe
impl Send for Base64UrlSafe
impl Sync for Base64UrlSafe
impl Unpin for Base64UrlSafe
impl UnsafeUnpin for Base64UrlSafe
impl UnwindSafe for Base64UrlSafe
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
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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 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>
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