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