leo_core/algorithms/
bhp.rs1use crate::algorithms::CoreFunction;
18use leo_ast::Type;
19
20pub struct BHP256Hash;
21
22impl CoreFunction for BHP256Hash {
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 BHP256Commit;
35
36impl CoreFunction for BHP256Commit {
37 const NUM_ARGS: usize = 2;
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 second_arg_is_allowed_type(type_: &Type) -> bool {
44 matches!(type_, Type::Scalar)
45 }
46
47 fn return_type() -> Type {
48 Type::Field
49 }
50}
51
52pub struct BHP512Hash;
53
54impl CoreFunction for BHP512Hash {
55 const NUM_ARGS: usize = 1;
56
57 fn first_arg_is_allowed_type(type_: &Type) -> bool {
58 !matches!(type_, Type::Mapping(_) | Type::Tuple(_) | Type::Err | Type::Unit)
59 }
60
61 fn return_type() -> Type {
62 Type::Field
63 }
64}
65
66pub struct BHP512Commit;
67
68impl CoreFunction for BHP512Commit {
69 const NUM_ARGS: usize = 2;
70
71 fn first_arg_is_allowed_type(type_: &Type) -> bool {
72 !matches!(type_, Type::Mapping(_) | Type::Tuple(_) | Type::Err | Type::Unit)
73 }
74
75 fn second_arg_is_allowed_type(type_: &Type) -> bool {
76 matches!(type_, Type::Scalar)
77 }
78
79 fn return_type() -> Type {
80 Type::Field
81 }
82}
83
84pub struct BHP768Hash;
85
86impl CoreFunction for BHP768Hash {
87 const NUM_ARGS: usize = 1;
88
89 fn first_arg_is_allowed_type(type_: &Type) -> bool {
90 !matches!(type_, Type::Mapping(_) | Type::Tuple(_) | Type::Err | Type::Unit)
91 }
92
93 fn return_type() -> Type {
94 Type::Field
95 }
96}
97
98pub struct BHP768Commit;
99
100impl CoreFunction for BHP768Commit {
101 const NUM_ARGS: usize = 2;
102
103 fn first_arg_is_allowed_type(type_: &Type) -> bool {
104 !matches!(type_, Type::Mapping(_) | Type::Tuple(_) | Type::Err | Type::Unit)
105 }
106
107 fn second_arg_is_allowed_type(type_: &Type) -> bool {
108 matches!(type_, Type::Scalar)
109 }
110
111 fn return_type() -> Type {
112 Type::Field
113 }
114}
115
116pub struct BHP1024Hash;
117
118impl CoreFunction for BHP1024Hash {
119 const NUM_ARGS: usize = 1;
120
121 fn first_arg_is_allowed_type(type_: &Type) -> bool {
122 !matches!(type_, Type::Mapping(_) | Type::Tuple(_) | Type::Err | Type::Unit)
123 }
124
125 fn return_type() -> Type {
126 Type::Field
127 }
128}
129
130pub struct BHP1024Commit;
131
132impl CoreFunction for BHP1024Commit {
133 const NUM_ARGS: usize = 2;
134
135 fn first_arg_is_allowed_type(type_: &Type) -> bool {
136 !matches!(type_, Type::Mapping(_) | Type::Tuple(_) | Type::Err | Type::Unit)
137 }
138
139 fn second_arg_is_allowed_type(type_: &Type) -> bool {
140 matches!(type_, Type::Scalar)
141 }
142
143 fn return_type() -> Type {
144 Type::Field
145 }
146}