leo icon indicating copy to clipboard operation
leo copied to clipboard

[Bug] "Proof is invalid"

Open b-chiang opened this issue 2 years ago • 2 comments

🐛 Bug Report

Creating an issue by @acoglio's request: I'm trying to run a simple program to test out circuits in Leo but running into a verification error. The proof seems to be generated without any issue, but the verification step fails.

Steps to Reproduce

Code snippet to reproduce

// main.leo
// The 'hello-world' main function.
circuit Rectangle {
    width: u32,
    height: u32,

    function area(self) -> u32 {
        return self.width * self.height;
    }
}

function main(a: u32, b: u32) -> u32 {
    let rect1 = Rectangle {
        width: a,
        height: b,
    };

    let area = rect1.area();

    console.log("Rectangle area: {} square pixels", area);
    return area;
}

// hello-world.in
// The program input for hello-world/src/main.leo
[main]
a: u32 = 1;
b: u32 = 5;

[registers]
r0: u32 = 0;

Stack trace & error message

> Executing task: /Users/bryan/.aleo-studio/binaries/leo run <

     Build Starting...
     Build Compiling main program... ("/Users/bryan/Aleo Studio/hello-world/src/main.leo")
     Build Rectangle area: 5 square pixels
     Build Number of constraints - 4294
     Build Complete
      Done Finished in 37 milliseconds 

     Setup Detected saved setup
     Setup Loading proving key...
     Setup Complete
     Setup Loading verification key...
     Setup Complete
      Done Finished in 174 milliseconds 

   Proving Starting...
   Proving Rectangle area: 5 square pixels
   Proving Saving proof... ("/Users/bryan/Aleo Studio/hello-world/outputs/hello-world.proof")
      Done Finished in 45 milliseconds 

 Verifying Starting...
 Verifying Proof is invalid
      Done Finished in 3 milliseconds 

I'm also getting another warning when I declare the circuit.

`main` function is missing

Expected Behavior

Verification should be successful.

Your Environment

  • leo 1.5.3
  • rustc 1.59.0 (9d1b2106e 2022-02-23)
  • macOS Monterey 12.0.1

b-chiang avatar Mar 03 '22 07:03 b-chiang

After further conversion on Discord, it looks like the problem may go away after doing a leo clean. I've seen this issue as well. Still, arguably it shouldn't necessary to clean.

acoglio avatar Mar 03 '22 07:03 acoglio

After further conversion on Discord, it looks like the problem may go away after doing a leo clean. I've seen this issue as well. Still, arguably it shouldn't necessary to clean.

ive seen this before as well. i brought it up when i first started here and was also told to just run leo clean between compilations. this definitely should be looked at though yeah

0rphon avatar Mar 05 '22 00:03 0rphon

Leo v1.6.2 translated program file:

program rectangle.aleo {
    struct Rectangle {
        width: u32,
        height: u32,
    }

    function area(r: Rectangle) -> u32 {
        return r.width * r.height;
    }

    transition main(a: u32, b: u32) -> u32 {
        let rect1: Rectangle = Rectangle {
            width: a,
            height: b,
        };

        let area1: u32 = area(rect1);

        return area1;
    }
}

This program should now compile and run @bryanhpchiang We also removed the requirement on a "main" function so the previous error message should not appear anymore.

I'm going to close this issue as resolved for now but feel free to reopen if you hit it again somehow.

collinc97 avatar Jan 05 '23 19:01 collinc97