Code Monkey home page Code Monkey logo

zcash-fpga's Introduction

The work in this repo is the result of a Zcash foundation grant to develop open-source FPGA code that can be used to accelerate various aspects of the network. An Architecture document is here.

We also gave a presentation at the Taipei Ethereum Meetup here. Here is a copy of the presentation slides.

While mainly developed for Equihash verification and elliptic curve operations on the secp256k1 and bls12-381 curves, the code (ip_cores) used in this repo can also be applied to other curves by changing parameters / minimum modification to equations. Currently a FPGA accelerator for Ethereum 2.0 SNARKs is being developed here (underlying core modules are all reused as a submodule from this Zcash repo).

Getting started

The architecture document has instructions for building an AWS image or simulating the top level design. The easiest way is to add all .sv and .xci files to a new Vivado project, and then set the top level _tb.sv file to the module you want to test. Everything has been synthesized and tested in both simulation and on FPGA (AWS and Bittware) with both Vivado 2018.3 and 2019.1.

Repo folder structure

Each top level folder is explained below. Inside each folder is source code written in SystemVerilog, and most blocks have a stand-alone self-checking testbench.

AWS

This contains the top / project files for building on a AWS F1 instance (Amazon FPGA VU9P w/ 64GB DDR4).

  • This contains the zcash_fpga library (aws/cl_zcash/software/runtime/zcash_fpga.hpp) that can be used to interface with the FPGA over PCIe.
  • Instructions on how to build are in the architecture document.

bittware_xupvvh

This contains the top / project files for building on the Bittware VVH board (VU37P FPGA w/ 8GB HBM, 16GB DDR4).

ip_cores

These contain shared IP cores that are used by the projects in this repo. These include many functions, such as:

  • Hashing
    • Blake2b - single pipe implementation of blake2b and a pipline-unrolled version for high performance (single clock hash @ 200MHz after initial 52 clock delay).
    • SHA256 and SHA256d
  • Packages and interfaces for common use, along with many tasks to simplify simulation
    • AXI4
    • AXI4-lite
    • Block RAM
  • Fifo implementations
  • Hash map implementation
    • Fully parameterized for bit widths and uses CRC as the hashing function
  • Blocks for parsing/processing streams
  • Karatsuba multiplier
    • Fully parameterized for number of levels
  • Barret reduction for modulo reduction when the modulus does not allow fast reduction
    • Both a fully pipelined high performance version and a slower but smaller resource utilization version
  • Fully parallel multiplier with carry save adder tree and RAM for modular reduction
    • Fully pipelined, 3x performance over Karatsuba + Barret, but uses FPGA RAM
  • Multiplier using carry tree to accumulate products with BRAM for modular reduction
    • 3x performance over Karatsuba + Barret approach, but takes more LUTs / RAM
  • Addition and subtraction modules
    • Fully parameterized so that they can be used for large bit-width arithmetic
  • Extended Euclidean algorithm for calculating multiplicative inverses
  • Resource arbitrators
  • General purpose elliptical curve (Weierstrass) point and element modules
    • Point multiplication, doubling, adding up to Fp^12 (towered over Fp^6 and Fp^2)
    • Operations in both affine and jacobian coordinates

zcash_fpga

This is the top level for the Zcash FPGA. It contains source code and testbenches for the blocks used in the Zcash acceleration engine.

It optionally contains the following top-level engines (you can include in a build via parameters in the top level package):

  • Equihash verification engine
    • Verifies the equihash solution and difficulty filters
  • Transparent Signature Verification Engine (secp256k1 ECDSA core)
    • Uses efficient endomorphism to reduce key bit size
    • Signature verification calculates multiple EC point operations in parallel, using a resource-shared single fully pipelined karatsuba multiplier and quick modulo reduction technique
  • BLS12-381 coprocessor (zk-SNARK accelerator)
    • Custom instruction set with 2kB instruction memory
    • 12kB Data slot URAM at curve native bit width of 381b
    • General arithmetic up to Fp^12 (Towering Fp -> Fp^2 -> Fp^6 -> Fp^12) over bls12-381 curve
    • Dual Point multiplication in Fp and Fp^2 (G1 and G2)
    • Fp^12 Frobenius map operations
    • Fp^12 inversion
    • Fp^12 exponentiation
    • The optimal ate pairing
      • Miller loop and final exponentiation stage, with separate instructions for multi-pairing use

