Skip to content

Commit

Permalink
Merge pull request #72 from NilFoundation/71-fix-marshalling-of-step-…
Browse files Browse the repository at this point in the history
…list

Fix marshalling of step list.
  • Loading branch information
martun authored Dec 27, 2023
2 parents 3a8efcf + 4a58ae3 commit de11310
Show file tree
Hide file tree
Showing 11 changed files with 192 additions and 176 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/publish-results.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Needed to publish test results in fork
name: Testing Callback

on:
workflow_run:
workflows: ["PR Testing"]
types:
- completed

jobs:
call-reusable-workflow:
name: Call Reusable Testing Callback Workflow
uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-publish-result.yml@v1.2.0
42 changes: 42 additions & 0 deletions .github/workflows/pull-request-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Reusable PR testing for mac and linux

on:
workflow_call:
inputs:
targets:
type: string
description: "Make and CTest targets. If not specified, everything is tested"
required: false

jobs:
handle-syncwith:
name: Call Reusable SyncWith Handler
uses: NilFoundation/ci-cd/.github/workflows/reusable-handle-syncwith.yml@v1.2.0
with:
ci-cd-ref: 'v1.2.0'
secrets: inherit

matrix-test-linux:
name: Linux Reusable Crypto3 Testing
needs:
- handle-syncwith
uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-testing-linux.yml@v1.2.0

secrets: inherit
with:
submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }}

targets: ${{ inputs.targets }}

matrix-test-mac:
name: Mac Reusable Crypto3 Testing
needs:
- handle-syncwith
uses: NilFoundation/ci-cd/.github/workflows/reusable-crypto3-testing-mac.yml@v1.2.0

secrets: inherit
with:
submodules-refs: ${{ needs.handle-syncwith.outputs.prs-refs }}

targets: ${{ inputs.targets }}

31 changes: 31 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: PR Testing

on:
pull_request:
types:
- opened
- synchronize

jobs:
run-pull-request-actions:
name: Reusable Crypto3 Testing
uses: ./.github/workflows/pull-request-action.yml

secrets: inherit
with:
targets: |
marshalling_fri_commitment_test
marshalling_lpc_commitment_test
marshalling_placeholder_common_data_test
marshalling_placeholder_proof_test
marshalling_sparse_vector_test
marshalling_accumulation_vector_test
marshalling_plonk_constraint_system_test
marshalling_plonk_assignment_table_test
marshalling_plonk_gates_test
marshalling_r1cs_gg_ppzksnark_primary_input_test
marshalling_r1cs_gg_ppzksnark_proof_test
marshalling_r1cs_gg_ppzksnark_verification_key_test
# Test should be fixed
# marshalling_merkle_proof_test
130 changes: 0 additions & 130 deletions .github/workflows/run_tests.yml

This file was deleted.

30 changes: 30 additions & 0 deletions .github/workflows/set_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Set version

on:
# Triggers the workflow on push to master branch
push:
branches: [ master ]

jobs:
set_version:
name: Set and tag version
runs-on: [ubuntu-latest]
env:
VERSION_FILE_NAME: VERSION
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set version
id: set_version
run: |
version=$(cat ${{ env.VERSION_FILE_NAME }} | tr -d '\r').$GITHUB_RUN_NUMBER
echo "VERSION=$version" >> $GITHUB_ENV
- name: Tag new version
run: git tag v${{ env.VERSION }}

- name: Push tags
uses: ad-m/github-push-action@master
with:
tags: true
16 changes: 4 additions & 12 deletions include/nil/crypto3/marshalling/zk/types/commitments/fri.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ namespace nil {

template <typename Endianness, typename FRI>
typename fri_proof<nil::marshalling::field_type<Endianness>, FRI>::type
fill_fri_proof(const typename FRI::proof_type &proof, const batch_info_type &batch_info){
fill_fri_proof(const typename FRI::proof_type &proof, const batch_info_type &batch_info, const typename FRI::params_type& params) {
using TTypeBase = nil::marshalling::field_type<Endianness>;

// merkle roots
Expand All @@ -266,8 +266,6 @@ namespace nil {
filled_fri_roots.value().push_back(fill_merkle_node_value<typename FRI::commitment_type, Endianness>(proof.fri_roots[i]));
}

std::vector<std::uint8_t> step_list(proof.query_proofs[0].round_proofs.size());

// initial_polynomials values
std::vector<typename FRI::field_type::value_type> initial_val;
for( std::size_t i = 0; i < FRI::lambda; i++ ){
Expand All @@ -276,15 +274,12 @@ namespace nil {
auto &initial_proof = it.second;
BOOST_ASSERT(initial_proof.values.size() == batch_info.at(it.first));
for( std::size_t j = 0; j < initial_proof.values.size(); j++ ){
if( step_list[0] == 0) {
step_list[0] = log2(initial_proof.values[j].size()) + 1;
}
for(std::size_t k = 0; k < initial_proof.values[j].size(); k++ ){
for( std::size_t l = 0; l < FRI::m; l++ ){
initial_val.push_back(initial_proof.values[j][k][l]);
}
}
BOOST_ASSERT((1 << (step_list[0] - 1)) == initial_proof.values[j].size());
BOOST_ASSERT((1 << (params.step_list[0] - 1)) == initial_proof.values[j].size());
}
}
}
Expand All @@ -300,9 +295,6 @@ namespace nil {
auto &query_proof = proof.query_proofs[i];
for( std::size_t j = 0; j < query_proof.round_proofs.size(); j++ ){
auto &round_proof = query_proof.round_proofs[j];
if(log2(round_proof.y.size()) + 1 != 0 && j != query_proof.round_proofs.size()){
step_list[j+1] = log2(round_proof.y.size()) + 1;
}
for( std::size_t k = 0; k < round_proof.y.size(); k++){
round_val.push_back(round_proof.y[k][0]);
round_val.push_back(round_proof.y[k][1]);
Expand All @@ -321,8 +313,8 @@ namespace nil {
nil::marshalling::types::integral<TTypeBase, std::uint8_t>,
nil::marshalling::option::sequence_size_field_prefix<nil::marshalling::types::integral<TTypeBase, std::size_t>>
> filled_step_list;
for( std::size_t i = 0; i < step_list.size(); i++ ){
filled_step_list.value().push_back(nil::marshalling::types::integral<TTypeBase, std::uint8_t>(step_list[i]));
for (const auto& step : params.step_list) {
filled_step_list.value().push_back(nil::marshalling::types::integral<TTypeBase, std::uint8_t>(step));
}

// initial merkle proofs
Expand Down
4 changes: 2 additions & 2 deletions include/nil/crypto3/marshalling/zk/types/commitments/lpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ namespace nil {

template<typename Endianness, typename LPC>
typename eval_proof<nil::marshalling::field_type<Endianness>, LPC>::type
fill_eval_proof( const typename LPC::proof_type &proof ){
fill_eval_proof( const typename LPC::proof_type &proof, const typename LPC::fri_type::params_type& fri_params){
using TTypeBase = nil::marshalling::field_type<Endianness>;

nil::crypto3::marshalling::types::batch_info_type batch_info = proof.z.get_batch_info();

auto filled_z = fill_eval_storage<Endianness, typename LPC::eval_storage_type>(proof.z);

typename fri_proof<TTypeBase, typename LPC::basic_fri>::type filled_fri_proof = fill_fri_proof<Endianness, typename LPC::basic_fri>(
proof.fri_proof, batch_info
proof.fri_proof, batch_info, fri_params
);

return typename eval_proof<TTypeBase, LPC>::type(
Expand Down
12 changes: 6 additions & 6 deletions include/nil/crypto3/marshalling/zk/types/placeholder/proof.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ namespace nil {
>;


template<typename Endianness, typename Proof>
template<typename Endianness, typename Proof, typename CommitmentParamsType>
placeholder_evaluation_proof<nil::marshalling::field_type<Endianness>, Proof>
fill_placeholder_evaluation_proof(const typename Proof::evaluation_proof &proof) {
fill_placeholder_evaluation_proof(const typename Proof::evaluation_proof &proof, const CommitmentParamsType& commitment_params) {

using TTypeBase = nil::marshalling::field_type<Endianness>;
using uint64_t_marshalling_type = nil::marshalling::types::integral<TTypeBase, std::uint64_t>;
Expand All @@ -75,7 +75,7 @@ namespace nil {

// typename commitment_scheme_type::proof_type eval_proof;
auto filled_eval_proof =
fill_eval_proof<Endianness, typename Proof::commitment_scheme_type>(proof.eval_proof);
fill_eval_proof<Endianness, typename Proof::commitment_scheme_type>(proof.eval_proof, commitment_params);

return placeholder_evaluation_proof<TTypeBase, Proof>(std::make_tuple(
filled_challenge,
Expand Down Expand Up @@ -118,9 +118,9 @@ namespace nil {
>
>;

template<typename Endianness, typename Proof>
template<typename Endianness, typename Proof, typename CommitmentParamsType>
placeholder_proof<nil::marshalling::field_type<Endianness>, Proof>
fill_placeholder_proof(const Proof &proof) {
fill_placeholder_proof(const Proof &proof, const CommitmentParamsType& commitment_params) {

using TTypeBase = nil::marshalling::field_type<Endianness>;

Expand All @@ -137,7 +137,7 @@ namespace nil {

return placeholder_proof<TTypeBase, Proof>(std::make_tuple(
filled_commitments,
fill_placeholder_evaluation_proof<Endianness, Proof>(proof.eval_proof)
fill_placeholder_evaluation_proof<Endianness, Proof>(proof.eval_proof, commitment_params)
));
}

Expand Down
Loading

0 comments on commit de11310

Please sign in to comment.