ec

package
v0.0.0-...-ee1bab5 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 2 Imported by: 0

README

Elliptic curve

This package contains Go (only) implementation of elliptic curve with equation: y^2 =x^3 + ax + b. It also implements the standard Go elliptic.Curve interface.

The SECP256K1() function returns curve instance with parameters from SEC 2: Recommended Elliptic Curve Domain Parameters.

In the tests you can find the comparison of this implementation and popular Ethereum implementation.

More about (Wiki)

Documentation

Overview

Package ec Copyright 2023 Oleg Fomenko. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Curve

type Curve struct {
	P       *big.Int
	N       *big.Int
	A       *big.Int
	B       *big.Int
	Gx, Gy  *big.Int
	BitSize int
}

Curve implements elliptic curve with equation: y^2 =x^3 + ax + b

func SECP256K1

func SECP256K1() *Curve

SECP256K1 returns an Ethereum secp256k1 curve

func (*Curve) Add

func (c *Curve) Add(x1, y1, x2, y2 *big.Int) (x, y *big.Int)

func (*Curve) Double

func (c *Curve) Double(x1, y1 *big.Int) (x, y *big.Int)

func (*Curve) IsOnCurve

func (c *Curve) IsOnCurve(x, y *big.Int) bool

func (*Curve) Params

func (c *Curve) Params() *elliptic.CurveParams

func (*Curve) ScalarBaseMult

func (c *Curve) ScalarBaseMult(k []byte) (x, y *big.Int)

func (*Curve) ScalarMult

func (c *Curve) ScalarMult(x1, y1 *big.Int, k []byte) (x, y *big.Int)

Jump to

Keyboard shortcuts

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