zcash-fpga's People

Contributors

bsdevlin avatar leonmac avatar lmaxeniro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zcash-fpga's Issues

compile error

HI ,,,
I use cadence irun tool to compile this project. I find some error about like as follows .
parameter DAT_BYTS,
parameter CTL_BITS, ....

Thanks.

lint error

In the specp256k1_top.sv file.

jb_point_t  .... , pt_X0,pt_X1,pt_X, ....;

You declare three signals but never used.I'm confused about that.

Is this project going to work on an FPGA?

Hi ALL,

Is this project in running condition?
I would like to get it to work on a xilinx ZCu102 board to get it to work but there is one issue reported and nobody has replied.
So I am trying to figure out if this is even gonna operate or is just abandoned in non working state.
Hashrate: Also nowhere there is any mention about the hashrate on the fpga board that was used to test.
Can anyone let me know if its gonna work and if possible, can u direct me to what changes I need to get it to work.

Thanks,
Kapoor7997

Unexpected behaviour when instantiate secp256k1 multiple times

I am using Vivado 2020.2 to test the secp256k1 core. I instantiated two cores in my design, but it behaved strangely during simulation. I simply let the cores running in parallel and drived only one of them, but it returned a timeout. However, if I just commented out the unused core, it would work correctly. I have attached a minimal design and testbench that can reproduce my
issue.

test_secp256k1.zip

common interface error

You write import task get_keep_from_mod();
But get_keep_from_mod is defined a function.So you should write as follows right ?

extern function get_keep_from_mod(); //should add 

...
modport sink(
.....
import function get_keep_from_mod();   //task changed to function
)

....
extern function get_keep_from_mod();
....

endfunction

scan mode

Hi ,,,
I find this code do not have enter into scan mode. I will use uvm method to verification some code of the project to make it to ASIC. Does the code have finished ?

logic area

Using logic registers to do these algorithms. It consumes too much resources registers and LUTs.
Why don't you use the memory method(such as internal or external RAMS) to implement these algorithms?It will reduce a lot of resources cells.

err <= err << 1;

secp256k1_mod.sv

always_ff @ (posedge i_clk) begin
  if (i_rst) begin
    val <= 0;
    err <= 0;
    o_val <= 0;
    ctl <= 0;
    o_err <= 0;
  end else begin
    if (~o_val || (i_rdy && o_val)) begin
      val <= val << 1;
      ctl <= {ctl, i_ctl};
      err <= err << 1;
      val[0] <= i_val && o_rdy;
      err[0] <= i_err;
      o_dat <= res1[255:0];
  
      o_err <= err[1] || res1 >= p_eq;
      o_val <= val[1];
      o_ctl <= ctl[1];
    end

  end
end



err <= err << 1; err signal is no sense.It doesn't work.

Maximum prover throughput

Hi Ben,

I would like to know, in your estimation, what would be the theoretical maximum prover throughput if I tiled a large FPGA (like an Alveo 280) with the BLS12-381 coprocessors. LUT utilisation was 25% on your device (VU9P), so I assume I could get 3-4 processors on an equivalent device, leading to a 12x speedup against a pretty high-end CPU (3.7GHz!). I noticed the clock speed is quite low (200MHz) even for an FPGA design (could probably hit 275 MHz?). Is there a possibility of cranking this up?

In your talk (https://www.youtube.com/watch?v=VNClWrMbhlg&t=1717s), is the CPU throughput referenced for single-thread or multiple threads? If it is single-thread, that is somewhat disappointing, since if I had 4 threads I should be able to achieve the same throughput.

Furthermore, judging by some past results, it seems one could get similar speedups (10x-40x) on a GPU? So perhaps FPGAs are not worth the trouble for now? Furthermore, how much could a powerful multicore machine like a threadripper with 64 or 128 logical threads do to speed things up over the CPU benchmark you used? This is assuming one could be running multiple proofs/pairings in parallel alongside parallelising individual proofs/pairings.

Best,
Jonathan

Error happen when start synthesizing

Hi I am trying to build this on a AWS F1 instance..
However some some error reported when starting synthesizing, error log is as below:
Study while and I find this file "accum_mult_mod_generated.sv" can be generated by a python script under zcash-fpga/ip_cores/accum_mult_mod/scripts/ .
But if using this specifically generated file directly, there will be other syntax error report by synthesizing tool..
Can you please take a look for the possible cause?
Tks!
LMa

ERROR: [Synth 8-1766] cannot open include file accum_mult_mod_generated.sv [/home/centos/aws-fpga/hdk/cl/developer_designs/cl_zcash/build/src_post_encryption/accum_mult_mod.sv:56]
ERROR: [Synth 8-1031] accum_grid_o_r is not declared [/home/centos/aws-fpga/hdk/cl/developer_designs/cl_zcash/build/src_post_encryption/accum_mult_mod.sv:114]
ERROR: [Synth 8-1031] accum_grid_o is not declared [/home/centos/aws-fpga/hdk/cl/developer_designs/cl_zcash/build/src_post_encryption/accum_mult_mod.sv:114]
ERROR: [Synth 8-1031] accum_grid_o_rr is not declared [/home/centos/aws-fpga/hdk/cl/developer_designs/cl_zcash/build/src_post_encryption/accum_mult_mod.sv:115]
ERROR: [Synth 8-1031] accum_grid_o_r is not declared [/home/centos/aws-fpga/hdk/cl/developer_designs/cl_zcash/build/src_post_encryption/accum_mult_mod.sv:115]
ERROR: [Synth 8-1031] accum2_grid_o is not declared [/home/centos/aws-fpga/hdk/cl/developer_designs/cl_zcash/build/src_post_encryption/accum_mult_mod.sv:123]
INFO: [Synth 8-2350] module accum_mult_mod ignored due to previous errors [/home/centos/aws-fpga/hdk/cl/developer_designs/cl_zcash/build/src_post_encryption/accum_mult_mod.sv:24]
Failed to read verilog '/home/centos/aws-fpga/hdk/cl/developer_designs/cl_zcash/build/src_post_encryption/accum_mult_mod.sv'
INFO: [Common 17-83] Releasing license: Synthesis
62 Infos, 4 Warnings, 0 Critical Warnings and 7 Errors encountered.
synth_design failed
ERROR: [Common 17-69] Command failed: Synthesis failed - please see the console or run log file for details

while executing

"source -notrace ./synth_${CL_MODULE}.tcl"
invoked from within
"if {${cl.synth}} {
source -notrace ./synth_${CL_MODULE}.tcl
set synth_dcp ${timestamp}.CL.post_synth.dcp
}"
(file "create_dcp_from_cl.tcl" line 203)

Build test application got error

I build the AFI on one Centos machine successfully.
I am able to load AFI to another F1 instance (ubuntu machine) successfully.
When I am trying to build the application to call-up the AFI, meet such issue (on ubuntu F1 machine):
Please have a look?

ubuntu@ip-XXXXXXXXX~/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime$ make all gcc -DCONFIG_LOGLEVEL=4 -g -Wall -I/home/ubuntu/aws-fpga/sdk/userspace/include -I /home/ubuntu/aws-fpga/hdk/common/software/include -I ./include -lstdc++ -std=c++11 -o test_zcash zcash_fpga.cpp test_zcash.cpp /home/ubuntu/aws-fpga/sdk/userspace/utils/sh_dpi_tasks.o -lfpga_mgmt -lrt -lpthread /tmp/ccjfM665.o: In function zcash_fpga::get_instance()':
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/zcash_fpga.cpp:28: undefined reference to __cxa_guard_acquire' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/zcash_fpga.cpp:28: undefined reference to __cxa_guard_release'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/zcash_fpga.cpp:28: undefined reference to __cxa_guard_abort' /tmp/ccjfM665.o:(.data.rel.local.DW.ref.__gxx_personality_v0[DW.ref.__gxx_personality_v0]+0x0): undefined reference to __gxx_personality_v0'
/tmp/ccynn5Cx.o: In function string_to_hex(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned char*)': /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:66: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::length() const'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:68: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::c_str() const' /tmp/ccynn5Cx.o: In function main':
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:118: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:118: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:118: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:118: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:119: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:119: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:119: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:119: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:120: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:120: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:120: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:120: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:121: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:121: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:121: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:121: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:122: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:122: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:122: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:122: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:179: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:179: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:179: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:179: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:185: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:185: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:185: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:185: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:191: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:191: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:191: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:191: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:197: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:197: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:197: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:197: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:203: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:203: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:203: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:203: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:209: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:209: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:209: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:209: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:328: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:328: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:328: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:328: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:329: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:329: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:329: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:329: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:330: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:330: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:330: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:330: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:331: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:331: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:331: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:331: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:332: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:332: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:332: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:332: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:333: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:333: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:333: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:333: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:334: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:334: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:334: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:334: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:335: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:335: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:335: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:335: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:336: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:336: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:336: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:336: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:337: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:337: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:337: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:337: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:338: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:338: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:338: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:338: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:339: undefined reference to std::allocator<char>::allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:339: undefined reference to std::__cxx11::basic_string<char, std::char_traits, std::allocator >::basic_string(char const*, std::allocator const&)'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:339: undefined reference to std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:339: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:118: undefined reference to std::allocator<char>::~allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:119: undefined reference to std::allocator::~allocator()'
/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:120: undefined reference to std::allocator<char>::~allocator()' /home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:121: undefined reference to std::allocator::~allocator()'
/tmp/ccynn5Cx.o:/home/ubuntu/aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime/test_zcash.cpp:122: more undefined references to std::allocator<char>::~allocator()' follow collect2: error: ld returned 1 exit status Makefile:34: recipe for target 'test_zcash' failed make: *** [test_zcash] Error 1

