Giter VIP home page Giter VIP logo

rapidec's Introduction

RapidEC: Accelerating Elliptic Curve Digital Signature Algorithms on GPUs

GPU-accelerated ECDSA library for the SM2 curve.

Dependencies

  • NVIDIA CUDA Toolkit
  • GMP (GNU Multiple Precision Library)

Build the example (main.cpp)

  1. Build with CMake
mkdir build && cd build
cmake -DCMAKE_CUDA_ARCHITECTURES=70 ..
make
  1. Build manually
mkdir -p bin
nvcc -O3 -gencode arch=compute_70,code=sm_70 -o bin/gsv.o -c gsv.cu
g++ -O3 -I/usr/local/cuda-11/include -o bin/main.o -c main.cpp
g++ -O3 -o bin/main bin/gsv.o bin/main.o -L/usr/local/cuda-11/lib64 -lcuda -lcudart -lgmp

Build and run Docker image

docker build -t rapidec:v1 .
docker run -it --gpus all rapidec:v1

API description

#include "RapidSV/gsv_wrapper.h"
void GSV_init(int device_id = 0);
void GSV_verify(int count, sig_t *sig, int *results);
void GSV_close();

GSV_init() initializes the GPU device, allocates the GPU memory pool, and copies the precomputed table to constant memory.

GSV_verify() does the signature verification.

  • The first parameter is the number of signatures.
  • The second parameter is the array of signatures. Each signature is a sig_t struct that contains 5 big integers, namely signature (r, s), message digest e, and public key (key_x, key_y). Each big integer is represented by an array of unsigned 32-bit integers.
  • The third parameter is the array of verification results. Correct verification returns 0, otherwise 1.

GSV_close() frees GPU memory.

Configuration

Configurable flags in gsv_wrapper.h:

  • GSV_TPI: Threads per instance, a parameter of the CGBN library. Can be set to 4, 8, 16, or 32. Default value is 16.
  • GSV_256BIT: Enable this flag to use 256-bit integers for calculation rather than 512-bit integers. Will save space but a bit slower.
  • GSV_KNOWN_PKEY: When the public key of a batch of signatures are the same, use a precomputed table to speed up verification. Need to generate different sm2_pkey_512.table for different keys.

Acknowledgement

This project used the CGBN library.

rapidec's People

Contributors

unisolate avatar

Stargazers

 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

rapidec's Issues

fixed_point_mult module bug

Recently, I have been learning about CUDA programming and digital signatures, and I am fortunate to have seen this project and have benefited greatly. When I saw the fixed point multiplication calculation, I tested it separately and found that the correct fixed point multiplication results can only be generated when the TPI is 8 in 256bit storage, and the calculated results are consistent and incorrect at 256bit, TPI=16, and 512bit, TPI=8, and TPI=16. I want to ask the reason for the error. Thank you.

Measure memory transfer cost

In gsv.cu/test_sig_verify(), measure the time cost of memory transfer between CPU and GPU using gettimeofday or CUDA event.

Parameter tuning

  • Fix the number of instances, change the number of threads per instance.
  • FIx the number of threads per instance, change the number of instances.

Find how does performance change and what is the best parameter setting.

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.