commitments

package
v2.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PartsCap is the maximum number of parts allowed in a commitment.
	PartsCap = 3
	// MaxPartSize is the maximum byte size of a single commitment part (1 MB).
	MaxPartSize = int64(1 * 1024 * 1024) // 1 MB - rather liberal
)
View Source
const (
	// HashLength is the bit length used for generating commitment randomness.
	HashLength = 256
)

Variables

This section is empty.

Functions

func NewBuilder

func NewBuilder() *builder

NewBuilder creates a new commitment builder for assembling multi-part secrets.

func ParseSecrets

func ParseSecrets(secrets []*big.Int) ([][]*big.Int, error)

ParseSecrets decodes a length-prefixed flat slice of big.Int values back into separate parts.

Types

type HashCommitDecommit

type HashCommitDecommit struct {
	C HashCommitment
	D HashDeCommitment
}

HashCommitDecommit holds a paired commitment and decommitment for hash-based commitment schemes.

func NewHashCommitment

func NewHashCommitment(rand io.Reader, secrets ...*big.Int) *HashCommitDecommit

NewHashCommitment creates a new hash commitment with a random nonce for the given secrets.

func NewHashCommitmentWithRandomness

func NewHashCommitmentWithRandomness(r *big.Int, secrets ...*big.Int) *HashCommitDecommit

NewHashCommitmentWithRandomness creates a new hash commitment using the provided randomness value r and secrets.

func (*HashCommitDecommit) DeCommit

func (cmt *HashCommitDecommit) DeCommit() (bool, HashDeCommitment)

DeCommit verifies the commitment and, if valid, returns the secret values (excluding the randomness).

func (*HashCommitDecommit) Verify

func (cmt *HashCommitDecommit) Verify() bool

Verify checks that the decommitment D hashes to the commitment C.

type HashCommitment

type HashCommitment = *big.Int

HashCommitment is a hash-based commitment value.

type HashDeCommitment

type HashDeCommitment = []*big.Int

HashDeCommitment holds the decommitment values including the randomness and secrets.

func NewHashDeCommitmentFromBytes

func NewHashDeCommitmentFromBytes(marshalled [][]byte) HashDeCommitment

NewHashDeCommitmentFromBytes reconstructs a HashDeCommitment from a slice of byte slices.

Jump to

Keyboard shortcuts

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