leo_core/algorithms/
poseidon.rs1use crate::algorithms::CoreFunction;
18use leo_ast::Type;
19
20pub struct Poseidon2Hash;
21
22impl CoreFunction for Poseidon2Hash {
23 const NUM_ARGS: usize = 1;
24
25 fn first_arg_is_allowed_type(type_: &Type) -> bool {
26 !matches!(type_, Type::Mapping(_) | Type::Tuple(_) | Type::Err | Type::Unit)
27 }
28
29 fn return_type() -> Type {
30 Type::Field
31 }
32}
33
34pub struct Poseidon4Hash;
35
36impl CoreFunction for Poseidon4Hash {
37 const NUM_ARGS: usize = 1;
38
39 fn first_arg_is_allowed_type(type_: &Type) -> bool {
40 !matches!(type_, Type::Mapping(_) | Type::Tuple(_) | Type::Err | Type::Unit)
41 }
42
43 fn return_type() -> Type {
44 Type::Field
45 }
46}
47
48pub struct Poseidon8Hash;
49
50impl CoreFunction for Poseidon8Hash {
51 const NUM_ARGS: usize = 1;
52
53 fn first_arg_is_allowed_type(type_: &Type) -> bool {
54 !matches!(type_, Type::Mapping(_) | Type::Tuple(_) | Type::Err | Type::Unit)
55 }
56
57 fn return_type() -> Type {
58 Type::Field
59 }
60}