Skip to content

Commit

Permalink
Redshift proof type and LPC added. #3
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaskov committed Nov 15, 2021
1 parent 4565aa5 commit 144a5b2
Show file tree
Hide file tree
Showing 8 changed files with 293 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2017-2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
// Copyright (c) 2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2021 Nikita Kaskov <nbering@nil.foundation>
//
// MIT License
//
Expand Down Expand Up @@ -103,10 +103,10 @@ namespace nil {
>,
nil::marshalling::option::sequence_size_field_prefix<
nil::marshalling::types::integral<
TTypeBase,
TTypeBase,
std::size_t
>
>
>
>
>
>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2017-2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
// Copyright (c) 2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2021 Nikita Kaskov <nbering@nil.foundation>
//
// MIT License
//
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2021 Nikita Kaskov <nbering@nil.foundation>
//
// 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 <ratio>
#include <limits>
#include <type_traits>

#include <nil/marshalling/types/bundle.hpp>
#include <nil/marshalling/types/array_list.hpp>
#include <nil/marshalling/types/integral.hpp>
#include <nil/marshalling/status_type.hpp>
#include <nil/marshalling/options.hpp>

#include <nil/crypto3/zk/snark/commitments/list_polynomial_commitment.hpp>

namespace nil {
namespace crypto3 {
namespace marshalling {
namespace types {

template<typename TTypeBase,
typename LPCScheme,
typename = typename std::enable_if<
std::is_same<LPCScheme,
nil::crypto3::zk::snark::list_polynomial_commitment<>
>::value,
bool>::type,
typename... TOptions>
using lpc_proof =
nil::marshalling::types::bundle<
TTypeBase,
std::tuple<
// std::array<merkle_proof_type, k> z_openings;
nil::marshalling::types::array_list<
TTypeBase,
// merkle_proof_type
merkle_proof<
TTypeBase,
LPCScheme::openning_type
>,
nil::marshalling::option::fixed_size_storage<LPCScheme::k>
>,
// std::array<std::array<merkle_proof_type, m * r>, 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<LPCScheme::m * LPCScheme::r>
>,
nil::marshalling::option::fixed_size_storage<LPCScheme::lamda>
>,
// std::array<std::array<merkle_proof_type, r>, 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<LPCScheme::r>
>,
nil::marshalling::option::fixed_size_storage<LPCScheme::lamda>
>,
// std::array<std::array<commitment_type, r - 1>, 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<LPCScheme::r - 1>
>,
nil::marshalling::option::fixed_size_storage<LPCScheme::lamda>
>,
// std::array<std::array<typename FieldType::value_type>, 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<LPCScheme::...>
>,
nil::marshalling::option::fixed_size_storage<LPCScheme::lamda>
>
>
>;

} // namespace types
} // namespace marshalling
} // namespace crypto3
} // namespace nil
#endif // CRYPTO3_MARSHALLING_LPC_COMMITMENT_HPP
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2017-2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
// Copyright (c) 2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2021 Nikita Kaskov <nbering@nil.foundation>
// Copyright (c) 2021 Noam Yemini <@NoamDev at GitHub>

//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2017-2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
// Copyright (c) 2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2021 Nikita Kaskov <nbering@nil.foundation>
//
// MIT License
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2017-2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
// Copyright (c) 2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2021 Nikita Kaskov <nbering@nil.foundation>
//
// MIT License
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2017-2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2020-2021 Nikita Kaskov <nbering@nil.foundation>
// Copyright (c) 2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2021 Nikita Kaskov <nbering@nil.foundation>
//
// MIT License
//
Expand Down
143 changes: 143 additions & 0 deletions include/nil/crypto3/marshalling/zk/types/redshift/proof.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2021 Mikhail Komarov <nemo@nil.foundation>
// Copyright (c) 2021 Nikita Kaskov <nbering@nil.foundation>
//
// 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 <ratio>
#include <limits>
#include <type_traits>

#include <nil/marshalling/types/bundle.hpp>
#include <nil/marshalling/types/array_list.hpp>
#include <nil/marshalling/types/integral.hpp>
#include <nil/marshalling/status_type.hpp>
#include <nil/marshalling/options.hpp>

#include <nil/crypto3/zk/snark/systems/plonk/redshift/proof.hpp>

namespace nil {
namespace crypto3 {
namespace marshalling {
namespace types {

template<typename TTypeBase,
typename RedshiftProof,
typename = typename std::enable_if<
std::is_same<RedshiftProof,
nil::crypto3::zk::snark::redshift_proof<
typename RedshiftProof::hash_type,
RedshiftProof::arity
>
>::value,
bool>::type,
typename... TOptions>
using redshift_proof =
nil::marshalling::types::bundle<
TTypeBase,
std::tuple<
// std::vector<typename CommitmentSchemeType::commitment_type> 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<typename CommitmentSchemeType::commitment_type> 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<typename CommitmentSchemeType::proof_type> 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<typename CommitmentSchemeType::proof_type> 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

0 comments on commit 144a5b2

Please sign in to comment.