当前位置: 首页 > 工具软件 > monero-regex > 使用案例 >

Monero bulletproof 源码结构解析

房育
2023-12-01

1. 代码下载并切换到指定commit

切换到 bp-multi-aggregation 分支的7f964dfc8f15145e364ae4763c49026a3fab985d commit.

git clone https://github.com/moneromooo-monero/bitmonero.git
cd bitmonero
git checkout 7f964dfc8f

Bulletproof的代码实现主要在src/ringct目录下,其中ringct代表Ring Confidential Transaction.
该目录下的代码结构主要为:
src/ringct
├── bulletproofs.cc
├── bulletproofs.h
├── CMakeLists.txt
├── multiexp.cc
├── multiexp.h
├── rctCryptoOps.c
├── rctCryptoOps.h
├── rctOps.cpp
├── rctOps.h
├── rctSigs.cpp
├── rctSigs.h
├── rctTypes.cpp
└── rctTypes.h

src/ringct目录下的源码主要依赖为:

  • src/crypto/目录下定义的密码学函数;
  • src/common/, src/serialization/contrib/epee/include/目录下的工具类函数;
  • src/cryptonote_config.hcryptonote_basic/cryptonote_format_utils.h文件中定义的通用格式和函数;
  • boostopenssl/ssl.h等外部依赖库。

2. 代码结构

src/ringct目录下主要有以下6类功能:
bulletproofs declares the two main functions bulletproof_PROVE and bulletproof_VERIFY with variants depending on the input parameters.
multiexp declares the structure and the functions used for multi-exponentiation. The three algorithms implemented are Straus, Bos-Coster and Pippenger.
rctCryptoOps declares the function sc_reduce32copy(unsigned char * scopy, const unsigned char *s) which is a variant of sc_reduce32(unsigned char *s) in src/crypto/crypto-ops.h providing the result in scopy. It is a reduction modulo
ℓ = 2252 + 27742317777372353535851937790883648493 (order of the main subgroup of the curve Ed25519) of a 32-byte input.
rctOps declares constants and functions related to the manipulation of vectors or points (initialization, random generation, addition, multiplication, commitments, hash-to-point, etc.)
rctSigs declares functions related to the Multilayered Spontaneous Anonymous Group Signatures (MLSAG signatures) which allows the confidential transactions. It also contains the former range proof and verification functions relying on ring signatures that should be replaced by bulletproofs.
rctTypes defines all the objects (key, signature, tuple, etc.) in the rct namespace and conversion functions.

参考资料:
[1] https://ostif.org/wp-content/uploads/2018/10/OSTIF-QuarksLab-Monero-Bulletproofs-Final2.pdf

 类似资料: