internal

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const NumMRTests = 64

Variables

View Source
var (
	One   = big.NewInt(1)
	Two   = big.NewInt(2)
	Three = big.NewInt(3)
)

Functions

func Add added in v1.3.0

func Add(dst []byte, src ...[]byte)

func AppendBigUint16 added in v1.3.0

func AppendBigUint16(b []byte, v uint16) []byte

func AppendBigUint32 added in v1.3.0

func AppendBigUint32(b []byte, v uint32) []byte

func AppendBigUint64 added in v1.3.0

func AppendBigUint64(b []byte, v uint64) []byte

func AppendBigUint8 added in v1.3.0

func AppendBigUint8(b []byte, v byte) []byte

func BigCeilLog2 added in v1.3.0

func BigCeilLog2(n *big.Int, e int) int

= ceil(log(n) / log(2 ** e))

func BigEqual added in v1.3.0

func BigEqual(a, b *big.Int) bool

func BigLog2 added in v1.3.0

func BigLog2(n *big.Int) int

log(n) / log(2)

func BigLog2e added in v1.3.0

func BigLog2e(n *big.Int, e int) int

log(n) / log(2 ** e)

func BitsToBytes added in v1.3.0

func BitsToBytes(bits int) int

func BytesClone added in v1.3.0

func BytesClone(b []byte) []byte

Clone returns a copy of b[:len(b)]. The result may have additional unused capacity. Clone(nil) returns nil.

func CeilDiv added in v1.3.0

func CeilDiv(a, b int) int

same with `int(math.Ceil(float64(a) / float64(b)))`

func ConsumeBigU16 added in v1.3.0

func ConsumeBigU16(b []byte) ([]byte, uint16)

func ConsumeBigU32 added in v1.3.0

func ConsumeBigU32(b []byte) ([]byte, uint32)

func ConsumeBigU64 added in v1.3.0

func ConsumeBigU64(b []byte) ([]byte, uint64)

func FermatInverse

func FermatInverse(k, P *big.Int) *big.Int

https://cs.opensource.google/go/go/+/refs/tags/go1.18:src/crypto/dsa/dsa.go;l=188-192 fermatInverse calculates the inverse of k in GF(P) using Fermat's method. This has better constant-time properties than Euclid's method (implemented in math/big.Int.ModInverse) although math/big itself isn't strictly constant-time so it's not perfect.

func Grow added in v1.3.0

func Grow(buf []byte, bytes int) []byte

without guarantee of data

func H

func H(s string) string

func HB

func HB(s string) []byte

hex to byte

func HI

func HI(s string) *big.Int

hex to *big.Int

func IncCtr added in v1.3.0

func IncCtr(b []byte)

func LeftMost added in v1.3.0

func LeftMost(b []byte, bits int) []byte

[0 0 0 0 0 0]0 0

func ReadBigInt added in v1.3.0

func ReadBigInt(dst *big.Int, rand io.Reader, buf []byte, max *big.Int) (bufNew []byte, err error)

ReadBigInt returns a uniform random value in [0, max). It panics if max <= 0.

func ReadBits

func ReadBits(dst []byte, rand io.Reader, bits int) ([]byte, error)

resize dst, ReadFull, cut from right

func ReadBytes added in v1.3.0

func ReadBytes(dst []byte, rand io.Reader, bytes int) ([]byte, error)

resize dst, ReadFull, cut from right

func ReadInt added in v1.3.0

func ReadInt(r io.Reader, max int) (int, error)

[0, max)

func Resize added in v1.3.0

func Resize(arr []byte, bytes int) []byte

keep data

func RightMost added in v1.3.0

func RightMost(b []byte, bits int) []byte

0 0[0 0 0 0 0 0]

func SliceForAppend added in v1.3.0

func SliceForAppend(in []byte, n int) (head, tail []byte)

func StringClone added in v1.3.0

func StringClone(s string) string

Types

type Hash added in v1.3.0

type Hash interface {
	hash.Hash
	// encoding.BinaryMarshaler
	MarshalBinary() (data []byte, err error)
	// encoding.BinaryUnmarshaler
	UnmarshalBinary(data []byte) error
}

Directories

Path Synopsis
Package alias implements memory aliasing tests.
Package alias implements memory aliasing tests.
drbg
golang.org
x/crypto/cryptobyte
Package cryptobyte contains types that help with parsing and constructing length-prefixed, binary messages, including ASN.1 DER.
Package cryptobyte contains types that help with parsing and constructing length-prefixed, binary messages, including ASN.1 DER.
x/crypto/cryptobyte/asn1
Package asn1 contains supporting types for parsing and building ASN.1 messages with the cryptobyte package.
Package asn1 contains supporting types for parsing and building ASN.1 messages with the cryptobyte package.
x/sys/cpu
Package cpu implements processor feature detection for various CPU architectures.
Package cpu implements processor feature detection for various CPU architectures.
Package randutil contains internal randomness utilities for various crypto packages.
Package randutil contains internal randomness utilities for various crypto packages.

Jump to

Keyboard shortcuts

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