forked from HalosGhost/bulletproof-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.patch
50 lines (46 loc) · 1.88 KB
/
helper.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
diff --git a/include/secp256k1_generator.h b/include/secp256k1_generator.h
index 5479fc8..3498170 100644
--- a/include/secp256k1_generator.h
+++ b/include/secp256k1_generator.h
@@ -104,6 +104,16 @@ typedef struct {
unsigned char data[64];
} secp256k1_pedersen_commitment;
+/** Reinterpret a pedersen commitment as a public key
+ *
+ * In: comm: a pointer to a pedersen commitment
+ * Out: key: a pointer to a public key
+ */
+SECP256K1_API void secp256k1_pedersen_commitment_as_key(
+ secp256k1_pedersen_commitment* comm,
+ secp256k1_pubkey* key
+) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2);
+
/** Parse a 33-byte commitment into a commitment object.
*
* Returns: 1 if input contains a valid commitment.
diff --git a/src/modules/generator/main_impl.h b/src/modules/generator/main_impl.h
index 544d8fe..4fc5235 100644
--- a/src/modules/generator/main_impl.h
+++ b/src/modules/generator/main_impl.h
@@ -36,7 +36,6 @@ static const secp256k1_generator secp256k1_generator_h_internal = {{
const secp256k1_generator *secp256k1_generator_h = &secp256k1_generator_h_internal;
-
static void secp256k1_generator_load(secp256k1_ge* ge, const secp256k1_generator* gen) {
int succeed;
succeed = secp256k1_fe_set_b32(&ge->x, &gen->data[0]);
@@ -258,6 +257,16 @@ static void secp256k1_pedersen_commitment_save(secp256k1_pedersen_commitment* co
commit->data[0] = 9 ^ secp256k1_fe_is_quad_var(&ge->y);
}
+void secp256k1_pedersen_commitment_as_key(secp256k1_pedersen_commitment* comm, secp256k1_pubkey* key) {
+ secp256k1_ge ge;
+
+ VERIFY_CHECK(comm != NULL);
+ VERIFY_CHECK(key != NULL);
+
+ secp256k1_pedersen_commitment_load(&ge, comm);
+ secp256k1_pubkey_save(key, &ge);
+}
+
int secp256k1_pedersen_commitment_parse(const secp256k1_context* ctx, secp256k1_pedersen_commitment* commit, const unsigned char *input) {
secp256k1_fe x;
secp256k1_ge ge;