use crate::algorithms::CoreFunction;
use leo_ast::{IntegerType, Type};
pub struct Pedersen64Hash;
impl CoreFunction for Pedersen64Hash {
const NUM_ARGS: usize = 1;
fn first_arg_is_allowed_type(type_: &Type) -> bool {
matches!(
type_,
Type::Boolean
| Type::Integer(IntegerType::I8)
| Type::Integer(IntegerType::I16)
| Type::Integer(IntegerType::I32)
| Type::Integer(IntegerType::I64)
| Type::Integer(IntegerType::U8)
| Type::Integer(IntegerType::U16)
| Type::Integer(IntegerType::U32)
| Type::Integer(IntegerType::U64)
| Type::String
)
}
fn return_type() -> Type {
Type::Field
}
}
pub struct Pedersen64Commit;
impl CoreFunction for Pedersen64Commit {
const NUM_ARGS: usize = 2;
fn first_arg_is_allowed_type(type_: &Type) -> bool {
matches!(
type_,
Type::Boolean
| Type::Integer(IntegerType::I8)
| Type::Integer(IntegerType::I16)
| Type::Integer(IntegerType::I32)
| Type::Integer(IntegerType::I64)
| Type::Integer(IntegerType::U8)
| Type::Integer(IntegerType::U16)
| Type::Integer(IntegerType::U32)
| Type::Integer(IntegerType::U64)
| Type::String
)
}
fn second_arg_is_allowed_type(type_: &Type) -> bool {
matches!(type_, Type::Scalar)
}
fn return_type() -> Type {
Type::Group
}
}
pub struct Pedersen128Hash;
impl CoreFunction for Pedersen128Hash {
const NUM_ARGS: usize = 1;
fn first_arg_is_allowed_type(type_: &Type) -> bool {
matches!(type_, Type::Boolean | Type::Integer(_) | Type::String)
}
fn return_type() -> Type {
Type::Field
}
}
pub struct Pedersen128Commit;
impl CoreFunction for Pedersen128Commit {
const NUM_ARGS: usize = 2;
fn first_arg_is_allowed_type(type_: &Type) -> bool {
matches!(type_, Type::Boolean | Type::Integer(_) | Type::String)
}
fn second_arg_is_allowed_type(type_: &Type) -> bool {
matches!(type_, Type::Scalar)
}
fn return_type() -> Type {
Type::Group
}
}