secp256k1
elliptic-curve
P
N
A
B
secp256k1
point
point-to-string
string-to-point
on-curve?
G
I
add-point
rmul-point
8.12

secp256k1🔗ℹ

Mohamed Amine LEGHERABA <mohamed.amine.legheraba@gmail.com>

 (require secp256k1) package: secp256k1

struct

(struct elliptic-curve (a b field))

  a : field-element?
  b : field-element?
  field : integer?
An elliptic curve, with each element respecting y^2 = x^3 + ax + b. The elliptic curve is defined over a finite field

value

P : integer?

 = 115792089237316195423570985008687907853269984665640564039457584007908834671663
Prime of the field. value = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F"

value

N : integer?

 = 115792089237316195423570985008687907852837564279074904382605163141518161494337
Max val on the curve. value = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141"

value

A : field-element = (field-element 0 P)

The parameter A of the curve secp256k1. A = 0 mod P.

value

B : field-element = (field-element 7 P)

The parameter B of the curve secp256k1. A = 7 mod P.

The curve secp256k1.

struct

(struct point (x y curve))

  x : field-element?
  y : field-element?
  curve : elliptic-curve?
A point (x,y) on the curve

procedure

(point-to-string point)  string?

  point : point?
Display a point element (concatenation of the x and y values, in hexadecimal)

procedure

(string-to-point point-hex #:curve curve?)  point?

  point-hex : string?
  curve? : secp256k1
Return a point from a hexadecimal string and a curve

procedure

(on-curve? point-val)  boolean?

  point-val : point?
Return true if y^2 = x^3 + ax + b

value

G : point

 = 
(point (field-element
55066263022277343669578718895168534326250603453777594175500187360389116729240
P)
(field-element
 32670510020758816978083085130507043184471273380659243275938904335757337482424
 P)
secp256k1)
The generator of the curve.

value

I : point = (point null null secp256k1)

The "0" point of the curve, or point at infinity.

procedure

(add-point point1 point2)  point?

  point1 : point?
  point2 : point?
Return point1 + point2, according to the addition rules for the elliptic curve secp256k1.

procedure

(rmul-point value scalar)  point?

  value : point?
  scalar : integer?
Return value * scalar. Implemented as cumulative addition of the point with itself.