p256

package
v0.0.0-...-e51f1a5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package p256 Encapsulates secP256k1 elliptic curve.

Index

Constants

This section is empty.

Variables

View Source
var (
	CURVE = S256()
)

Functions

func F

func F(x *big.Int) (*big.Int, error)

F receives a big integer x as input and return x^3 + 7 mod ORDER.

func HashToInt

func HashToInt(b bytes.Buffer) (*big.Int, error)

Hash is responsible for the computing a Zp element given the input string.

Types

type MyBitCurve

type MyBitCurve struct {
	secp256k1.BitCurve
}

func S256

func S256() *MyBitCurve

S256 returns a BitCurve which implements secp256k1.

func (*MyBitCurve) Add

func (BitCurve *MyBitCurve) Add(x1, y1, x2, y2 *big.Int) (*big.Int, *big.Int)

Add returns the sum of (x1,y1) and (x2,y2)

type P256

type P256 struct {
	X, Y *big.Int
}

Elliptic Curve Point struct.

func MapToGroup

func MapToGroup(m string) (*P256, error)

MapToGroup is a hash function that returns a valid elliptic curve point given as input a string. It is also known as hash-to-point and is used to obtain a generator that has no discrete logarithm known relation, thus addressing the concept of NUMS (nothing up my sleeve). This implementation is based on the paper: Short signatures from the Weil pairing Boneh, Lynn and Shacham Journal of Cryptology, September 2004, Volume 17, Issue 4, pp 297–319

func (*P256) Add

func (p *P256) Add(a, b *P256) *P256

Input points must be distinct

func (*P256) Double

func (p *P256) Double(a *P256) *P256

Double returns 2*P, where P is the given elliptic curve point.

func (*P256) IsOnCurve

func (p *P256) IsOnCurve() bool

IsOnCurve returns TRUE if and only if p has coordinates X and Y that satisfy the Elliptic Curve equation: y^2 = x^3 + 7.

func (*P256) IsZero

func (p *P256) IsZero() bool

IsZero returns true if and only if the elliptic curve point is the point at infinity.

func (*P256) Multiply

func (p *P256) Multiply(a, b *P256) *P256

Multiply actually is reponsible for the addition of elliptic curve points. The name here is to maintain compatibility with bn256 interface. This algorithm verifies if the given elliptic curve points are equal, in which case it returns the result of Double function, otherwise it returns the result of Add function.

func (*P256) Neg

func (p *P256) Neg(a *P256) *P256

Neg returns the inverse of the given elliptic curve point.

func (*P256) ScalarBaseMult

func (p *P256) ScalarBaseMult(n *big.Int) *P256

ScalarBaseMult returns the Scalar Multiplication by the base generator.

func (*P256) ScalarMult

func (p *P256) ScalarMult(a *P256, n *big.Int) *P256

ScalarMul encapsulates the scalar Multiplication Algorithm from secP256k1.

func (*P256) SetInfinity

func (p *P256) SetInfinity() *P256

SetInfinity sets the given elliptic curve point to the point at infinity.

func (*P256) String

func (p *P256) String() string

String returns the readable representation of the given elliptic curve point, i.e. the tuple formed by X and Y coordinates.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL