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
- Variables
- func Coordinates(p kyber.Point) (*big.Int, *big.Int)
- func EthereumAddress(p kyber.Point) (rv [20]byte)
- func Generate(random cipher.Stream) *key.Pair
- func IntToScalar(i *big.Int) kyber.Scalar
- func IsSecp256k1Point(p kyber.Point) bool
- func IsSecp256k1Scalar(s kyber.Scalar) bool
- func LongMarshal(p kyber.Point) []byte
- func LongUnmarshal(m []byte) (kyber.Point, error)
- func RepresentsScalar(i *big.Int) bool
- func ScalarToHash(s kyber.Scalar) common.Hash
- func ScalarToPublicPoint(s kyber.Scalar) kyber.Point
- func SetCoordinates(x, y *big.Int) kyber.Point
- func ToInt(s kyber.Scalar) *big.Int
- func ValidPublicKey(p kyber.Point) bool
- type PublicKey
- func (k *PublicKey) Address() common.Address
- func (k *PublicKey) Hash() (common.Hash, error)
- func (k *PublicKey) IsZero() bool
- func (k PublicKey) MarshalText() ([]byte, error)
- func (k *PublicKey) MustHash() common.Hash
- func (k *PublicKey) Point() (kyber.Point, error)
- func (k *PublicKey) Scan(value interface{}) error
- func (k *PublicKey) Set(l PublicKey)
- func (k *PublicKey) SetFromHex(hex string) error
- func (k PublicKey) String() string
- func (k *PublicKey) StringUncompressed() (string, error)
- func (k *PublicKey) UnmarshalText(text []byte) error
- func (k PublicKey) Value() (driver.Value, error)
- type Secp256k1
- type SuiteSecp256k1
- func (s *SuiteSecp256k1) Hash() hash.Hash
- func (s *SuiteSecp256k1) New(t reflect.Type) interface{}
- func (s *SuiteSecp256k1) RandomStream() cipher.Stream
- func (s *SuiteSecp256k1) Read(r io.Reader, objs ...interface{}) error
- func (s *SuiteSecp256k1) Write(w io.Writer, objs ...interface{}) error
- func (s *SuiteSecp256k1) XOF(key []byte) kyber.XOF
Constants ¶
const CompressedPublicKeyLength = 33
CompressedPublicKeyLength is the length of a secp256k1 public key's x coordinate as a uint256, concatenated with 00 if y is even, 01 if odd.
Variables ¶
var FieldSize = secp256k1BTCD.S256().P
var GroupOrder = secp256k1BTCD.S256().N
Functions ¶
func Coordinates ¶
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 ¶
Generate generates a public/private key pair, which can be verified cheaply on-chain
func IntToScalar ¶
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
LongUnmarshal returns the secp256k1 point represented by m, as a concatenated pair of uint256's
func RepresentsScalar ¶
RepresentsScalar returns true iff i is in the right range to be a scalar
func ScalarToHash ¶ added in v0.8.2
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 ¶
SetCoordinates returns the point (x,y), or panics if an invalid secp256k1Point
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 PublicKey ¶ added in v0.10.8
type PublicKey [CompressedPublicKeyLength]byte
PublicKey is a secp256k1 point in compressed format
func NewPublicKeyFromBytes ¶ added in v1.2.0
NewPublicKeyFromBytes returns the PublicKey built from the given bytes, or errors
func NewPublicKeyFromHex ¶ added in v0.10.8
NewPublicKeyFromHex returns the PublicKey encoded by 0x-hex string hex, or errors
func (*PublicKey) Address ¶ added in v0.10.8
Address returns the Ethereum address of k or 0 if the key is invalid
func (*PublicKey) Hash ¶ added in v0.10.8
Hash returns the solidity Keccak256 hash of k. Corresponds to hashOfKey on VRFCoordinator.
func (*PublicKey) IsZero ¶ added in v0.10.8
IsZero returns true iff k is the zero value for PublicKey
func (PublicKey) MarshalText ¶ added in v0.10.8
MarshalText renders k as a text string
func (*PublicKey) MustHash ¶ added in v0.10.8
MustHash is like Hash, but panics on error. Useful for testing.
func (*PublicKey) SetFromHex ¶ added in v0.10.8
SetFromHex sets k to the public key represented by hex, which must represent the compressed binary format
func (PublicKey) String ¶ added in v0.10.8
String returns k's binary compressed representation, as 0x-hex
func (*PublicKey) StringUncompressed ¶ added in v0.10.8
StringUncompressed returns k's binary uncompressed representation, as 0x-hex
func (*PublicKey) UnmarshalText ¶ added in v0.10.8
UnmarshalText reads a PublicKey into k from text, or errors
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) Scalar ¶
func (*Secp256k1) Scalar() kyber.Scalar
Scalar creates a new Scalar for the prime-order group on the secp256k1 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.