Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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.