Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

verify function visibility should be public to enable inheritance #24

Open
Turupawn opened this issue May 11, 2023 · 2 comments
Open

verify function visibility should be public to enable inheritance #24

Turupawn opened this issue May 11, 2023 · 2 comments

Comments

@Turupawn
Copy link

Turupawn commented May 11, 2023

Hello, I'm writing educational content about Noir in spanish and @critesjosh has been guiding me on the process. I stumbled into following issue while writing a guide on how to create a dApp. I got redirected here from acvm-backend-barretenberg.

I did a PR #23 that solves this. Happy to hear your comments.

The problem

It should be common for devs to inherit from UltraVerifier while creating a dApp. This is to keep the codebase organized and readable. A normal implementation should look like the following example:

//SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

contract MyDApp is UltraVerifier {
    // Custom logic
    function proveStuff(bytes calldata _proof, bytes32[] calldata _publicInputs) public {
        verify(_proof, _publicInputs));
        // More custom logic
    }
}

However this is currently not possible due to the verify function being external. This means that this function is not visible to inherited contracts.

The solution

I think the verify visibility should be changed to public. This will enable verify being called from inherited contracts like the example above.

@Maddiaa0
Copy link
Member

Maddiaa0 commented May 11, 2023

As mentioned here: #23 (comment) we purposely have the verifier calls as external library calls to ensure that they are writing into clean memory.

The solution should be to swap the contract syntax to be a library instead, we will get this updated within noir

The resulting syntax when the verifier is a library should be something like this:

import {UltraVerifier} from "...path...";

contract MyDApp  {
    // Custom logic
    function proveStuff(bytes calldata _proof, bytes32[] calldata _publicInputs) public {
        UltraVerifier.verify(_proof, _publicInputs));
        // More custom logic
    }
}

@Turupawn
Copy link
Author

Noted 📝 , yeah a library would be nice. I'll stick with interfaces for the mean time. Thanks for the explanation!

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

No branches or pull requests

2 participants