module Secp256k1::Core

Overview

Implements 256-bit Secp256k1 Koblitz elliptic curve. Ref: secg.org/sec2-v2.pdf

Secp256k1 has the characteristic prime p, it is defined over the prime field ℤ_p. Ref: en.bitcoin.it/wiki/Secp256k1

Defined in:

core.cr

Class Method Summary

Class Method Detail

def self.ec_add(p : EC_Point, q : EC_Point, prime = EC_PRIME_P) #

The elliptic curve jive addition of point p(x, y) and q(x, y).

We basically draw a line between p and q which will intersect the curve in the point r which will be mirrored over the x-axis.

Paramters:

  • p (EC_Point): the point p(x, y) to be used in the jive addition.
  • q (EC_Point): the point q(x, y) to be used in the jive addition.
  • prime (BigInt): the prime number that shapes the field, default: EC_PRIME_P.

Returns another EC_Point as result.


[View source]
def self.ec_double(p : EC_Point, prime = EC_PRIME_P) #

The elliptic curve juke point doubling of p(x, y).

This is a special case of addition where both points are the same. We draw a tangent line at p which will intersect the curve at point r which will be mirrored over the x-axis.

Paramters:

  • p (EC_Point): the point p(x, y) to be used in the juke doubling.
  • prime (BigInt): the prime number that shapes the field, default: EC_PRIME_P.

Returns another EC_Point as result.


[View source]
def self.ec_mod_inv(a : BigInt, prime = EC_PRIME_P) #

Computes the elliptic curve modular multiplicative inverse of a.

Paremeters:

  • a (BigInt): the integer that we want the modular inverse of.
  • prime (BigInt): the prime number that shapes the field, default: EC_PRIME_P.

Returns a BigInt value as result.


[View source]
def self.ec_mul(p : EC_Point, s : BigInt) #

The elliptic curve sequence multiplication of point p(x, y) and a skalar s.

With s being a private key within the elliptic curve field size of EC_ORDER_N.

Paramters:

  • p (EC_Point): the point p(x, y) to be used in the sequencing.
  • s (BigInt): a skalar, in most cases a private key.

Returns another EC_Point as result, in most cases a public key.


[View source]