@@ -26,19 +26,19 @@ int main(void) {
26
26
unsigned char randomize [32 ];
27
27
int return_val ;
28
28
size_t len ;
29
- rustsecp256k1_v0_8_1_pubkey pubkey1 ;
30
- rustsecp256k1_v0_8_1_pubkey pubkey2 ;
29
+ rustsecp256k1_v0_9_0_pubkey pubkey1 ;
30
+ rustsecp256k1_v0_9_0_pubkey pubkey2 ;
31
31
32
32
/* Before we can call actual API functions, we need to create a "context". */
33
- rustsecp256k1_v0_8_1_context * ctx = rustsecp256k1_v0_8_1_context_create (SECP256K1_CONTEXT_NONE );
33
+ rustsecp256k1_v0_9_0_context * ctx = rustsecp256k1_v0_9_0_context_create (SECP256K1_CONTEXT_NONE );
34
34
if (!fill_random (randomize , sizeof (randomize ))) {
35
35
printf ("Failed to generate randomness\n" );
36
36
return 1 ;
37
37
}
38
38
/* Randomizing the context is recommended to protect against side-channel
39
- * leakage See `rustsecp256k1_v0_8_1_context_randomize ` in secp256k1.h for more
39
+ * leakage See `rustsecp256k1_v0_9_0_context_randomize ` in secp256k1.h for more
40
40
* information about it. This should never fail. */
41
- return_val = rustsecp256k1_v0_8_1_context_randomize (ctx , randomize );
41
+ return_val = rustsecp256k1_v0_9_0_context_randomize (ctx , randomize );
42
42
assert (return_val );
43
43
44
44
/*** Key Generation ***/
@@ -51,27 +51,27 @@ int main(void) {
51
51
printf ("Failed to generate randomness\n" );
52
52
return 1 ;
53
53
}
54
- if (rustsecp256k1_v0_8_1_ec_seckey_verify (ctx , seckey1 ) && rustsecp256k1_v0_8_1_ec_seckey_verify (ctx , seckey2 )) {
54
+ if (rustsecp256k1_v0_9_0_ec_seckey_verify (ctx , seckey1 ) && rustsecp256k1_v0_9_0_ec_seckey_verify (ctx , seckey2 )) {
55
55
break ;
56
56
}
57
57
}
58
58
59
59
/* Public key creation using a valid context with a verified secret key should never fail */
60
- return_val = rustsecp256k1_v0_8_1_ec_pubkey_create (ctx , & pubkey1 , seckey1 );
60
+ return_val = rustsecp256k1_v0_9_0_ec_pubkey_create (ctx , & pubkey1 , seckey1 );
61
61
assert (return_val );
62
- return_val = rustsecp256k1_v0_8_1_ec_pubkey_create (ctx , & pubkey2 , seckey2 );
62
+ return_val = rustsecp256k1_v0_9_0_ec_pubkey_create (ctx , & pubkey2 , seckey2 );
63
63
assert (return_val );
64
64
65
65
/* Serialize pubkey1 in a compressed form (33 bytes), should always return 1 */
66
66
len = sizeof (compressed_pubkey1 );
67
- return_val = rustsecp256k1_v0_8_1_ec_pubkey_serialize (ctx , compressed_pubkey1 , & len , & pubkey1 , SECP256K1_EC_COMPRESSED );
67
+ return_val = rustsecp256k1_v0_9_0_ec_pubkey_serialize (ctx , compressed_pubkey1 , & len , & pubkey1 , SECP256K1_EC_COMPRESSED );
68
68
assert (return_val );
69
69
/* Should be the same size as the size of the output, because we passed a 33 byte array. */
70
70
assert (len == sizeof (compressed_pubkey1 ));
71
71
72
72
/* Serialize pubkey2 in a compressed form (33 bytes) */
73
73
len = sizeof (compressed_pubkey2 );
74
- return_val = rustsecp256k1_v0_8_1_ec_pubkey_serialize (ctx , compressed_pubkey2 , & len , & pubkey2 , SECP256K1_EC_COMPRESSED );
74
+ return_val = rustsecp256k1_v0_9_0_ec_pubkey_serialize (ctx , compressed_pubkey2 , & len , & pubkey2 , SECP256K1_EC_COMPRESSED );
75
75
assert (return_val );
76
76
/* Should be the same size as the size of the output, because we passed a 33 byte array. */
77
77
assert (len == sizeof (compressed_pubkey2 ));
@@ -80,12 +80,12 @@ int main(void) {
80
80
81
81
/* Perform ECDH with seckey1 and pubkey2. Should never fail with a verified
82
82
* seckey and valid pubkey */
83
- return_val = rustsecp256k1_v0_8_1_ecdh (ctx , shared_secret1 , & pubkey2 , seckey1 , NULL , NULL );
83
+ return_val = rustsecp256k1_v0_9_0_ecdh (ctx , shared_secret1 , & pubkey2 , seckey1 , NULL , NULL );
84
84
assert (return_val );
85
85
86
86
/* Perform ECDH with seckey2 and pubkey1. Should never fail with a verified
87
87
* seckey and valid pubkey */
88
- return_val = rustsecp256k1_v0_8_1_ecdh (ctx , shared_secret2 , & pubkey1 , seckey2 , NULL , NULL );
88
+ return_val = rustsecp256k1_v0_9_0_ecdh (ctx , shared_secret2 , & pubkey1 , seckey2 , NULL , NULL );
89
89
assert (return_val );
90
90
91
91
/* Both parties should end up with the same shared secret */
@@ -104,7 +104,7 @@ int main(void) {
104
104
print_hex (shared_secret1 , sizeof (shared_secret1 ));
105
105
106
106
/* This will clear everything from the context and free the memory */
107
- rustsecp256k1_v0_8_1_context_destroy (ctx );
107
+ rustsecp256k1_v0_9_0_context_destroy (ctx );
108
108
109
109
/* It's best practice to try to clear secrets from memory after using them.
110
110
* This is done because some bugs can allow an attacker to leak memory, for
0 commit comments