Skip to content

There's no way to get an ultrahonk verification key through UltraHonkBackend #1337

Open

Description

@TomAFrench

Currently it's impossible to get the verification key for a circuit from the backend without directly using the cbinds. This requires the user to:

  1. Spin up another instance of barretenberg
  2. base64 decode and decompress their bytecode before passing it to acirWriteVkUltraHonk
  3. Know that they need to wrap the response in a RawBuffer and pass it to acirVkAsFieldsUltraHonk

What should be simple then requires copying out bb.js internals and multiple function calls.

Activity

  1. changed the title [-]There's no way to get a ultrahonk verification key through `UltraHonkBackend`[/-] [+]There's no way to get an ultrahonk verification key through `UltraHonkBackend`[/+] on Apr 11, 2025
  2. ledwards2225 commented on Apr 15, 2025

    @ledwards2225

    Does UltraHonkBackend::getVerificationKey not work for this purpose?

  3. TomAFrench commented on Apr 15, 2025

    @TomAFrench
    MemberAuthor

    This returns a Uint8Array but in order to feed this into a circuit I need to get the verification key as fields. I don't know offhand how to decompose the binary representation into fields.

  4. saleel commented on Apr 15, 2025

    @saleel
    Member

    generateProofForRecursiveAggregation() got removed in 13217. This method used to return proof and VK in fields which we were able to feed in to nargo.execute() of the recursive circuit IIRC.
    I think we need to bring it back.

  5. added
    prio
    on Jul 3, 2025
  6. ledwards2225 commented on Jul 6, 2025

    @ledwards2225

    @saleel Is this something you're able to support us on?

  7. removed
    prio
    on Aug 8, 2025
  8. johnathan79717 commented on Jan 20, 2026

    @johnathan79717
  9. TomAFrench commented on Jan 20, 2026

    @TomAFrench
    MemberAuthor

    That output looks great for feeding into a Nargo.toml!

  10. johnathan79717 commented on Jan 26, 2026

    @johnathan79717

    Now that the bb CLI can read/write JSONs. Does that solve this issue or do we need to hook that functionality into bb.js?

  11. TomAFrench commented on Jan 26, 2026

    @TomAFrench
    MemberAuthor

    Not the JSON functionality exactly but if we look at UltraHonkBackend, we can see that it's not obvious on how to generate the necessary inputs for recursive verification to be fed into another circuit:

    https://github.com/AztecProtocol/aztec-packages/blob/71ffa49969f4c11e42ca685e382c5789a4ed8b2b/barretenberg/ts/src/barretenberg/backend.ts#L157-L277

    1. We get a proof back as a byte array which then needs to be converted into fields.
    2. We get a vk back as a byte array which then needs to be converted into fields.
    3. There's no method to get the verification key hash

    We can't assume that the user will know the correct process to convert from the byte to field representations. While it's currently just chunking every 32 bytes, this has changed in the past and we can't just assume that knowledge on the part of the user anyway. We're also requiring the user to know barretenberg internals on how they should calculate the vk hash.

    We should have some helper functions convertVkToFields(vk: Uint8Array): string[], convertProofToFields(proof: Uint8Array): string[] and getVkHash(vk: Uint8Array): string to have a fool-proof method of doing these conversions.

  12. johnathan79717 commented on Feb 6, 2026

    @johnathan79717

    Does the generateRecursiveProofArtifacts not serve this purpose? It returns Promise<{ proofAsFields: string[]; vkAsFields: string[]; vkHash: string }> https://github.com/AztecProtocol/aztec-packages/blob/next/barretenberg/ts/src/barretenberg/backend.ts#L237-L243

  13. johnathan79717 commented on Apr 1, 2026

    @johnathan79717

    Talked to @TomAFrench offline today.

    1. We don't really need generateRecursiveProofArtifacts anymore.
    2. In https://github.com/noir-lang/noir/blob/127ca88a6b11b5f7288a83b92efd29013655c380/compiler/integration-tests/test/browser/recursion.test.ts#L51-L61 instead of having to instantiate another barretenbergAPI object to do the vkAsFields and poseidon2Hash, maybe it's more user friendly to be able to call main_backend.getVerificationKeyAsFields or main_backend.getHash.
    3. deflattenFields as a name is harder to understand than perhaps proofBytesAsFields or something.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions