class Noble::Ed25519::Point

Overview

** Default Point works in affine coordinates: (x, y) /

Defined in:

noble-ed25519.cr

Constant Summary

BASE = Point.new(Noble::Ed25519::Curve::Gx, Noble::Ed25519::Curve::Gy)

Base point aka generator public_key = Point::BASE * private_key

ZERO = Point.new(Zero, One)

Identity point aka point at infinity point = point + zero_point

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(x : BigInt, y : BigInt) #

[View source]

Class Method Detail

def self.fromHex(hex : Hex, strict = true) #

Converts hash string or Bytes to Point. Uses algo from RFC8032 5.1.3.


[View source]
def self.fromPrivateKey(privateKey : PrivKey) #

[View source]

Instance Method Detail

def ==(other : Point) : Bool #

[View source]
def _setWindowSize(windowSize : Int32) #

"Private method", don't use it directly.


[View source]
def _WINDOW_SIZE : Int32 #

We calculate precomputes for elliptic curve point multiplication using windowed method. This specifies window size and stores precomputed values. Usually only base point would be precomputed.


[View source]
def _WINDOW_SIZE=(_WINDOW_SIZE : Int32) #

We calculate precomputes for elliptic curve point multiplication using windowed method. This specifies window size and stores precomputed values. Usually only base point would be precomputed.


[View source]
def add(other : Point) #

[View source]
def equals(other : Point) : Bool #

[View source]
def finialize #

Note: This method is not in the original typescript implementation. This method only exists to retain the WeakMap semantics that were encoded in the original implementation through the use of WeakMap(Point, Array(ExtendedPoint)) in typescript.


[View source]
def isTorsionFree : Bool #

[View source]
def multiply(scalar : Int) : Point #

** Constant time multiplication. @param scalar Big-Endian number @returns new point /


[View source]
def negate #

[View source]
def subtract(other : Point) #

[View source]
def toHex : String #

Same as toRawBytes, but returns string.


[View source]
def toRawBytes : Bytes #

There can always be only two x values (x, -x) for any y When compressing point, it's enough to only store its y coordinate and use the last byte to encode sign of x.


[View source]
def toX25519 : Bytes #

** Converts to Montgomery aka x coordinate of curve25519. We don't have fromX25519, because we don't know sign.

u, v: curve25519 coordinates
x, y: ed25519 coordinates
(u, v) = ((1+y)/(1-y), sqrt(-486664)*u/x)
(x, y) = (sqrt(-486664)*u/v, (u-1)/(u+1))

https://blog.filippo.io/using-ed25519-keys-for-encryption @returns u coordinate of curve25519 point /


[View source]
def x : BigInt #

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

[View source]
def y : BigInt #

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

[View source]