-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from cartridge-gg/verifier
Feature: Endpoint for Validating Generated Proofs
- Loading branch information
Showing
9 changed files
with
143 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use std::{path::PathBuf, process::Command}; | ||
|
||
use axum::Json; | ||
|
||
pub async fn verify_proof(Json(proof): Json<String>) -> Json<bool> { | ||
// Define the path for the proof file | ||
let file = PathBuf::from("proof"); | ||
|
||
// Write the proof string to the file | ||
if let Err(e) = std::fs::write(&file, proof) { | ||
eprintln!("Failed to write proof to file: {}", e); | ||
return Json(false); | ||
} | ||
|
||
// Create the command to run the verifier | ||
let mut command = Command::new("cpu_air_verifier"); | ||
command.arg("--in_file").arg(&file); | ||
|
||
// Execute the command and capture the status | ||
let status = command.status(); | ||
|
||
// Remove the proof file | ||
if let Err(e) = std::fs::remove_file(&file) { | ||
eprintln!("Failed to remove proof file: {}", e); | ||
} | ||
|
||
// Check if the command was successful | ||
match status { | ||
Ok(exit_status) => Json(exit_status.success()), | ||
Err(e) => { | ||
eprintln!("Failed to execute verifier: {}", e); | ||
Json(false) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters