secp256k1

package
v0.9.10 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 14 Imported by: 2

Documentation

Overview

Package secp256k1 is an implementation of the kyber.{Group,Point,Scalar} //////////////////////////////////////////////////////////////////////////////

XXX: Do not use in production until this code has been audited.

////////////////////////////////////////////////////////////////////////////// interfaces, based on btcd/btcec and kyber/group/mod

XXX: NOT CONSTANT TIME!

Package secp256k1 is an implementation of the kyber.{Group,Point,Scalar} //////////////////////////////////////////////////////////////////////////////

XXX: Do not use in production until this code has been audited.

////////////////////////////////////////////////////////////////////////////// interfaces, based on btcd/btcec and kyber/group/mod

XXX: NOT CONSTANT TIME!

Package secp256k1 is an implementation of the kyber.{Group,Point,Scalar} //////////////////////////////////////////////////////////////////////////////

XXX: Do not use in production until this code has been audited.

////////////////////////////////////////////////////////////////////////////// interfaces, based on btcd/btcec and kyber/group/mod

XXX: NOT CONSTANT TIME!

Package secp256k1 is an implementation of the kyber.{Group,Point,Scalcar} //////////////////////////////////////////////////////////////////////////////

XXX: Do not use in production until this code has been audited.

////////////////////////////////////////////////////////////////////////////// interfaces, based on btcd/btcec and kyber/group/mod

XXX: NOT CONSTANT TIME!

Package secp256k1 is an implementation of the kyber.{Group,Point,Scalar} //////////////////////////////////////////////////////////////////////////////

XXX: Do not use in production until this code has been audited.

////////////////////////////////////////////////////////////////////////////// interfaces, based on btcd/btcec and kyber/group/mod

XXX: NOT CONSTANT TIME!

Index

Constants

This section is empty.

Variables

View Source
var GroupOrder = secp256k1BTCD.S256().N

Functions

func Coordinates

func Coordinates(p kyber.Point) (*big.Int, *big.Int)

Coordinates returns the coordinates of p

func EthereumAddress

func EthereumAddress(p kyber.Point) (rv [20]byte)

EthereumAddress returns the 160-bit address corresponding to p as public key.

func Generate

func Generate(random cipher.Stream) *key.Pair

Generate generates a public/private key pair, which can be verified cheaply on-chain

func IntToScalar

func IntToScalar(i *big.Int) kyber.Scalar

IntToScalar returns i wrapped as a big.Int.

May modify i to reduce mod GroupOrder

func IsSecp256k1Point

func IsSecp256k1Point(p kyber.Point) bool

IsSecp256k1Point returns true if p is a secp256k1Point

func IsSecp256k1Scalar

func IsSecp256k1Scalar(s kyber.Scalar) bool

IsSecp256k1Scalar returns true if p is a secp256k1Scalar

func LongMarshal

func LongMarshal(p kyber.Point) []byte

LongMarshal returns the concatenated coordinates serialized as uint256's

func LongUnmarshal added in v0.8.2

func LongUnmarshal(m []byte) (kyber.Point, error)

LongUnmarshal returns the secp256k1 point represented by m, as a concatenated pair of uint256's

func RepresentsScalar

func RepresentsScalar(i *big.Int) bool

RepresentsScalar returns true iff i is in the right range to be a scalar

func ScalarToHash added in v0.8.2

func ScalarToHash(s kyber.Scalar) common.Hash

func ScalarToPublicPoint added in v0.8.2

func ScalarToPublicPoint(s kyber.Scalar) kyber.Point

ScalarToPublicPoint returns the public secp256k1 point associated to s

func SetCoordinates

func SetCoordinates(x, y *big.Int) kyber.Point

SetCoordinates returns the point (x,y), or panics if an invalid secp256k1Point

func ToInt

func ToInt(s kyber.Scalar) *big.Int

func ValidPublicKey

func ValidPublicKey(p kyber.Point) bool

ValidPublicKey returns true iff p can be used in the optimized on-chain Schnorr-signature verification. See SchnorrSECP256K1.sol for details.

Types

type Secp256k1

type Secp256k1 struct{}

Secp256k1 represents the secp256k1 group. There are no parameters and no initialization is required because it supports only this one specific curve.

func (*Secp256k1) Point

func (*Secp256k1) Point() kyber.Point

Point returns a new secp256k1 point

func (*Secp256k1) PointLen

func (*Secp256k1) PointLen() int

PointLen returns the length of a marshalled Point

func (*Secp256k1) Scalar

func (*Secp256k1) Scalar() kyber.Scalar

Scalar creates a new Scalar for the prime-order group on the secp256k1 curve

func (*Secp256k1) ScalarLen

func (*Secp256k1) ScalarLen() int

ScalarLen returns the length of a marshalled Scalar

func (*Secp256k1) String

func (*Secp256k1) String() string

String returns the name of the curve

type SuiteSecp256k1

type SuiteSecp256k1 struct {
	Secp256k1
	// contains filtered or unexported fields
}

SuiteSecp256k1 implements some basic functionalities such as Group, HashFactory, and XOFFactory.

func NewBlakeKeccackSecp256k1

func NewBlakeKeccackSecp256k1() *SuiteSecp256k1

NewBlakeKeccackSecp256k1 returns a cipher suite based on package go.dedis.ch/kyber/xof/blake2xb, SHA-256, and the secp256k1 curve. It produces cryptographically secure random numbers via package crypto/rand.

func (*SuiteSecp256k1) Hash

func (s *SuiteSecp256k1) Hash() hash.Hash

Hash returns a newly instantiated keccak hash function.

func (*SuiteSecp256k1) New

func (s *SuiteSecp256k1) New(t reflect.Type) interface{}

New implements the kyber.Encoding interface, and returns a new element of type t, which can be a Point or a Scalar

func (*SuiteSecp256k1) RandomStream

func (s *SuiteSecp256k1) RandomStream() cipher.Stream

RandomStream returns a cipher.Stream that returns a key stream from crypto/rand.

func (*SuiteSecp256k1) Read

func (s *SuiteSecp256k1) Read(r io.Reader, objs ...interface{}) error

Read implements the Encoding interface function, and reads a series of objs from r The objs must all be pointers

func (*SuiteSecp256k1) Write

func (s *SuiteSecp256k1) Write(w io.Writer, objs ...interface{}) error

Write implements the Encoding interface, and writes the objs to r using their built-in binary serializations. Supports Points, Scalars, fixed-length data types supported by encoding/binary/Write(), and structs, arrays, and slices containing these types.

func (*SuiteSecp256k1) XOF

func (s *SuiteSecp256k1) XOF(key []byte) kyber.XOF

XOF returns an XOR function, implemented via the Blake2b hash.

This should only be used for generating secrets, so there is no need to make it cheap to compute on-chain.

Jump to

Keyboard shortcuts

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