VegeBun-csj / substrate-zk

A substrate-based chain with bellman
Apache License 2.0
2 stars 1 forks source link

What is the format of generate_proof_vkey function arguments? #1

Closed atsupontio closed 1 year ago

atsupontio commented 2 years ago

Hello, thanks for this useful library !

I tried to create a proof using the generate_proof_vkey function but could not. The arguments I entered (proof_a) are in the following format

[7, 224, 184, 255, 109, 41, 194, 34, 144, 62, 254, 105, 17, 13, 208, 72, 254, 225, 11, 17, 24, 43, 3, 141, 145, 133, 86, 132, 253, 105, 61, 203, 18, 6, 69, 110, 209, 249, 74, 120, 106, 250, 23, 51, 194, 29, 54, 206, 15, 115, 202, 140, 73, 206, 149, 179, 103, 251, 133, 228, 24, 77, 223, 144, 131, 39, 129, 252, 78, 202, 129, 155, 14, 194, 145, 110, 208, 55, 90, 19, 37, 44, 84, 184, 241, 209, 249, 195, 3, 21, 108, 233, 168, 140, 84, 100]

I also got the following error when executing the verifier function

Version: 4.0.0-dev-4860364029c

   0: sp_panic_handler::set::{{closure}}
   1: std::panicking::rust_panic_with_hook
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:702:17
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:588:13
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/sys_common/backtrace.rs:138:18
   4: rust_begin_unwind
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
   5: core::panicking::panic_fmt
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
   6: core::panicking::panic_bounds_check
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:84:5
   7: pallet_maci_verifier::parser::parse_proof
   8: pallet_maci_verifier::pallet::Pallet<T>::verifier
   9: frame_support::storage::transactional::in_storage_layer
  10: <pallet_maci_verifier::pallet::Call<T> as frame_support::traits::dispatch::UnfilteredDispatchable>::dispatch_bypass_filter
  11: <node_template_runtime::Call as frame_support::traits::dispatch::UnfilteredDispatchable>::dispatch_bypass_filter
  12: <node_template_runtime::Call as sp_runtime::traits::Dispatchable>::dispatch
  13: <sp_runtime::generic::checked_extrinsic::CheckedExtrinsic<AccountId,Call,Extra> as sp_runtime::traits::Applyable>::apply
  14: frame_executive::Executive<System,Block,Context,UnsignedValidator,AllPalletsWithSystem,COnRuntimeUpgrade>::apply_extrinsic
  15: <node_template_runtime::Runtime as sp_block_builder::runtime_decl_for_BlockBuilder::BlockBuilder<sp_runtime::generic::block::Block<sp_runtime::generic::header::Header<u32,sp_runtime::traits::BlakeTwo256>,sp_runtime::generic::unchecked_extrinsic::UncheckedExtrinsic<sp_runtime::multiaddress::MultiAddress<<<sp_runtime::MultiSignature as sp_runtime::traits::Verify>::Signer as sp_runtime::traits::IdentifyAccount>::AccountId,()>,node_template_runtime::Call,sp_runtime::MultiSignature,(frame_system::extensions::check_non_zero_sender::CheckNonZeroSender<node_template_runtime::Runtime>,frame_system::extensions::check_spec_version::CheckSpecVersion<node_template_runtime::Runtime>,frame_system::extensions::check_tx_version::CheckTxVersion<node_template_runtime::Runtime>,frame_system::extensions::check_genesis::CheckGenesis<node_template_runtime::Runtime>,frame_system::extensions::check_mortality::CheckMortality<node_template_runtime::Runtime>,frame_system::extensions::check_nonce::CheckNonce<node_template_runtime::Runtime>,frame_system::extensions::check_weight::CheckWeight<node_template_runtime::Runtime>,pallet_transaction_payment::ChargeTransactionPayment<node_template_runtime::Runtime>)>>>>::apply_extrinsic
  16: std::panicking::try
  17: std::thread::local::LocalKey<T>::with
  18: sc_executor::native_executor::WasmExecutor<H>::with_instance::{{closure}}
  19: sc_executor::wasm_runtime::RuntimeCache::with_instance
  20: <sc_executor::native_executor::NativeElseWasmExecutor<D> as sp_core::traits::CodeExecutor>::call
  21: sp_state_machine::execution::StateMachine<B,H,Exec>::execute_aux
  22: sp_state_machine::execution::StateMachine<B,H,Exec>::execute_using_consensus_failure_handler
  23: <sc_service::client::call_executor::LocalCallExecutor<Block,B,E> as sc_client_api::call_executor::CallExecutor<Block>>::contextual_call
  24: <sc_service::client::client::Client<B,E,Block,RA> as sp_api::CallApiAt<Block>>::call_api_at
  25: sp_block_builder::runtime_decl_for_BlockBuilder::apply_extrinsic_call_api_at
  26: <node_template_runtime::RuntimeApiImpl<__SR_API_BLOCK__,RuntimeApiImplCall> as sp_block_builder::BlockBuilder<__SR_API_BLOCK__>>::BlockBuilder_apply_extrinsic_runtime_api_impl
  27: <node_template_runtime::RuntimeApiImpl<Block,C> as sp_api::ApiExt<Block>>::execute_in_transaction
  28: <sc_basic_authorship::basic_authorship::Proposer<B,Block,C,A,PR> as sp_consensus::Proposer<Block>>::propose::{{closure}}
  29: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  30: <sc_service::task_manager::prometheus_future::PrometheusFuture<T> as core::future::future::Future>::poll
  31: <futures_util::future::select::Select<A,B> as core::future::future::Future>::poll
  32: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  33: std::thread::local::LocalKey<T>::with
  34: tokio::park::thread::CachedParkThread::block_on
  35: tokio::runtime::handle::Handle::block_on
  36: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
  37: tokio::runtime::task::harness::Harness<T,S>::poll
  38: tokio::runtime::blocking::pool::Inner::run
  39: std::sys_common::backtrace::__rust_begin_short_backtrace
  40: core::ops::function::FnOnce::call_once{{vtable.shim}}
  41: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/alloc/src/boxed.rs:1935:9
      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/alloc/src/boxed.rs:1935:9
      std::sys::unix::thread::Thread::new::thread_start
             at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/sys/unix/thread.rs:108:17
  42: start_thread
  43: clone

Thread 'tokio-runtime-worker' panicked at 'index out of bounds: the len is 96 but the index is 96', /home/○○/substrate-zk/pallets/maci-verifier/src/parser.rs:20

This is a bug. Please report it at:

        support.anonymous.an

2022-10-03 14:11:30 🙌 Starting consensus session on top of parent 0x10868aceda485a956ef28fdd3b1153369213fdfe8e6b2bf712282720d687ffbb    
2022-10-03 14:11:30 [91, 55, 44, 32, 50, 50, 52, 44, 32, 49, 56, 52, 44, 32, 50, 53, 53, 44, 32, 49, 48, 57, 44, 32, 52, 49, 44, 32, 49, 57, 52, 44, 32, 51, 52, 44, 32, 49, 52, 52, 44, 32, 54, 50, 44, 32, 50, 53, 52, 44, 32, 49, 48, 53, 44, 32, 49, 55, 44, 32, 49, 51, 44, 32, 50, 48, 56, 44, 32, 55, 50, 44, 32, 50, 53, 52, 44, 32, 50, 50, 53, 44, 32, 49, 49, 44, 32, 49, 55, 44, 32, 50, 52, 44, 32, 52, 51, 44, 32, 51, 44, 32, 49, 52, 49, 44, 32, 49, 52, 53, 44, 32, 49, 51, 51, 44, 32, 56, 54, 44, 32, 49, 51, 50, 44, 32, 50, 53, 51, 44, 32, 49, 48, 53, 44, 32, 54, 49, 44, 32, 50, 48, 51, 44, 32, 49, 56, 44, 32, 54, 44, 32, 54, 57, 44, 32, 49, 49, 48, 44, 32, 50, 48, 57, 44, 32, 50, 52, 57, 44, 32, 55, 52, 44, 32, 49, 50, 48, 44, 32, 49, 48, 54, 44, 32, 50, 53, 48, 44, 32, 50, 51, 44, 32, 53, 49, 44, 32, 49, 57, 52, 44, 32, 50, 57, 44, 32, 53, 52, 44, 32, 50, 48, 54, 44, 32, 49, 53, 44, 32, 49, 49, 53, 44, 32, 50, 48, 50, 44, 32, 49, 52, 48, 44, 32, 55, 51, 44, 32, 50, 48, 54, 44, 32, 49, 52, 57, 44, 32, 49, 55, 57, 44, 32, 49, 48, 51, 44, 32, 50, 53, 49, 44, 32, 49, 51, 51, 44, 32, 50, 50, 56, 44, 32, 50, 52, 44, 32, 55, 55, 44, 32, 50, 50, 51, 44, 32, 49, 52, 52, 44, 32, 49, 51, 49, 44, 32, 51, 57, 44, 32, 49, 50, 57, 44, 32, 50, 53, 50, 44, 32, 55, 56, 44, 32, 50, 48, 50, 44, 32, 49, 50, 57, 44, 32, 49, 53, 53, 44, 32, 49, 52, 44, 32, 49, 57, 52, 44, 32, 49, 52, 53, 44, 32, 49, 49, 48, 44, 32, 50, 48, 56, 44, 32, 53, 53, 44, 32, 57, 48, 44, 32, 49, 57, 44, 32, 51, 55, 44, 32, 52, 52, 44, 32, 56, 52, 44, 32, 49, 56, 52, 44, 32, 50, 52, 49, 44, 32, 50, 48, 57, 44, 32, 50, 52, 57, 44, 32, 49, 57, 53, 44, 32, 51, 44, 32, 50, 49, 44, 32, 49, 48, 56, 44, 32, 50, 51, 51, 44, 32, 49, 54, 56, 44, 32, 49, 52, 48, 44, 32, 56, 52, 44, 32, 49, 48, 48, 93]    
2022-10-03 14:11:30 1 storage transactions are left open by the runtime. Those will be rolled back.    
2022-10-03 14:11:30 1 storage transactions are left open by the runtime. Those will be rolled back.    
2022-10-03 14:11:30 🎁 Prepared block for proposing at 16 (21 ms) [hash: 0x8ed492bdecad4aa0505410f6e4a50132906ecac9db1ed50732a21cb6e11e1461; parent_hash: 0x1086…ffbb; extrinsics (1): [0xf4f6…8bad]]    
2022-10-03 14:11:30 🔖 Pre-sealed block for proposal at 16. Hash now 0xaee439bc37fd901807069901778ff0c4c09619205eafc2e9787e190815911d05, previously 0x8ed492bdecad4aa0505410f6e4a50132906ecac9db1ed50732a21cb6e11e1461.    
2022-10-03 14:11:30 ✨ Imported #16 (0xaee4…1d05)    
2022-10-03 14:11:31 unsubscribe call `author_unwatchExtrinsic` subscription key=SubscriptionKey { conn_id: 0, sub_id: Str("o6UsACDcahPR74YM") } not an active subscription
atsupontio commented 1 year ago

I solved the problem by converting uncompressed proof and vkey to hexadecimal.

VegeBun-csj commented 1 year ago

yes, you are right!