@@ -20,6 +20,22 @@ static void secp256k1_bulletproofs_serialize_points(unsigned char *output, const
20
20
secp256k1_fe_get_b32 (& output [33 ], & rpt -> x );
21
21
}
22
22
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
+
23
39
/* little-endian encodes a uint64 */
24
40
static void secp256k1_bulletproofs_le64 (unsigned char * output , const uint64_t n ) {
25
41
output [0 ] = n ;
@@ -43,8 +59,7 @@ static void secp256k1_bulletproofs_commit_initial_data(
43
59
) {
44
60
unsigned char scratch [65 ];
45
61
secp256k1_sha256 sha256 ;
46
- secp256k1_sha256_initialize (& sha256 );
47
- /* FIXME use tagged hash here */
62
+ secp256k1_bulletproofs_sha256_tagged_commitment (& sha256 );
48
63
secp256k1_bulletproofs_le64 (scratch , n_bits );
49
64
secp256k1_sha256_write (& sha256 , scratch , 8 );
50
65
secp256k1_bulletproofs_le64 (scratch , min_value );
0 commit comments