pub struct JwtClaims {
pub len_bytes: Wire,
pub json: Vec<Wire>,
pub attributes: Vec<Attribute>,
}Expand description
Verifies that a JSON string contains specific attribute values.
This circuit validates that the JSON contains each specified attribute with exactly the expected string value.
This circuit makes some strong assumptions, in particular:
- The input is a valid JSON object. No effort is put into checking that or any other properties such as duplicate keys.
- No whitespace handling.
- The attributes of interest are strings only. Matching arrays or objects as values is not supported.
❗️ At this point, the circuit does not check that it did not get multiple attributes. For example, imagine there are two attributes “sub” and “nonce” where one is right next to the other. A prover can get away with providing the attribute “sub” but the end quote of the nonce.
Fields§
§len_bytes: WireThe actual length of the JSON string in bytes.
json: Vec<Wire>§attributes: Vec<Attribute>Implementations§
Source§impl JwtClaims
impl JwtClaims
Sourcepub fn new(
b: &CircuitBuilder,
len_bytes: Wire,
json: Vec<Wire>,
attributes: Vec<Attribute>,
) -> Self
pub fn new( b: &CircuitBuilder, len_bytes: Wire, json: Vec<Wire>, attributes: Vec<Attribute>, ) -> Self
Creates a new JWT claims verifier circuit. See the struct documentation for more details.
§Arguments
b- Circuit builderlen_bytes- Wire for actual JSON size in bytesjson- JSON input array packed as words (8 bytes per word)attributes- List of attributes to verify with their value wires
Sourcepub fn populate_len_bytes(&self, w: &mut WitnessFiller<'_>, len_bytes: usize)
pub fn populate_len_bytes(&self, w: &mut WitnessFiller<'_>, len_bytes: usize)
Populate the len_bytes wire with the actual JSON size in bytes
Sourcepub fn populate_json(&self, w: &mut WitnessFiller<'_>, json: &[u8])
pub fn populate_json(&self, w: &mut WitnessFiller<'_>, json: &[u8])
Populate the JSON array from a byte slice
§Panics
Panics if json.len() > max_len_json (the maximum size specified during construction)
Auto Trait Implementations§
impl Freeze for JwtClaims
impl RefUnwindSafe for JwtClaims
impl Send for JwtClaims
impl Sync for JwtClaims
impl Unpin for JwtClaims
impl UnsafeUnpin for JwtClaims
impl UnwindSafe for JwtClaims
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
§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>
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