crypto

package
v2.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlattenECPoints

func FlattenECPoints(in []*ECPoint) ([]*big.Int, error)

FlattenECPoints serializes a slice of ECPoints into a flat slice of big.Int coordinates (x1, y1, x2, y2, ...).

func GenerateNTildei

func GenerateNTildei(rand io.Reader, safePrimes [2]*big.Int) (NTildei, h1i, h2i *big.Int, err error)

GenerateNTildei computes NTilde = p*q from two safe primes and returns NTilde along with two random generators of the quadratic residue group.

Types

type ECPoint

type ECPoint struct {
	// contains filtered or unexported fields
}

ECPoint convenience helper

func NewECPoint

func NewECPoint(curve elliptic.Curve, X, Y *big.Int) (*ECPoint, error)

Creates a new ECPoint and checks that the given coordinates are on the elliptic curve.

func NewECPointNoCurveCheck

func NewECPointNoCurveCheck(curve elliptic.Curve, X, Y *big.Int) *ECPoint

Creates a new ECPoint without checking that the coordinates are on the elliptic curve. Only use this function when you are completely sure that the point is already on the curve.

func ScalarBaseMult

func ScalarBaseMult(curve elliptic.Curve, k *big.Int) *ECPoint

ScalarBaseMult returns k*G where G is the base point of the given curve.

func UnFlattenECPoints

func UnFlattenECPoints(curve elliptic.Curve, in []*big.Int, noCurveCheck ...bool) ([]*ECPoint, error)

UnFlattenECPoints reconstructs a slice of ECPoints from a flat slice of big.Int coordinate pairs.

func (*ECPoint) Add

func (p *ECPoint) Add(p1 *ECPoint) (*ECPoint, error)

Add returns the sum of p and p1 on the elliptic curve.

func (*ECPoint) Curve

func (p *ECPoint) Curve() elliptic.Curve

Curve returns the elliptic curve on which the point is defined.

func (*ECPoint) EightInvEight

func (p *ECPoint) EightInvEight() *ECPoint

EightInvEight multiplies the point by 8 and then by the modular inverse of 8 (used for cofactor clearing on Ed25519).

func (*ECPoint) Equals

func (p *ECPoint) Equals(p2 *ECPoint) bool

Equals reports whether p and p2 represent the same point.

func (*ECPoint) GobDecode

func (p *ECPoint) GobDecode(buf []byte) error

GobDecode implements the gob.GobDecoder interface for ECPoint.

func (*ECPoint) GobEncode

func (p *ECPoint) GobEncode() ([]byte, error)

GobEncode implements the gob.GobEncoder interface for ECPoint.

func (*ECPoint) IsOnCurve

func (p *ECPoint) IsOnCurve() bool

IsOnCurve reports whether the point lies on its elliptic curve.

func (*ECPoint) MarshalJSON

func (p *ECPoint) MarshalJSON() ([]byte, error)

crypto.ECPoint is not inherently json marshal-able

func (*ECPoint) ScalarMult

func (p *ECPoint) ScalarMult(k *big.Int) *ECPoint

ScalarMult returns the result of multiplying the point by the scalar k.

func (*ECPoint) SetCurve

func (p *ECPoint) SetCurve(curve elliptic.Curve) *ECPoint

SetCurve sets the curve of the point and returns the modified point.

func (*ECPoint) ToECDSAPubKey

func (p *ECPoint) ToECDSAPubKey() *ecdsa.PublicKey

ToECDSAPubKey converts the ECPoint to a standard library ECDSA public key.

func (*ECPoint) ToEd25519PubKey added in v2.1.4

func (p *ECPoint) ToEd25519PubKey() *edwards25519.PublicKey

ToEd25519PubKey returns a github.com/ModChain/edwards25519.PublicKey object for this public key or nil if this is not a ed25519 key.

func (*ECPoint) ToSecp256k1PubKey added in v2.1.1

func (p *ECPoint) ToSecp256k1PubKey() *secp256k1.PublicKey

ToSecp256k1PubKey returns a github.com/ModChain/secp256k1.PublicKey object for this public key or nil if this is not a secp256k1 key.

func (*ECPoint) UnmarshalJSON

func (p *ECPoint) UnmarshalJSON(payload []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for ECPoint.

func (*ECPoint) ValidateBasic

func (p *ECPoint) ValidateBasic() bool

ValidateBasic checks that the point is non-nil, has non-nil coordinates, and lies on its curve.

func (*ECPoint) X

func (p *ECPoint) X() *big.Int

X returns a copy of the point's X coordinate.

func (*ECPoint) Y

func (p *ECPoint) Y() *big.Int

Y returns a copy of the point's Y coordinate.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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