Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make API more safe #2

Open
olehmisar opened this issue Dec 9, 2024 · 1 comment
Open

Make API more safe #2

olehmisar opened this issue Dec 9, 2024 · 1 comment

Comments

@olehmisar
Copy link
Contributor

Users may accidentally forget to call jwt.verify(). Is there any reason not to combine .init and .verify into a single function?

Before:

let jwt = JWT::init(
    data,
    b64_offset: u32,
    pubkey_modulus_limbs,
    redc_params_limbs,
    signature_limbs,
);
jwt.verify();

After:

let jwt = JWT::verify(
    data,
    b64_offset: u32,
    pubkey_modulus_limbs,
    redc_params_limbs,
    signature_limbs,
);

Also, for partial hashing:

let jwt = JWT::verify_with_partial_hash(
    partial_data,
    partial_hash,
    full_data_length,
    b64_offset,
    pubkey_modulus_limbs,
    redc_params_limbs,
    signature_limbs,
);
@saleel
Copy link
Member

saleel commented Jan 23, 2025

This is true, but I think init api is more cleaner to return a jwt instance which can be then used to call other methods.

With v0.3.0, if the assert_claim() is called before verify(), then Noir will throw a warning saying there are values from unconstrained code that is not constrained anywhere in circuit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants