@@ -20,6 +20,22 @@ static void secp256k1_bulletproofs_serialize_points(unsigned char *output, const
2020 secp256k1_fe_get_b32 (& output [33 ], & rpt -> x );
2121}
2222
23+ /* Initializes SHA256 with fixed midstate. This midstate was computed by applying
24+ * SHA256 to SHA256("Bulletproofs/commitment")||SHA256("Bulletproofs/commitment"). */
25+ static void secp256k1_bulletproofs_sha256_tagged_commitment (secp256k1_sha256 * sha ) {
26+ secp256k1_sha256_initialize (sha );
27+ sha -> s [0 ] = 0xbb15fb75ul ;
28+ sha -> s [1 ] = 0xa8e6af90ul ;
29+ sha -> s [2 ] = 0x5b019104ul ;
30+ sha -> s [3 ] = 0x7fc4f83ful ;
31+ sha -> s [4 ] = 0x13280e0bul ;
32+ sha -> s [5 ] = 0xf5395816ul ;
33+ sha -> s [6 ] = 0x5a9d6e5bul ;
34+ sha -> s [7 ] = 0x5856888eul ;
35+
36+ sha -> bytes = 64 ;
37+ }
38+
2339/* little-endian encodes a uint64 */
2440static void secp256k1_bulletproofs_le64 (unsigned char * output , const uint64_t n ) {
2541 output [0 ] = n ;
@@ -43,8 +59,7 @@ static void secp256k1_bulletproofs_commit_initial_data(
4359 size_t extra_commit_len
4460) {
4561 secp256k1_sha256 sha256 ;
46- secp256k1_sha256_initialize (& sha256 );
47- /* FIXME use tagged hash here */
62+ secp256k1_bulletproofs_sha256_tagged_commitment (& sha256 );
4863 secp256k1_bulletproofs_le64 (scratch , n_bits );
4964 secp256k1_sha256_write (& sha256 , scratch , 8 );
5065 secp256k1_bulletproofs_le64 (scratch , min_value );
0 commit comments