mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-15 15:24:52 +00:00
26 lines
1.2 KiB
Solidity
26 lines
1.2 KiB
Solidity
// SPDX-License-Identifier: AGPL-3.0-only
|
|
pragma solidity ^0.8.26;
|
|
|
|
import "../Schnorr.sol";
|
|
|
|
/// @title A thin wrapper around the library for verifying Schnorr signatures to test it with
|
|
/// @author Luke Parker <lukeparker5132@gmail.com>
|
|
/// @author Elizabeth Binks <elizabethjbinks@gmail.com>
|
|
contract TestSchnorr {
|
|
/// @notice Verifies a Schnorr signature for the specified public key
|
|
/// @dev The y-coordinate of the public key is assumed to be even
|
|
/// @dev The x-coordinate of the public key is assumed to be less than the order of secp256k1
|
|
/// @dev The challenge is calculated as `keccak256(abi.encodePacked(address(R), public_key, message))` where `R` is the commitment to the Schnorr signature's nonce
|
|
/// @param public_key The x-coordinate of the public key
|
|
/// @param message The (hash of the) message signed
|
|
/// @param c The challenge for the Schnorr signature
|
|
/// @param s The response to the challenge for the Schnorr signature
|
|
/// @return If the signature is valid
|
|
function verify(bytes32 public_key, bytes calldata message, bytes32 c, bytes32 s)
|
|
external
|
|
pure
|
|
returns (bool)
|
|
{
|
|
return Schnorr.verify(public_key, keccak256(message), c, s);
|
|
}
|
|
}
|