From 144a5b288080e681427452fc6b83ed0d87d435ce Mon Sep 17 00:00:00 2001 From: nkaskov Date: Mon, 15 Nov 2021 20:26:19 +0300 Subject: [PATCH] Redshift proof type and LPC added. #3 --- .../containers/types/merkle_proof.hpp | 8 +- .../zk/types/accumulation_vector.hpp | 4 +- .../list_polynomial_commitment.hpp | 136 +++++++++++++++++ .../r1cs_gg_ppzksnark/auxiliary_input.hpp | 4 +- .../types/r1cs_gg_ppzksnark/primary_input.hpp | 4 +- .../zk/types/r1cs_gg_ppzksnark/proof.hpp | 4 +- .../r1cs_gg_ppzksnark/verification_key.hpp | 4 +- .../marshalling/zk/types/redshift/proof.hpp | 143 ++++++++++++++++++ 8 files changed, 293 insertions(+), 14 deletions(-) create mode 100644 include/nil/crypto3/marshalling/zk/types/commitments/list_polynomial_commitment.hpp create mode 100644 include/nil/crypto3/marshalling/zk/types/redshift/proof.hpp diff --git a/include/nil/crypto3/marshalling/containers/types/merkle_proof.hpp b/include/nil/crypto3/marshalling/containers/types/merkle_proof.hpp index 6c29f03..899f797 100644 --- a/include/nil/crypto3/marshalling/containers/types/merkle_proof.hpp +++ b/include/nil/crypto3/marshalling/containers/types/merkle_proof.hpp @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov +// Copyright (c) 2021 Mikhail Komarov +// Copyright (c) 2021 Nikita Kaskov // // MIT License // @@ -103,10 +103,10 @@ namespace nil { >, nil::marshalling::option::sequence_size_field_prefix< nil::marshalling::types::integral< - TTypeBase, + TTypeBase, std::size_t > - > + > > > >; diff --git a/include/nil/crypto3/marshalling/zk/types/accumulation_vector.hpp b/include/nil/crypto3/marshalling/zk/types/accumulation_vector.hpp index fc24cfb..dc01f28 100644 --- a/include/nil/crypto3/marshalling/zk/types/accumulation_vector.hpp +++ b/include/nil/crypto3/marshalling/zk/types/accumulation_vector.hpp @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov +// Copyright (c) 2021 Mikhail Komarov +// Copyright (c) 2021 Nikita Kaskov // // MIT License // diff --git a/include/nil/crypto3/marshalling/zk/types/commitments/list_polynomial_commitment.hpp b/include/nil/crypto3/marshalling/zk/types/commitments/list_polynomial_commitment.hpp new file mode 100644 index 0000000..b37750c --- /dev/null +++ b/include/nil/crypto3/marshalling/zk/types/commitments/list_polynomial_commitment.hpp @@ -0,0 +1,136 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2021 Mikhail Komarov +// Copyright (c) 2021 Nikita Kaskov +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + +#ifndef CRYPTO3_MARSHALLING_LPC_COMMITMENT_HPP +#define CRYPTO3_MARSHALLING_LPC_COMMITMENT_HPP + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +namespace nil { + namespace crypto3 { + namespace marshalling { + namespace types { + + template + >::value, + bool>::type, + typename... TOptions> + using lpc_proof = + nil::marshalling::types::bundle< + TTypeBase, + std::tuple< + // std::array z_openings; + nil::marshalling::types::array_list< + TTypeBase, + // merkle_proof_type + merkle_proof< + TTypeBase, + LPCScheme::openning_type + >, + nil::marshalling::option::fixed_size_storage + >, + // std::array, lamda> alpha_openings + nil::marshalling::types::array_list< + TTypeBase, + // layer path + nil::marshalling::types::array_list< + TTypeBase, + // merkle_proof_type + merkle_proof< + TTypeBase, + LPCScheme::openning_type + >, + nil::marshalling::option::fixed_size_storage + >, + nil::marshalling::option::fixed_size_storage + >, + // std::array, lamda> f_y_openings + nil::marshalling::types::array_list< + TTypeBase, + // layer path + nil::marshalling::types::array_list< + TTypeBase, + // merkle_proof_type + merkle_proof< + TTypeBase, + LPCScheme::openning_type + >, + nil::marshalling::option::fixed_size_storage + >, + nil::marshalling::option::fixed_size_storage + >, + // std::array, lamda> f_commitments + nil::marshalling::types::array_list< + TTypeBase, + // layer path + nil::marshalling::types::array_list< + TTypeBase, + // merkle_proof_type + merkle_proof< + TTypeBase, + LPCScheme::openning_type + >, + nil::marshalling::option::fixed_size_storage + >, + nil::marshalling::option::fixed_size_storage + >, + // std::array, lambda> + // f_ip1_coefficients + nil::marshalling::types::array_list< + TTypeBase, + // layer path + nil::marshalling::types::array_list< + TTypeBase, + // merkle_proof_type + merkle_proof< + TTypeBase, + LPCScheme::openning_type + >, + nil::marshalling::option::fixed_size_storage + >, + nil::marshalling::option::fixed_size_storage + > + > + >; + + } // namespace types + } // namespace marshalling + } // namespace crypto3 +} // namespace nil +#endif // CRYPTO3_MARSHALLING_LPC_COMMITMENT_HPP diff --git a/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/auxiliary_input.hpp b/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/auxiliary_input.hpp index cc3013e..c6d97cc 100644 --- a/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/auxiliary_input.hpp +++ b/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/auxiliary_input.hpp @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov +// Copyright (c) 2021 Mikhail Komarov +// Copyright (c) 2021 Nikita Kaskov // Copyright (c) 2021 Noam Yemini <@NoamDev at GitHub> // diff --git a/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/primary_input.hpp b/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/primary_input.hpp index 2f29192..82c5526 100644 --- a/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/primary_input.hpp +++ b/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/primary_input.hpp @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov +// Copyright (c) 2021 Mikhail Komarov +// Copyright (c) 2021 Nikita Kaskov // // MIT License // diff --git a/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/proof.hpp b/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/proof.hpp index 72569d0..76aaeef 100644 --- a/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/proof.hpp +++ b/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/proof.hpp @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov +// Copyright (c) 2021 Mikhail Komarov +// Copyright (c) 2021 Nikita Kaskov // // MIT License // diff --git a/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/verification_key.hpp b/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/verification_key.hpp index c701e53..797b6fa 100644 --- a/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/verification_key.hpp +++ b/include/nil/crypto3/marshalling/zk/types/r1cs_gg_ppzksnark/verification_key.hpp @@ -1,6 +1,6 @@ //---------------------------------------------------------------------------// -// Copyright (c) 2017-2021 Mikhail Komarov -// Copyright (c) 2020-2021 Nikita Kaskov +// Copyright (c) 2021 Mikhail Komarov +// Copyright (c) 2021 Nikita Kaskov // // MIT License // diff --git a/include/nil/crypto3/marshalling/zk/types/redshift/proof.hpp b/include/nil/crypto3/marshalling/zk/types/redshift/proof.hpp new file mode 100644 index 0000000..122a9d2 --- /dev/null +++ b/include/nil/crypto3/marshalling/zk/types/redshift/proof.hpp @@ -0,0 +1,143 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2021 Mikhail Komarov +// Copyright (c) 2021 Nikita Kaskov +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + +#ifndef CRYPTO3_MARSHALLING_REDSHIFT_PROOF_HPP +#define CRYPTO3_MARSHALLING_REDSHIFT_PROOF_HPP + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +namespace nil { + namespace crypto3 { + namespace marshalling { + namespace types { + + template + >::value, + bool>::type, + typename... TOptions> + using redshift_proof = + nil::marshalling::types::bundle< + TTypeBase, + std::tuple< + // std::vector f_commitments + nil::marshalling::types::array_list< + TTypeBase, + merkle_proof< + TTypeBase, + typename RedshiftProof::lpc::openning_type + >, + nil::marshalling::option::sequence_size_field_prefix< + nil::marshalling::types::integral< + TTypeBase, + std::size_t + > + > + >, + // typename CommitmentSchemeType::commitment_type P_commitment + merkle_proof< + TTypeBase, + typename RedshiftProof::lpc::openning_type + >, + // typename CommitmentSchemeType::commitment_type Q_commitment + merkle_proof< + TTypeBase, + typename RedshiftProof::lpc::openning_type + >, + // std::vector T_commitments + nil::marshalling::types::array_list< + TTypeBase, + merkle_proof< + TTypeBase, + typename RedshiftProof::lpc::openning_type + >, + nil::marshalling::option::sequence_size_field_prefix< + nil::marshalling::types::integral< + TTypeBase, + std::size_t + > + > + >, + // std::vector f_lpc_proofs + nil::marshalling::types::array_list< + TTypeBase, + lpc_proof< + TTypeBase, + typename RedshiftProof::lpc + >, + nil::marshalling::option::sequence_size_field_prefix< + nil::marshalling::types::integral< + TTypeBase, + std::size_t + > + > + >, + // typename CommitmentSchemeType::proof_type P_lpc_proof + lpc_proof< + TTypeBase, + typename RedshiftProof::lpc + >, + // typename CommitmentSchemeType::proof_type Q_lpc_proof + lpc_proof< + TTypeBase, + typename RedshiftProof::lpc + >, + // std::vector T_lpc_proofs + nil::marshalling::types::array_list< + TTypeBase, + lpc_proof< + TTypeBase, + typename RedshiftProof::lpc + >, + nil::marshalling::option::sequence_size_field_prefix< + nil::marshalling::types::integral< + TTypeBase, + std::size_t + > + > + > + > + >; + } // namespace types + } // namespace marshalling + } // namespace crypto3 +} // namespace nil +#endif // CRYPTO3_MARSHALLING_REDSHIFT_PROOF_HPP