Documentation
¶
Overview ¶
Package base provides the base package contains a set of base primitives, including but not limited to various elliptic curves, data structures, and common functions used across this library.
See README.md for details.
Index ¶
- Constants
- Variables
- func GetMaliciousIdentities[ID IdentifiableAbortID](err error) []ID
- func IsIdentifiableAbortError(err error) bool
- func ShouldAbort(err error) bool
- type BytesLike
- type BytesLikeFactory
- type Clonable
- type Comparable
- type Equatable
- type HashCode
- type Hashable
- type HashableStructure
- type IdentifiableAbortID
- type Ordering
- type PartialOrdering
- type Transparent
- type WithInternalCompareMethod
- type WithInternalPartialCompareMethod
Constants ¶
const ( // Computational security derived values ComputationalSecurityLog2Ceil = 7 ComputationalSecurityPow2Ceil = 1 << ComputationalSecurityLog2Ceil ComputationalSecurityBytesCeil = 16 // ceil(ComputationalSecurityBits/8) // Statistical security derived values StatisticalSecurityLog2Ceil = 7 StatisticalSecurityPower2Ceil = 1 << StatisticalSecurityLog2Ceil StatisticalSecurityBytesCeil = 10 // ceil(StatisticalSecurityBits/8) // Collision resistance derived values CollisionResistanceBytesCeil = 32 // ceil(CollisionResistance/8) )
Derived constants from the base security parameters in constants.go
const ( // ComputationalSecurityBits (λ) is the number of bits of computational security // we want to achieve in most of our cryptographic primitives. ComputationalSecurityBits = 128 // StatisticalSecurityBits (λ_s) is the number of bits of statistical security // we want to achieve in most of our cryptographic primitives, // applicable mostly to soundness of interactive proofs. StatisticalSecurityBits = 80 // IFCKeyLength is the key length (in bits) for integer factorization based cryptography // (e.g. RSA) to achieve λ-bits of security. // Values based on SP 800-57 Part 1 Rev. 5, Table 2. IFCKeyLength = 3072 // CollisionResistance is the hash digest length to achieve λ-bits of // collision resistance (birthday paradox). CollisionResistance = 2 * ComputationalSecurityBits // Hash2CurveAppTag is the application tag for hash-to-curve operations. Hash2CurveAppTag = "bron_crypto_with-" )
Base security parameters - these are the source of truth.
const IdentifiableAbortPartyIDTag = "identifiable_abort_party_id"
IdentifiableAbortPartyIDTag is the tag used to identify parties responsible for an identifiable abort.
Variables ¶
var ErrAbort = errs.New("ABORT")
ErrAbort indicates that an operation was aborted due to malicious behaviour.
var (
ErrIsIncomparable = errs.New("elements are incomparable")
)
Functions ¶
func GetMaliciousIdentities ¶
func GetMaliciousIdentities[ID IdentifiableAbortID](err error) []ID
GetMaliciousIdentities extracts the party IDs responsible for an identifiable abort from the given error.
func IsIdentifiableAbortError ¶
IsIdentifiableAbortError checks if the given error is an identifiable abort error.
func ShouldAbort ¶
ShouldAbort checks if the given error indicates that an operation should be aborted.
Types ¶
type BytesLike ¶
type BytesLike interface {
// Bytes returns the byte slice representation of the receiver.
Bytes() []byte
}
BytesLike represents types that can provide a byte slice representation.
type BytesLikeFactory ¶
type BytesLikeFactory[E any] interface { // FromBytes creates an element of type E from the given byte slice. FromBytes([]byte) (E, error) // If elemnts are atomic, ElementSize returns the **exact** number of bytes (implementation-dependent) required to represent an element. // If elements are collections of atomic elements, ElementSize returns the size of an individual element. // If elements are variable size, ElementSize returns -1. ElementSize() int }
BytesLikeFactory represents a factory for creating elements of type E from byte slices.
type Comparable ¶
type Comparable[E any] interface { // IsLessThanOrEqual checks if the receiver is less than or equal to rhs. IsLessThanOrEqual(rhs E) bool }
Comparable represents types that can be compared.
type HashCode ¶
HashCode represents a 64-bit hash code.
func DeriveHashCode ¶
DeriveHashCode derives a HashCode from one or more byte slices.
type HashableStructure ¶
type HashableStructure[E any] interface { // Hash hashes the input byte slice and returns an element of type E. Hash([]byte) (E, error) }
HashableStructure represents a structure that can hash byte slices into elements of type E.
type IdentifiableAbortID ¶
type IdentifiableAbortID interface {
constraints.Unsigned
}
IdentifiableAbortID represents the type used for party identifiers in identifiable abort errors.
type Ordering ¶
type Ordering int8
Ordering represents a total ordering result. It can take values: LessThan, Equal, GreaterThan.
func Compare ¶
func Compare[E Comparable[E]](x, y E) Ordering
Compare compares two elements and returns their Ordering. It panics if the elements are Incomparable. It prefers ct.Comparable if available for constant-time comparison.
func (Ordering) Is ¶
func (o Ordering) Is(other PartialOrdering) bool
Is checks if the Ordering is equal to the given PartialOrdering.
func (Ordering) IsGreaterThan ¶
IsGreaterThan checks if the Ordering represents GreaterThan.
func (Ordering) IsLessThan ¶
IsLessThan checks if the Ordering represents LessThan.
type PartialOrdering ¶
type PartialOrdering int8
PartialOrdering represents a partial ordering result. It can take values: Incomparable, LessThan, Equal, GreaterThan.
const ( Incomparable PartialOrdering = -2 LessThan PartialOrdering = -1 Equal PartialOrdering = 0 GreaterThan PartialOrdering = 1 )
func ParseOrderingFromMasks ¶
func ParseOrderingFromMasks[F constraints.Integer](lt, eq, gt F) PartialOrdering
ParseOrderingFromMasks parses a PartialOrdering from comparison masks.
func PartialCompare ¶
func PartialCompare[E Comparable[E]](x, y E) PartialOrdering
PartialCompare compares two elements and returns their PartialOrdering. It prefers ct.Comparable if available for constant-time comparison.
func (PartialOrdering) Is ¶
func (o PartialOrdering) Is(other Ordering) bool
Is checks if the PartialOrdering is equal to the given Ordering.
func (PartialOrdering) IsEqual ¶
func (o PartialOrdering) IsEqual() bool
IsEqual checks if the PartialOrdering represents Equal.
func (PartialOrdering) IsGreaterThan ¶
func (o PartialOrdering) IsGreaterThan() bool
IsGreaterThan checks if the PartialOrdering represents GreaterThan.
func (PartialOrdering) IsIncomparable ¶
func (o PartialOrdering) IsIncomparable() bool
IsIncomparable checks if the PartialOrdering represents Incomparable.
func (PartialOrdering) IsLessThan ¶
func (o PartialOrdering) IsLessThan() bool
IsLessThan checks if the PartialOrdering represents LessThan.
func (PartialOrdering) String ¶
func (o PartialOrdering) String() string
String returns the string representation of the PartialOrdering.
type Transparent ¶
type Transparent[V any] interface { Value() V }
Transparent represents a type that can expose an underlying value of type V.
type WithInternalCompareMethod ¶
type WithInternalCompareMethod[E any] interface { // Compare compares the receiver with rhs and returns an Ordering. Compare(rhs E) Ordering }
WithInternalCompareMethod allows types to implement their own Compare method.
type WithInternalPartialCompareMethod ¶
type WithInternalPartialCompareMethod[E any] interface { // PartialCompare compares the receiver with rhs and returns a PartialOrdering. PartialCompare(rhs E) PartialOrdering }
WithInternalPartialCompareMethod allows types to implement their own PartialCompare method.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package algebra provides algebraic interfaces and generic helpers for groups, rings, fields, modules, and related algebraic structures.
|
Package algebra provides algebraic interfaces and generic helpers for groups, rings, fields, modules, and related algebraic structures. |
|
impl/fields
Package fields provides low-level field element traits used by generated finite field implementations.
|
Package fields provides low-level field element traits used by generated finite field implementations. |
|
Package base58 implements base58 encoding and decoding.
|
Package base58 implements base58 encoding and decoding. |
|
binaryfields
|
|
|
bf128
Package bf128 implements arithmetic over the binary field GF(2^128).
|
Package bf128 implements arithmetic over the binary field GF(2^128). |
|
Package bitvec implements a mutable bit vector with insertion, deletion, and indexing operations.
|
Package bitvec implements a mutable bit vector with insertion, deletion, and indexing operations. |
|
cgo
|
|
|
boring
Package boring wraps a small subset of BoringSSL BigNum APIs for internal use.
|
Package boring wraps a small subset of BoringSSL BigNum APIs for internal use. |
|
Package ct provides constant-time operations for cryptographic implementations, helping to prevent timing-based side-channel attacks.
|
Package ct provides constant-time operations for cryptographic implementations, helping to prevent timing-based side-channel attacks. |
|
Package curves provides implementation of various elliptic curves.
|
Package curves provides implementation of various elliptic curves. |
|
curve25519
Package curve25519 implements Curve25519 group operations, field elements, scalars, and encoding helpers.
|
Package curve25519 implements Curve25519 group operations, field elements, scalars, and encoding helpers. |
|
edwards25519
Package edwards25519 implements the Edwards25519 curve, its scalar and base fields, and point encoding.
|
Package edwards25519 implements the Edwards25519 curve, its scalar and base fields, and point encoding. |
|
edwards25519/impl
Package impl contains low-level Edwards25519 field and point implementations plus hash-to-curve parameters.
|
Package impl contains low-level Edwards25519 field and point implementations plus hash-to-curve parameters. |
|
impl/points
Package points provides point arithmetic implementations for short Weierstrass and twisted Edwards curves.
|
Package points provides point arithmetic implementations for short Weierstrass and twisted Edwards curves. |
|
impl/rfc9380
Package rfc9380 implements hash-to-curve helpers from RFC 9380.
|
Package rfc9380 implements hash-to-curve helpers from RFC 9380. |
|
impl/rfc9380/expanders
Package expanders implements XMD and XOF expanders for RFC 9380.
|
Package expanders implements XMD and XOF expanders for RFC 9380. |
|
impl/rfc9380/mappers/elligator2
Package elligator2 implements Elligator 2 mappings for Curve25519 and Edwards25519.
|
Package elligator2 implements Elligator 2 mappings for Curve25519 and Edwards25519. |
|
impl/rfc9380/mappers/sswu
Package sswu implements simplified SWU mapping and related helpers for RFC 9380.
|
Package sswu implements simplified SWU mapping and related helpers for RFC 9380. |
|
impl/traits
Package traits provides reusable traits for field and curve wrappers.
|
Package traits provides reusable traits for field and curve wrappers. |
|
k256
Package k256 implements the secp256k1 curve, field, scalar, and point types.
|
Package k256 implements the secp256k1 curve, field, scalar, and point types. |
|
k256/impl
Package impl contains low-level secp256k1 field arithmetic and point operations.
|
Package impl contains low-level secp256k1 field arithmetic and point operations. |
|
p256
Package p256 implements the NIST P-256 curve, field, scalar, and point types.
|
Package p256 implements the NIST P-256 curve, field, scalar, and point types. |
|
p256/impl
Package impl contains low-level P-256 field arithmetic and point operations.
|
Package impl contains low-level P-256 field arithmetic and point operations. |
|
pairable
Package pairable provides exposes pairing-friendly curve families and shared interfaces.
|
Package pairable provides exposes pairing-friendly curve families and shared interfaces. |
|
pairable/bls12381
Package bls12381 implements the BLS12-381 curve groups, fields, and pairing interfaces.
|
Package bls12381 implements the BLS12-381 curve groups, fields, and pairing interfaces. |
|
pairable/bls12381/impl
Package impl contains low-level BLS12-381 field arithmetic, points, and pairing engine code.
|
Package impl contains low-level BLS12-381 field arithmetic, points, and pairing engine code. |
|
pasta
Package pasta implements the Pallas and Vesta curves and their field types.
|
Package pasta implements the Pallas and Vesta curves and their field types. |
|
pasta/impl
Package impl contains low-level Pallas and Vesta field arithmetic and point operations.
|
Package impl contains low-level Pallas and Vesta field arithmetic and point operations. |
|
Package datastructures provides generic data structure interfaces and implementations for Go.
|
Package datastructures provides generic data structure interfaces and implementations for Go. |
|
bimap
Package bimap provides bidirectional map implementations for the datastructures interfaces.
|
Package bimap provides bidirectional map implementations for the datastructures interfaces. |
|
hashmap
Package hashmap provides hash-based map implementations for the datastructures interfaces.
|
Package hashmap provides hash-based map implementations for the datastructures interfaces. |
|
hashset
Package hashset provides hash-based set implementations for the datastructures interfaces.
|
Package hashset provides hash-based set implementations for the datastructures interfaces. |
|
Package nt provides foundational number theory primitives for cryptographic applications.
|
Package nt provides foundational number theory primitives for cryptographic applications. |
|
cardinal
Package cardinal provides representations for cardinal numbers (cardinalities) used to express the size of algebraic structures such as groups, rings, and fields.
|
Package cardinal provides representations for cardinal numbers (cardinalities) used to express the size of algebraic structures such as groups, rings, and fields. |
|
crt
Package crt provides Chinese Remainder Theorem (CRT) reconstruction and decomposition for cryptographic applications.
|
Package crt provides Chinese Remainder Theorem (CRT) reconstruction and decomposition for cryptographic applications. |
|
modular
Package modular provides CRT-accelerated modular arithmetic for cryptographic applications such as RSA and Paillier.
|
Package modular provides CRT-accelerated modular arithmetic for cryptographic applications such as RSA and Paillier. |
|
num
Package num provides arbitrary-precision arithmetic for cryptographic applications.
|
Package num provides arbitrary-precision arithmetic for cryptographic applications. |
|
numct
Package numct provides constant-time arbitrary-precision arithmetic for cryptographic applications.
|
Package numct provides constant-time arbitrary-precision arithmetic for cryptographic applications. |
|
znstar
Package znstar provides multiplicative groups of units modulo n, denoted (Z/nZ)*, for cryptographic applications such as RSA and Paillier encryption.
|
Package znstar provides multiplicative groups of units modulo n, denoted (Z/nZ)*, for cryptographic applications such as RSA and Paillier encryption. |
|
Package polynomials provides polynomial rings and modules over algebraic structures with helpers for sampling, evaluation, and serialisation.
|
Package polynomials provides polynomial rings and modules over algebraic structures with helpers for sampling, evaluation, and serialisation. |
|
interpolation/lagrange
Package lagrange provides Lagrange interpolation utilities over finite fields and modules.
|
Package lagrange provides Lagrange interpolation utilities over finite fields and modules. |
|
csprng
Package csprng defines interfaces and helpers for cryptographically secure PRNGs, including a threadsafe wrapper.
|
Package csprng defines interfaces and helpers for cryptographically secure PRNGs, including a threadsafe wrapper. |
|
csprng/fkechacha20
Package fkechacha20 implements a cryptographically-secure pseudo-random number generator based on a fork of the ChaCha20 with fast key erasure.
|
Package fkechacha20 implements a cryptographically-secure pseudo-random number generator based on a fork of the ChaCha20 with fast key erasure. |
|
csprng/nist
Package nist implements a cryptographically-secure pseudo-random number generator i.e Deterministic Random Bit Generator (DRBG) definition of NIST spec, based on AES (AES128 or AES256) as block cipher in counter mode.
|
Package nist implements a cryptographically-secure pseudo-random number generator i.e Deterministic Random Bit Generator (DRBG) definition of NIST spec, based on AES (AES128 or AES256) as block cipher in counter mode. |
|
csprng/rfc8937
Package rfc8937 provides a randomness wrapper that ties the security of the CSPRNG to a deterministic signing key.
|
Package rfc8937 provides a randomness wrapper that ties the security of the CSPRNG to a deterministic signing key. |
|
pcg
Package pcg provides a seedable PCG-based PRNG for tests and non-cryptographic randomness.
|
Package pcg provides a seedable PCG-based PRNG for tests and non-cryptographic randomness. |
|
Package serde provides serialisation and deserialization utilities using CBOR (Concise Binary Object Representation) format.
|
Package serde provides serialisation and deserialization utilities using CBOR (Concise Binary Object Representation) format. |
|
Package utils provides common utility functions and helpers for working with Go primitives and data structures.
|
Package utils provides common utility functions and helpers for working with Go primitives and data structures. |
|
algebrautils
Package algebrautils provides utilities for working with algebraic structures such as monoids, groups, rings, and fields.
|
Package algebrautils provides utilities for working with algebraic structures such as monoids, groups, rings, and fields. |
|
ioutils
Package ioutils provides I/O helpers for Readers and Writers.
|
Package ioutils provides I/O helpers for Readers and Writers. |
|
iterutils
Package iterutils provides functional utilities for working with Go 1.23+ iterators (iter.Seq and iter.Seq2), enabling lazy evaluation and efficient data processing.
|
Package iterutils provides functional utilities for working with Go 1.23+ iterators (iter.Seq and iter.Seq2), enabling lazy evaluation and efficient data processing. |
|
maputils
Package maputils provides utilities for working with Go maps, providing functional transformations and map operations.
|
Package maputils provides utilities for working with Go maps, providing functional transformations and map operations. |
|
mathutils
Package mathutils provides mathematical utility functions for cryptographic and numerical operations.
|
Package mathutils provides mathematical utility functions for cryptographic and numerical operations. |
|
nocopy
Package nocopy provides types to prevent copying of structs after first use, useful for ensuring proper handling of sensitive data structures.
|
Package nocopy provides types to prevent copying of structs after first use, useful for ensuring proper handling of sensitive data structures. |
|
sliceutils
Package sliceutils provides functional utilities for working with slices in Go, providing a rich set of operations for transforming, filtering, and manipulating slice data.
|
Package sliceutils provides functional utilities for working with slices in Go, providing a rich set of operations for transforming, filtering, and manipulating slice data. |