7 #ifndef SECP256K1_ECKEY_IMPL_H 8 #define SECP256K1_ECKEY_IMPL_H 17 static int secp256k1_eckey_pubkey_parse(
secp256k1_ge *elem,
const unsigned char *pub,
size_t size) {
21 }
else if (size == 65 && (pub[0] == 0x04 || pub[0] == 0x06 || pub[0] == 0x07)) {
23 if (!secp256k1_fe_set_b32(&x, pub+1) || !secp256k1_fe_set_b32(&y, pub+33)) {
26 secp256k1_ge_set_xy(elem, &x, &y);
31 return secp256k1_ge_is_valid_var(elem);
37 static int secp256k1_eckey_pubkey_serialize(
secp256k1_ge *elem,
unsigned char *pub,
size_t *size,
int compressed) {
38 if (secp256k1_ge_is_infinity(elem)) {
41 secp256k1_fe_normalize_var(&elem->
x);
42 secp256k1_fe_normalize_var(&elem->
y);
43 secp256k1_fe_get_b32(&pub[1], &elem->
x);
50 secp256k1_fe_get_b32(&pub[33], &elem->
y);
56 secp256k1_scalar_add(key, key, tweak);
57 if (secp256k1_scalar_is_zero(key)) {
66 secp256k1_gej_set_ge(&pt, key);
67 secp256k1_scalar_set_int(&one, 1);
68 secp256k1_ecmult(ctx, &pt, &pt, &one, tweak);
70 if (secp256k1_gej_is_infinity(&pt)) {
73 secp256k1_ge_set_gej(key, &pt);
78 if (secp256k1_scalar_is_zero(tweak)) {
82 secp256k1_scalar_mul(key, key, tweak);
89 if (secp256k1_scalar_is_zero(tweak)) {
93 secp256k1_scalar_set_int(&zero, 0);
94 secp256k1_gej_set_ge(&pt, key);
95 secp256k1_ecmult(ctx, &pt, &pt, tweak, &zero);
96 secp256k1_ge_set_gej(key, &pt);
#define SECP256K1_TAG_PUBKEY_HYBRID_EVEN
A group element of the secp256k1 curve, in jacobian coordinates.
#define SECP256K1_TAG_PUBKEY_UNCOMPRESSED
#define SECP256K1_TAG_PUBKEY_ODD
A group element of the secp256k1 curve, in affine coordinates.
A scalar modulo the group order of the secp256k1 curve.
#define SECP256K1_TAG_PUBKEY_HYBRID_ODD
uint8_t const size_t const size
#define SECP256K1_TAG_PUBKEY_EVEN
Prefix byte used to tag various encoded curvepoints for specific purposes.