pedersen

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultNUMS is the default NUMS key used for Pedersen commitments.
	DefaultNUMS = input.TaprootNUMSKey
)

Functions

func WithCustomNUMS

func WithCustomNUMS(h btcec.PublicKey) commitOpt

WithCustomNUMS is a functional option that can be used to set a custom NUMS point.

Types

type Commitment

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

Commitment is a Pedersen commitment of the form: m*G + r*H, where:

  • m is the message being committed together
  • G is the generator point of the curve
  • r is the mask used to blind the messages
  • H is the auxiliary generator point

The commitment is a point on the curve. Given the opening a 3rd party can verify the message that was committed to.

func NewCommitment

func NewCommitment(op Opening, opts ...commitOpt) Commitment

NewCommitment creates a new Pedersen commitment given an opening.

func (Commitment) Point

func (c Commitment) Point() btcec.PublicKey

Point returns the underlying point of the commitment.

func (Commitment) Verify

func (c Commitment) Verify(op Opening) bool

Verify verifies that the commitment is valid given the opening. False is returned if the commitment doesn't match up.

type Opening

type Opening struct {
	// Msg is the message that was committed to.
	Msg [sha256.Size]byte

	// Mask is the mask used to blind the message. This is typically
	// referred to as `r` in the Pedersen commitment literature.
	//
	// We make this optional, as without it we'll default to no value, which
	// means that the commitment loses the hiding attribute, but still
	// remains computationally binding.
	Mask fn.Option[[sha256.Size]byte]

	// NUMS is an optional value that should be used to verify the
	// commitment if a custom NUMS point was used.
	NUMS fn.Option[btcec.PublicKey]
}

Opening is the opening to a Pedersen commitment. It contains a message, and an optional mask. If the mask is left off, then the commitment will lose its hiding property (two identical messages will map to the same point), but the binding property is kept.

Jump to

Keyboard shortcuts

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