@@ -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 ] = 0x50b6a879ul ;
28+ sha -> s [1 ] = 0x0d9a7470ul ;
29+ sha -> s [2 ] = 0xb4400e54ul ;
30+ sha -> s [3 ] = 0x32d29ac7ul ;
31+ sha -> s [4 ] = 0xde938408ul ;
32+ sha -> s [5 ] = 0x923fc797ul ;
33+ sha -> s [6 ] = 0x29f973a6ul ;
34+ sha -> s [7 ] = 0xa25e1a1cul ;
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) {
4460 unsigned char scratch [65 ];
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