Line data Source code
1 : #ifndef HEADER_fd_src_ballet_zksdk_rangeproofs_fd_rangeproofs_h 2 : #define HEADER_fd_src_ballet_zksdk_rangeproofs_fd_rangeproofs_h 3 : 4 : #include "fd_rangeproofs_transcript.h" 5 : 6 : #if FD_HAS_AVX512 7 : #include "./fd_rangeproofs_table_avx512.c" 8 : #else 9 : #include "./fd_rangeproofs_table_ref.c" 10 : #endif 11 : 12 : /* Rangeproofs constants. These are imported from fd_rangeproofs_table_{arch}.c. 13 : they are (re)defined here to avoid breaking compilation when the table needs 14 : to be rebuilt. */ 15 : static const fd_ristretto255_point_t fd_rangeproofs_basepoint_G[1]; 16 : static const fd_ristretto255_point_t fd_rangeproofs_basepoint_H[1]; 17 : static const fd_ristretto255_point_t fd_rangeproofs_generators_G[256]; 18 : static const fd_ristretto255_point_t fd_rangeproofs_generators_H[256]; 19 : 20 0 : #define FD_RANGEPROOFS_SUCCESS 0 21 0 : #define FD_RANGEPROOFS_ERROR -1 22 : 23 0 : #define FD_RANGEPROOFS_MAX_COMMITMENTS 8 24 : 25 : struct __attribute__((packed)) fd_rangeproofs_ipp_vecs { 26 : uchar l[ 32 ]; // point 27 : uchar r[ 32 ]; // point 28 : }; 29 : typedef struct fd_rangeproofs_ipp_vecs fd_rangeproofs_ipp_vecs_t; 30 : 31 : struct __attribute__((packed)) fd_rangeproofs_range_proof { 32 : uchar a [ 32 ]; // point 33 : uchar s [ 32 ]; // point 34 : uchar t1 [ 32 ]; // point 35 : uchar t2 [ 32 ]; // point 36 : uchar tx [ 32 ]; // scalar 37 : uchar tx_blinding[ 32 ]; // scalar 38 : uchar e_blinding [ 32 ]; // scalar 39 : }; 40 : typedef struct fd_rangeproofs_range_proof fd_rangeproofs_range_proof_t; 41 : 42 : struct fd_rangeproofs_ipp_proof { 43 : const uchar logn; // log(bit_length): 6 for u64, 7 for u128, 8 for u256 44 : const fd_rangeproofs_ipp_vecs_t * vecs; // log(bit_length) points 45 : const uchar * a; // scalar 46 : const uchar * b; // scalar 47 : }; 48 : typedef struct fd_rangeproofs_ipp_proof fd_rangeproofs_ipp_proof_t; 49 : 50 : FD_PROTOTYPES_BEGIN 51 : 52 : int 53 : fd_rangeproofs_verify( 54 : fd_rangeproofs_range_proof_t const * range_proof, 55 : fd_rangeproofs_ipp_proof_t const * ipp_proof, 56 : uchar const commitments [ 32 ], 57 : uchar const bit_lengths [ 1 ], 58 : uchar const batch_len, 59 : fd_merlin_transcript_t * transcript ); 60 : 61 : FD_PROTOTYPES_END 62 : #endif /* HEADER_fd_src_ballet_zksdk_rangeproofs_fd_rangeproofs_h */