From ad41c3def0fd834641f03a2c59f6e23f5bff3f9c Mon Sep 17 00:00:00 2001 From: Vesselin Velichkov Date: Thu, 18 Aug 2022 10:01:50 +0100 Subject: [PATCH] plonk: use std::count to check if the hasher buffer is of valid length instead of explicitly checking all valid lengths. --- libsnark/zk_proof_systems/plonk/srs.tcc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libsnark/zk_proof_systems/plonk/srs.tcc b/libsnark/zk_proof_systems/plonk/srs.tcc index 5b1553929..7515f33d4 100644 --- a/libsnark/zk_proof_systems/plonk/srs.tcc +++ b/libsnark/zk_proof_systems/plonk/srs.tcc @@ -185,9 +185,7 @@ template libff::Fr transcript_hasher::get_hash() // If we are here, then the hasher buffer has invalid length so throw an // exception bool b_valid_length = - ((buffer_len == length[0]) || (buffer_len == length[1]) || - (buffer_len == length[2]) || (buffer_len == length[3]) || - (buffer_len == length[4]) || (buffer_len == length[5])); + (0 != std::count(length.begin(), length.end(), buffer_len)); if (!b_valid_length) { throw std::logic_error( "Error: invalid length of transcript hasher buffer");