LCOV - code coverage report
Current view: top level - flamenco/runtime/program/zksdk/transcript - fd_zksdk_transcript.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 39 42 92.9 %
Date: 2024-11-13 11:58:15 Functions: 22 154 14.3 %

          Line data    Source code
       1             : #ifndef HEADER_fd_src_flamenco_runtime_program_zksdk_fd_transcript_h
       2             : #define HEADER_fd_src_flamenco_runtime_program_zksdk_fd_transcript_h
       3             : 
       4             : /* https://github.com/anza-xyz/agave/blob/v2.0.1/zk-sdk/src/transcript.rs */
       5             : 
       6             : #include "../../../../fd_flamenco_base.h"
       7             : #include "../merlin/fd_merlin.h"
       8             : #include "../rangeproofs/fd_rangeproofs.h"
       9             : #include "../../../../../ballet/ed25519/fd_ristretto255.h"
      10             : 
      11         567 : #define fd_zksdk_transcript_t fd_merlin_transcript_t
      12        5133 : #define FD_TRANSCRIPT_LITERAL FD_MERLIN_LITERAL
      13             : 
      14         567 : #define fd_zksdk_transcript_init                      fd_merlin_transcript_init
      15         210 : #define fd_zksdk_transcript_append_message            fd_merlin_transcript_append_message
      16         219 : #define fd_zksdk_transcript_append_point              fd_rangeproofs_transcript_append_point
      17         864 : #define fd_zksdk_transcript_validate_and_append_point fd_rangeproofs_transcript_validate_and_append_point
      18             : #define fd_zksdk_transcript_append_scalar             fd_rangeproofs_transcript_append_scalar
      19         789 : #define fd_zksdk_transcript_challenge_scalar          fd_rangeproofs_transcript_challenge_scalar
      20             : 
      21             : FD_PROTOTYPES_BEGIN
      22             : 
      23             : /* Append message:
      24             :    - pubkey
      25             :    - ciphertext (twisted elgamal 64 bytes: handle + commitment)
      26             :    - commitment
      27             :    - handle
      28             :  */
      29             : 
      30             : static inline void
      31             : fd_zksdk_transcript_append_pubkey( fd_zksdk_transcript_t * transcript,
      32             :                                    char const * const      label,
      33             :                                    uint const              label_len,
      34         645 :                                    uchar const             pubkey[ 32 ] ) {
      35         645 :   fd_merlin_transcript_append_message( transcript, label, label_len, pubkey, 32 );
      36         645 : }
      37             : 
      38             : static inline void
      39             : fd_zksdk_transcript_append_ciphertext( fd_zksdk_transcript_t * transcript,
      40             :                                        char const * const      label,
      41             :                                        uint const              label_len,
      42         273 :                                        uchar const             ciphertext[ 64 ] ) {
      43         273 :   fd_merlin_transcript_append_message( transcript, label, label_len, ciphertext, 64 );
      44         273 : }
      45             : 
      46             : static inline void
      47             : fd_zksdk_transcript_append_commitment( fd_zksdk_transcript_t * transcript,
      48             :                                        char const * const      label,
      49             :                                        uint const              label_len,
      50         174 :                                        uchar const             commitment[ 32 ] ) {
      51         174 :   fd_merlin_transcript_append_message( transcript, label, label_len, commitment, 32 );
      52         174 : }
      53             : 
      54             : static inline void
      55             : fd_zksdk_transcript_append_handle( fd_zksdk_transcript_t * transcript,
      56             :                                    char const * const      label,
      57             :                                    uint const              label_len,
      58           0 :                                    uchar const             handle[ 32 ] ) {
      59           0 :   fd_merlin_transcript_append_message( transcript, label, label_len, handle, 32 );
      60           0 : }
      61             : 
      62             : /* 
      63             :  * Domain separators
      64             :  */
      65             : 
      66             : static inline void
      67          54 : fd_zksdk_transcript_domsep_ciph_ciph_eq_proof( fd_zksdk_transcript_t * transcript ) {
      68          54 :   fd_merlin_transcript_append_message( transcript, FD_TRANSCRIPT_LITERAL("dom-sep"), (uchar *)FD_TRANSCRIPT_LITERAL("ciphertext-ciphertext-equality-proof") );
      69          54 : }
      70             : 
      71             : static inline void
      72          36 : fd_zksdk_transcript_domsep_ciph_comm_eq_proof( fd_zksdk_transcript_t * transcript ) {
      73          36 :   fd_merlin_transcript_append_message( transcript, FD_TRANSCRIPT_LITERAL("dom-sep"), (uchar *)FD_TRANSCRIPT_LITERAL("ciphertext-commitment-equality-proof") );
      74          36 : }
      75             : 
      76             : static inline void
      77          99 : fd_zksdk_transcript_domsep_zero_ciphertext_proof( fd_zksdk_transcript_t * transcript ) {
      78          99 :   fd_merlin_transcript_append_message( transcript, FD_TRANSCRIPT_LITERAL("dom-sep"), (uchar *)FD_TRANSCRIPT_LITERAL("zero-ciphertext-proof") );
      79          99 : }
      80             : 
      81             : static inline void
      82         120 : fd_zksdk_transcript_domsep_grp_ciph_val_proof( fd_zksdk_transcript_t * transcript, ulong handles ) {
      83         120 :   fd_merlin_transcript_append_message( transcript, FD_TRANSCRIPT_LITERAL("dom-sep"), (uchar *)FD_TRANSCRIPT_LITERAL("validity-proof") );
      84         120 :   fd_merlin_transcript_append_u64    ( transcript, FD_TRANSCRIPT_LITERAL("handles"), handles );
      85         120 : }
      86             : 
      87             : static inline void
      88          63 : fd_zksdk_transcript_domsep_batched_grp_ciph_val_proof( fd_zksdk_transcript_t * transcript, ulong handles ) {
      89          63 :   fd_merlin_transcript_append_message( transcript, FD_TRANSCRIPT_LITERAL("dom-sep"), (uchar *)FD_TRANSCRIPT_LITERAL("batched-validity-proof") );
      90          63 :   fd_merlin_transcript_append_u64    ( transcript, FD_TRANSCRIPT_LITERAL("handles"), handles );
      91          63 : }
      92             : 
      93             : static inline void
      94          39 : fd_zksdk_transcript_domsep_percentage_with_cap_proof( fd_zksdk_transcript_t * transcript ) {
      95          39 :   fd_merlin_transcript_append_message( transcript, FD_TRANSCRIPT_LITERAL("dom-sep"), (uchar *)FD_TRANSCRIPT_LITERAL("percentage-with-cap-proof") );
      96          39 : }
      97             : 
      98             : static inline void
      99          30 : fd_zksdk_transcript_domsep_pubkey_proof( fd_zksdk_transcript_t * transcript ) {
     100          30 :   fd_merlin_transcript_append_message( transcript, FD_TRANSCRIPT_LITERAL("dom-sep"), (uchar *)FD_TRANSCRIPT_LITERAL("pubkey-proof") );
     101          30 : }
     102             : 
     103             : FD_PROTOTYPES_END
     104             : #endif /* HEADER_fd_src_flamenco_runtime_program_zksdk_fd_transcript_h */

Generated by: LCOV version 1.14