@@ -100,9 +100,8 @@ std::shared_ptr<leafhash<FieldT, leaf_hash_type>> get_leafhash_internal(
100100 poseidon_params<FieldT> params = get_poseidon_parameters<FieldT>(hash_enum);
101101 /* security parameter is -1 b/c */
102102 std::shared_ptr<poseidon<FieldT>> permutation = std::make_shared<poseidon<FieldT>>(params);
103- std::shared_ptr<leafhash<FieldT, leaf_hash_type>> leafhasher = std::make_shared<algebraic_leafhash<FieldT>>(
104- permutation,
105- security_parameter - 1 );
103+ std::shared_ptr<leafhash<FieldT, leaf_hash_type>> leafhasher =
104+ std::make_shared<algebraic_leafhash<FieldT>>(permutation, security_parameter - 1 );
106105 return leafhasher;
107106 }
108107 throw std::invalid_argument (" bcs_hash_type unknown (algebraic leaf hash)" );
@@ -149,7 +148,7 @@ two_to_one_hash_function<FieldT> get_two_to_one_hash_internal(
149148 as this reference has to live after the function terminates */
150149 std::shared_ptr<algebraic_two_to_one_hash<FieldT>> hash_class =
151150 std::make_shared<algebraic_two_to_one_hash<FieldT>>(permutation, security_parameter - 1 );
152- std::function<FieldT (const FieldT&, const FieldT&, const std::size_t )> f = [permutation, hash_class](const FieldT& left, const FieldT& right, const std::size_t unused) -> FieldT
151+ std::function<FieldT (const FieldT&, const FieldT&, const std::size_t )> f = [permutation, hash_class](const FieldT& left, const FieldT& right, const std::size_t unused) -> FieldT
153152 {
154153 return hash_class->hash (left, right);
155154 };
@@ -185,25 +184,25 @@ cap_hash_function<FieldT> get_cap_hash_internal(
185184 const bcs_hash_type hash_enum,
186185 const size_t security_parameter)
187186{
188- // if (hash_enum == starkware_poseidon_type || hash_enum == high_alpha_poseidon_type)
189- // {
190- // if (security_parameter != 128)
191- // {
192- // throw std::invalid_argument("Poseidon only supported for 128 bit soundness.");
193- // }
194- // poseidon_params<FieldT> params = get_poseidon_parameters<FieldT>(hash_enum);
195- // /* security parameter is -1 b/c */
196- // std::shared_ptr<algebraic_sponge<FieldT>> permutation = std::make_shared<poseidon<FieldT>>(params);
197- // /* We explicitly place this on heap with no destructor,
198- // as this reference has to live after the function terminates */
199- // std::shared_ptr<algebraic_two_to_one_hash <FieldT>> hash_class =
200- // std::make_shared<algebraic_two_to_one_hash <FieldT>>(permutation, security_parameter - 1);
201- // std::function<FieldT(const FieldT&, const FieldT& , const std::size_t)> f = [permutation, hash_class](const FieldT& left, const FieldT& right , const std::size_t unused) -> FieldT
202- // {
203- // return hash_class->hash(left, right );
204- // };
205- // return f;
206- // }
187+ if (hash_enum == starkware_poseidon_type || hash_enum == high_alpha_poseidon_type)
188+ {
189+ if (security_parameter != 128 )
190+ {
191+ throw std::invalid_argument (" Poseidon only supported for 128 bit soundness." );
192+ }
193+ poseidon_params<FieldT> params = get_poseidon_parameters<FieldT>(hash_enum);
194+ /* security parameter is -1 b/c */
195+ std::shared_ptr<algebraic_sponge<FieldT>> permutation = std::make_shared<poseidon<FieldT>>(params);
196+ /* We explicitly place this on heap with no destructor,
197+ as this reference has to live after the function terminates */
198+ std::shared_ptr<algebraic_vector_hash <FieldT>> hash_class =
199+ std::make_shared<algebraic_vector_hash <FieldT>>(permutation, security_parameter - 1 );
200+ std::function<FieldT (const std::vector< FieldT> &leaf , const std::size_t )> f = [permutation, hash_class](const std::vector< FieldT> &leaf , const std::size_t unused) -> FieldT
201+ {
202+ return hash_class->hash (leaf );
203+ };
204+ return f;
205+ }
207206 throw std::invalid_argument (" bcs_hash_type unknown (algebraic cap hash)" );
208207}
209208
0 commit comments