Class: Secp256k1::SchnorrSignature
- Inherits:
-
Object
- Object
- Secp256k1::SchnorrSignature
- Defined in:
- ext/rbsecp256k1/rbsecp256k1.c
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_data(in_data) ⇒ Object
1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 |
# File 'ext/rbsecp256k1/rbsecp256k1.c', line 1376
static VALUE
SchnorrSignature_from_data(VALUE klass, VALUE in_data)
{
SchnorrSignature* sig;
VALUE result;
unsigned char* schnorr_data;
Check_Type(in_data, T_STRING);
if (RSTRING_LEN(in_data) != SCHNORR_SIG_SIZE_BYTES)
{
rb_raise(Secp256k1_DeserializationError_class, "schnorr signature data must be 64 bytes in length");
return Qnil;
}
schnorr_data = (unsigned char*)StringValuePtr(in_data);
result = SchnorrSignature_alloc(Secp256k1_SchnorrSignature_class);
TypedData_Get_Struct(result, SchnorrSignature, &SchnorrSignature_DataType, sig);
memcpy(sig->sig, schnorr_data, SCHNORR_SIG_SIZE_BYTES);
return result;
}
|
Instance Method Details
#==(other) ⇒ Object
1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 |
# File 'ext/rbsecp256k1/rbsecp256k1.c', line 1430
static VALUE
SchnorrSignature_equals(VALUE self, VALUE other)
{
SchnorrSignature *lhs;
SchnorrSignature *rhs;
TypedData_Get_Struct(self, SchnorrSignature, &SchnorrSignature_DataType, lhs);
TypedData_Get_Struct(other, SchnorrSignature, &SchnorrSignature_DataType, rhs);
if (memcmp(lhs->sig, rhs->sig, SCHNORR_SIG_SIZE_BYTES) == 0)
{
return Qtrue;
}
return Qfalse;
}
|
#serialized ⇒ Object
1400 1401 1402 1403 1404 1405 1406 1407 1408 |
# File 'ext/rbsecp256k1/rbsecp256k1.c', line 1400
static VALUE
SchnorrSignature_serialized(VALUE self)
{
SchnorrSignature *schnorr_sig;
TypedData_Get_Struct(self, SchnorrSignature, &SchnorrSignature_DataType, schnorr_sig);
return rb_str_new((char*)schnorr_sig->sig, SCHNORR_SIG_SIZE_BYTES);
}
|
#verify(in_message, in_xonly_pubkey) ⇒ Object
1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 |
# File 'ext/rbsecp256k1/rbsecp256k1.c', line 1410
static VALUE
SchnorrSignature_verify(VALUE self, VALUE in_message, VALUE in_xonly_pubkey)
{
XOnlyPublicKey *xonly_pubkey;
SchnorrSignature *schnorr_sig;
unsigned char* msg;
TypedData_Get_Struct(self, SchnorrSignature, &SchnorrSignature_DataType, schnorr_sig);
TypedData_Get_Struct(in_xonly_pubkey, XOnlyPublicKey, &XOnlyPublicKey_DataType, xonly_pubkey);
Check_Type(in_message, T_STRING);
msg = (unsigned char*)StringValuePtr(in_message);
if (secp256k1_schnorrsig_verify(secp256k1_context_static, schnorr_sig->sig, msg, RSTRING_LEN(in_message), &xonly_pubkey->pubkey) != 1)
{
return Qfalse;
}
return Qtrue;
}
|