Class: Secp256k1::XOnlyPublicKey
- Inherits:
-
Object
- Object
- Secp256k1::XOnlyPublicKey
- Defined in:
- ext/rbsecp256k1/rbsecp256k1.c
Class Method Summary collapse
-
.from_data(in_xonly_public_key_serialized) ⇒ Secp256k1::XOnlyPublicKey
Loads an x-only public key from serialized data.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compare two x-only public keys.
-
#serialized ⇒ String
Returns the 32-byte serialized version of this x-only public key.
Class Method Details
.from_data(in_xonly_public_key_serialized) ⇒ Secp256k1::XOnlyPublicKey
Loads an x-only public key from serialized data.
data.
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
# File 'ext/rbsecp256k1/rbsecp256k1.c', line 458
static VALUE
XOnlyPublicKey_from_data(VALUE klass, VALUE in_xonly_public_key_serialized)
{
unsigned char *xonly_pubkey_data;
Check_Type(in_xonly_public_key_serialized, T_STRING);
if (RSTRING_LEN(in_xonly_public_key_serialized) != 32)
{
rb_raise(Secp256k1_DeserializationError_class, "x-only public key data must be 32 bytes in length");
return Qnil;
}
xonly_pubkey_data = (unsigned char*)StringValuePtr(in_xonly_public_key_serialized);
return XOnlyPublicKey_create_from_data(xonly_pubkey_data);
}
|
Instance Method Details
#==(other) ⇒ Boolean
Compare two x-only public keys.
503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
# File 'ext/rbsecp256k1/rbsecp256k1.c', line 503
static VALUE
XOnlyPublicKey_equals(VALUE self, VALUE other)
{
XOnlyPublicKey *lhs;
XOnlyPublicKey *rhs;
TypedData_Get_Struct(self, XOnlyPublicKey, &XOnlyPublicKey_DataType, lhs);
TypedData_Get_Struct(other, XOnlyPublicKey, &XOnlyPublicKey_DataType, rhs);
if (secp256k1_xonly_pubkey_cmp(secp256k1_context_static, &lhs->pubkey, &rhs->pubkey) == 0)
{
return Qtrue;
}
return Qfalse;
}
|
#serialized ⇒ String
Returns the 32-byte serialized version of this x-only public key.
key.
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
# File 'ext/rbsecp256k1/rbsecp256k1.c', line 480
static VALUE
XOnlyPublicKey_serialized(VALUE self)
{
XOnlyPublicKey* xonly_pubkey;
unsigned char out[SERIALIZED_XONLY_PUBKEY_SIZE_BYTES];
TypedData_Get_Struct(self, XOnlyPublicKey, &XOnlyPublicKey_DataType, xonly_pubkey);
if (secp256k1_xonly_pubkey_serialize(secp256k1_context_static, out, &xonly_pubkey->pubkey) != 1)
{
rb_raise(Secp256k1_SerializationError_class, "failed to serialize x-only public key");
return Qnil;
}
return rb_str_new((char*)out, SERIALIZED_XONLY_PUBKEY_SIZE_BYTES);
}
|