class Secp256k1::Keypair

Overview

Implements a Secp256k1 key pair containing a private and a public key.

Properties:

key = Secp256k1::Keypair.new
key.get_secret
# => "53d77137b39427a35d8c4b187f532d3912e1e7135985e730633e1e3c1b87ce97"
key.to_s
# => "e097fc69f0b92f711620511c07fefdd648e469df46b1e4385a00a1786f6bc55b7d9011bb589e883d8a7947cfb37dc6b3c8beae9c614cab4a83009bd9d8732a9f"

Defined in:

structs.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(private_key : BigInt) #

Generates a new keypair using a provided private key.

Parameters:

  • #private_key (BigInt): the secret as known as the private key.
key = Secp256k1::Keypair.new BigInt.new("53d77137b39427a35d8c4b187f532d3912e1e7135985e730633e1e3c1b87ce97", 16)
# => #<Secp256k1::Keypair:0x7f8be5611d80>

[View source]
def self.new #

Generates a new keypair using a fresh random private key.

key = Secp256k1::Keypair.new
# => #<Secp256k1::Keypair:0x7f8be5611d80>

[View source]

Instance Method Detail

def get_secret #

Gets the private key as hexadecimal formatted string literal.

key.get_secret
# => "53d77137b39427a35d8c4b187f532d3912e1e7135985e730633e1e3c1b87ce97"

[View source]
def private_key : BigInt #

The secret as known as the private key.


[View source]
def private_key=(private_key : BigInt) #

The secret as known as the private key.


[View source]
def public_key : EC_Point #

The point on the elliptic curve as known as the public key.


[View source]
def public_key=(public_key : EC_Point) #

The point on the elliptic curve as known as the public key.


[View source]
def to_s #

Gets the key formatted as uncompressed public key string.

key.to_s
# => "e097fc69f0b92f711620511c07fefdd648e469df46b1e4385a00a1786f6bc55b7d9011bb589e883d8a7947cfb37dc6b3c8beae9c614cab4a83009bd9d8732a9f"

[View source]