Follow up the g++ compiled test program, AFI detection error.

Hi I run the test code but reported as no AFI detected.

  1. however check manually by I do have the AFI loaded correctly, slot/VendorID/DeviceId shall be all right (see log below)--anything else could cause error?
    The error comes from this function: fpga_mgmt_describe_local_image() --but can not find its implementation.
  2. log INFO shows the all tests passed--but the tests did not run yet?
  3. switch to root by su command and run, same error.

`ubuntu@ip-XXXXXXXXX: ~ /aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime$ make all
g++ -DCONFIG_LOGLEVEL=4 -g -Wall -I /home/ubuntu/aws-fpga/sdk/userspace/include -I /home/ubuntu/aws-fpga/hdk/common/software/include -I ./include -lstdc++ -std=c++11 -o test_zcash zcash_fpga.cpp test_zcash.cpp /home/ubuntu/aws-fpga/sdk/userspace/utils/sh_dpi_tasks.o -lfpga_mgmt -lrt -lpthread

ubuntu@ip-XXXXXXXXX:~ /aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime$ sudo ./test_zcash
2019-10-10T02:29:23.142966Z, undefined, ERROR, zcash_fpga.cpp +153: check_afi_ready(): ERROR: Unable to get AFI information from slot 0. Are you running as root?
2019-10-10T02:29:23.143041Z, undefined, ERROR, zcash_fpga.cpp +47: init_fpga(): ERROR: AFI not ready
ERROR: Unable to initialize to FPGA!
INFO: All tests passed!

ubuntu@ip-XXXXXXXXX:~ /aws-fpga/hdk/cl/developer_designs/cl_zcash/software/runtime$ sudo fpga-describe-local-image -S 0 -R -H
Type FpgaImageSlot FpgaImageId StatusName StatusCode ErrorName ErrorCode ShVersion
AFI 0 agfi-0ea41d448d4efefb7 loaded 0 ok 0 0x04261818
Type FpgaImageSlot VendorId DeviceId DBDF
AFIDEVICE 0 0x1d0f 0xf000 0000:00:1d.0
`

math calculate question

I view the secp256k1 module.the ECDSA signature verification as follows

  1. compute w= s^(-1) mod n.
  2. u1=H(m)w mod n and u2 = rw mod n.
  3. X=u1P + u2Q.
  4. Covert the x-coordinate x1 of X to an integer /x1;compute v = /x1 mod n.

When the code compute X=u1P +u2Q.Using the Jacobian coordinate point add.Then I noticed you provide two ways (one is CALC_X_AFFINE,another is CHECK_IN_JB) to check the result.In the CALC_X_AFFINE state,Firstly mult the z^2 ,Secondly ,do the binary inverse . and inv_p is secp256k1_pkg::p_eq; I'm confused about the binary inverse.Thirdly, mult the z^2 with X to covert AFFINE .

I'm confused about CALC_X_AFFINE state operation.Could you explain to me? Thanks a lot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.