nist

package
v3.1.100 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package nist implements cryptographic groups and ciphersuites based on the NIST standards, using Go's built-in crypto library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QrSuite

type QrSuite struct {
	ResidueGroup
}

QrSuite is a quadratic residue suite

func NewBlakeSHA256QR512

func NewBlakeSHA256QR512() *QrSuite

NewBlakeSHA256QR512 returns a cipher suite based on package github.com/michaljirman/kyber/v3/xof/blake2xb, SHA-256, and a residue group of quadratic residues modulo a 512-bit prime.

This group size should be used only for testing and experimentation. 512-bit DSA-style groups are no longer considered secure.

func (QrSuite) Hash

func (s QrSuite) Hash() hash.Hash

Hash returns the instance associated with the suite

func (*QrSuite) New

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

New implements the kyber.encoding interface

func (QrSuite) RandomStream

func (s QrSuite) RandomStream() cipher.Stream

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

func (*QrSuite) Read

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

func (*QrSuite) Write

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

func (QrSuite) XOF

func (s QrSuite) XOF(key []byte) kyber.XOF

XOF creates the XOF associated with the suite

type ResidueGroup

type ResidueGroup struct {
	dsa.Parameters
	R *big.Int
}

A ResidueGroup represents a DSA-style modular integer arithmetic group, defined by two primes P and Q and an integer R, such that P = Q*R+1. Points in a ResidueGroup are R-residues modulo P, and Scalars are integer exponents modulo the group order Q.

In traditional DSA groups P is typically much larger than Q, and hence use a large multiple R. This is done to minimize the computational cost of modular exponentiation while maximizing security against known classes of attacks: P must be on the order of thousands of bits long while for security Q is believed to require only hundreds of bits. Such computation-optimized groups are suitable for Diffie-Hellman agreement, DSA or ElGamal signatures, etc., which depend on Point.Mul() and homomorphic properties.

However, residue groups with large R are less suitable for public-key cryptographic techniques that require choosing Points pseudo-randomly or to contain embedded data, as required by ElGamal encryption for example. For such purposes quadratic residue groups are more suitable - representing the special case where R=2 and hence P=2Q+1. As a result, the Point.Pick() method should be expected to work efficiently ONLY on quadratic residue groups in which R=2.

func (*ResidueGroup) Order

func (g *ResidueGroup) Order() *big.Int

Order returns the order of this Residue group, namely the prime Q.

func (*ResidueGroup) Point

func (g *ResidueGroup) Point() kyber.Point

Point creates a Point associated with this Residue group, with an initial value of nil.

func (*ResidueGroup) PointLen

func (g *ResidueGroup) PointLen() int

PointLen returns the number of bytes in the encoding of a Point for this Residue group.

func (*ResidueGroup) QuadraticResidueGroup

func (g *ResidueGroup) QuadraticResidueGroup(bitlen uint, rand cipher.Stream)

QuadraticResidueGroup initializes Residue group parameters for a quadratic residue group, by picking primes P and Q such that P=2Q+1 and the smallest valid generator G for this group.

func (*ResidueGroup) Scalar

func (g *ResidueGroup) Scalar() kyber.Scalar

Scalar creates a Scalar associated with this Residue group, with an initial value of nil.

func (*ResidueGroup) ScalarLen

func (g *ResidueGroup) ScalarLen() int

ScalarLen returns the number of bytes in the encoding of a Scalar for this Residue group.

func (*ResidueGroup) SetParams

func (g *ResidueGroup) SetParams(P, Q, R, G *big.Int)

SetParams explicitly initializes a ResidueGroup with given parameters.

func (*ResidueGroup) String

func (g *ResidueGroup) String() string

func (*ResidueGroup) Valid

func (g *ResidueGroup) Valid() bool

Valid validates the parameters for a Residue group, checking that P and Q are prime, P=Q*R+1, and that G is a valid generator for this group.

type Secp256r1

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

P256 implements the kyber.Group interface for the NIST P-256 elliptic curve, based on Go's native elliptic curve library.

func (*Secp256r1) ComputeY

func (c *Secp256r1) ComputeY(x *big.Int) (*big.Int, *big.Int)

func (*Secp256r1) Init

func (curve *Secp256r1) Init() curve

Init initializes standard Curve instances

func (*Secp256r1) Order

func (c *Secp256r1) Order() *big.Int

Return the order of this curve: the prime N in the curve parameters.

func (*Secp256r1) Point

func (c *Secp256r1) Point() kyber.Point

Create a Point associated with this curve.

func (*Secp256r1) PointLen

func (c *Secp256r1) PointLen() int

Return the number of bytes in the encoding of a Point for this curve. Currently uses uncompressed ANSI X9.62 format with both X and Y coordinates; this could change.

func (*Secp256r1) Scalar

func (c *Secp256r1) Scalar() kyber.Scalar

Create a Scalar associated with this curve. The scalars created by this package implement kyber.Scalar's SetBytes method, interpreting the bytes as a big-endian integer, so as to be compatible with the Go standard library's big.Int type.

func (*Secp256r1) ScalarLen

func (c *Secp256r1) ScalarLen() int

Return the number of bytes in the encoding of a Scalar for this curve.

func (*Secp256r1) String

func (curve *Secp256r1) String() string

type Suite128

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

Suite128 is the suite for P256 curve

func NewBlakeSHA256P256

func NewBlakeSHA256P256() *Suite128

NewBlakeSHA256P256 returns a cipher suite based on package github.com/michaljirman/kyber/v3/xof/blake2xb, SHA-256, and the NIST P-256 elliptic curve. It returns random streams from Go's crypto/rand.

The scalars created by this group implement kyber.Scalar's SetBytes method, interpreting the bytes as a big-endian integer, so as to be compatible with the Go standard library's big.Int type.

func (*Suite128) Hash

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

Hash returns the instance associated with the suite

func (*Suite128) Init

func (curve *Suite128) Init() curve

Init initializes standard Curve instances

func (*Suite128) New

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

New implements the kyber.encoding interface

func (*Suite128) RandomStream

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

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

func (*Suite128) Read

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

func (*Suite128) String

func (curve *Suite128) String() string

func (*Suite128) Write

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

func (*Suite128) XOF

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

XOF creates the XOF associated with the suite

type Suite129

type Suite129 struct {
	Secp256r1
}

Suite129 is the suite for secp256r1 curve

func NewSecp256r1

func NewSecp256r1() *Suite129

func (*Suite129) ComputeY

func (c *Suite129) ComputeY(x *big.Int) (*big.Int, *big.Int)

func (*Suite129) Hash

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

Hash returns the instance associated with the suite

func (*Suite129) New

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

New implements the kyber.encoding interface

func (*Suite129) Order

func (c *Suite129) Order() *big.Int

Return the order of this curve: the prime N in the curve parameters.

func (*Suite129) Point

func (c *Suite129) Point() kyber.Point

Create a Point associated with this curve.

func (*Suite129) PointLen

func (c *Suite129) PointLen() int

Return the number of bytes in the encoding of a Point for this curve. Currently uses uncompressed ANSI X9.62 format with both X and Y coordinates; this could change.

func (*Suite129) RandomStream

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

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

func (*Suite129) Read

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

func (*Suite129) Scalar

func (c *Suite129) Scalar() kyber.Scalar

Create a Scalar associated with this curve. The scalars created by this package implement kyber.Scalar's SetBytes method, interpreting the bytes as a big-endian integer, so as to be compatible with the Go standard library's big.Int type.

func (*Suite129) ScalarLen

func (c *Suite129) ScalarLen() int

Return the number of bytes in the encoding of a Scalar for this curve.

func (*Suite129) Write

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

func (*Suite129) XOF

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

XOF creates the XOF associated with the suite

Jump to

Keyboard shortcuts

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