-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libraries: IVerifier: Refactor verifier into interface
- Loading branch information
Showing
7 changed files
with
95 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
import { PlonkProof, VerificationKey } from "./libraries/verifier/Types.sol"; | ||
import { ValidWalletCreateStatement, StatementSerializer } from "./libraries/darkpool/PublicInputs.sol"; | ||
import { VerificationKeys } from "./libraries/darkpool/VerificationKeys.sol"; | ||
import { IVerifier } from "./libraries/verifier/IVerifier.sol"; | ||
import { VerifierCore } from "./libraries/verifier/VerifierCore.sol"; | ||
import { BN254 } from "solidity-bn254/BN254.sol"; | ||
|
||
using StatementSerializer for ValidWalletCreateStatement; | ||
|
||
/// @title PlonK Verifier with the Jellyfish-style arithmetization | ||
/// @notice The methods on this contract are darkpool-specific | ||
contract Verifier is IVerifier { | ||
/// @notice Verify a proof of `VALID WALLET CREATE` | ||
/// @param statement The public inputs to the proof | ||
/// @param proof The proof to verify | ||
/// @return True if the proof is valid, false otherwise | ||
function verifyValidWalletCreate( | ||
ValidWalletCreateStatement memory statement, | ||
PlonkProof memory proof | ||
) | ||
external | ||
view | ||
returns (bool) | ||
{ | ||
VerificationKey memory vk = abi.decode(VerificationKeys.VALID_WALLET_CREATE_VKEY, (VerificationKey)); | ||
BN254.ScalarField[] memory publicInputs = statement.scalarSerialize(); | ||
return VerifierCore.verify(proof, publicInputs, vk); | ||
} | ||
} |
File renamed without changes.
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,19 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
import { PlonkProof } from "./Types.sol"; | ||
import { ValidWalletCreateStatement } from "../darkpool/PublicInputs.sol"; | ||
|
||
interface IVerifier { | ||
/// @notice Verify a proof of `VALID WALLET CREATE` | ||
/// @param proof The proof to verify | ||
/// @param statement The public inputs to the proof | ||
/// @return True if the proof is valid, false otherwise | ||
function verifyValidWalletCreate( | ||
ValidWalletCreateStatement memory statement, | ||
PlonkProof memory proof | ||
) | ||
external | ||
view | ||
returns (bool); | ||
} |
File renamed without changes.
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,26 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.8.0; | ||
|
||
import { PlonkProof } from "../../src/libraries/verifier/Types.sol"; | ||
import { IVerifier } from "../../src/libraries/verifier/IVerifier.sol"; | ||
import { ValidWalletCreateStatement } from "../../src/libraries/darkpool/PublicInputs.sol"; | ||
|
||
/// @title Test Verifier Implementation | ||
/// @notice This is a test implementation of the `IVerifier` interface that always returns true | ||
contract TestVerifier is IVerifier { | ||
/// @notice Verify a proof of `VALID WALLET CREATE` | ||
/// @param statement The public inputs to the proof | ||
/// @param proof The proof to verify | ||
/// @return True always, regardless of the proof | ||
function verifyValidWalletCreate( | ||
ValidWalletCreateStatement memory statement, | ||
PlonkProof memory proof | ||
) | ||
external | ||
view | ||
returns (bool) | ||
{ | ||
// Always return true for testing purposes | ||
return true; | ||
} | ||
} |