@@ -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 ] = 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
+
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
size_t extra_commit_len
44
60
) {
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