Documentation
¶
Overview ¶
Package pedersen provides pedersen commitments are perfectly hiding and computationally binding.
See README.md for details.
Index ¶
- Constants
- Variables
- type Commitment
- func (c *Commitment[E, S]) Bytes() []byte
- func (c *Commitment[E, S]) Clone() *Commitment[E, S]
- func (c *Commitment[E, S]) Equal(other *Commitment[E, S]) bool
- func (c *Commitment[E, S]) HashCode() base.HashCode
- func (c *Commitment[E, S]) MarshalCBOR() ([]byte, error)
- func (c *Commitment[E, S]) Op(other *Commitment[E, S]) *Commitment[E, S]
- func (c *Commitment[E, S]) ReRandomise(key *Key[E, S], prng io.Reader) (*Commitment[E, S], *Witness[S], error)
- func (c *Commitment[E, S]) ReRandomiseWithWitness(key *Key[E, S], r *Witness[S]) (*Commitment[E, S], error)
- func (c *Commitment[E, S]) ScalarOp(message *Message[S]) *Commitment[E, S]
- func (c *Commitment[E, S]) UnmarshalCBOR(data []byte) error
- func (c *Commitment[E, S]) Value() E
- type Committer
- type CommitterOption
- type Key
- type Message
- func (m *Message[S]) Add(other *Message[S]) *Message[S]
- func (m *Message[S]) Bytes() []byte
- func (m *Message[S]) Clone() *Message[S]
- func (m *Message[S]) Equal(other *Message[S]) bool
- func (m *Message[S]) HashCode() base.HashCode
- func (m *Message[S]) MarshalCBOR() ([]byte, error)
- func (m *Message[S]) Mul(other *Message[S]) *Message[S]
- func (m *Message[S]) Op(other *Message[S]) *Message[S]
- func (m *Message[S]) OtherOp(other *Message[S]) *Message[S]
- func (m *Message[S]) UnmarshalCBOR(data []byte) error
- func (m *Message[S]) Value() S
- type Scheme
- func (s *Scheme[E, S]) Committer(opts ...CommitterOption[E, S]) (*Committer[E, S], error)
- func (s *Scheme[E, S]) Group() algebra.PrimeGroup[E, S]
- func (s *Scheme[E, S]) Key() *Key[E, S]
- func (*Scheme[_, _]) Name() commitments.Name
- func (s *Scheme[E, S]) Verifier(opts ...VerifierOption[E, S]) (*Verifier[E, S], error)
- type Verifier
- type VerifierOption
- type Witness
- func (w *Witness[S]) Add(other *Witness[S]) *Witness[S]
- func (w *Witness[S]) Clone() *Witness[S]
- func (w *Witness[S]) Equal(other *Witness[S]) bool
- func (w *Witness[S]) HashCode() base.HashCode
- func (w *Witness[S]) MarshalCBOR() ([]byte, error)
- func (w *Witness[S]) Mul(other *Witness[S]) *Witness[S]
- func (w *Witness[S]) Op(other *Witness[S]) *Witness[S]
- func (w *Witness[S]) OtherOp(other *Witness[S]) *Witness[S]
- func (w *Witness[S]) UnmarshalCBOR(data []byte) error
- func (w *Witness[S]) Value() S
Constants ¶
const Name commitments.Name = "pedersen"
Name identifies the Pedersen commitment scheme.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Commitment ¶
type Commitment[E algebra.PrimeGroupElement[E, S], S algebra.PrimeFieldElement[S]] struct { // contains filtered or unexported fields }
Commitment represents a Pedersen commitment value held in the prime order group.
func NewCommitment ¶
func NewCommitment[E algebra.PrimeGroupElement[E, S], S algebra.PrimeFieldElement[S]](v E) (*Commitment[E, S], error)
NewCommitment wraps the provided group element as a commitment, rejecting the identity element.
func (*Commitment[E, S]) Bytes ¶
func (c *Commitment[E, S]) Bytes() []byte
Bytes serialises the commitment to its canonical byte representation.
func (*Commitment[E, S]) Clone ¶
func (c *Commitment[E, S]) Clone() *Commitment[E, S]
Clone returns a deep copy of the commitment.
func (*Commitment[E, S]) Equal ¶
func (c *Commitment[E, S]) Equal(other *Commitment[E, S]) bool
Equal reports whether both commitments hold the same group element (and handles nils).
func (*Commitment[E, S]) HashCode ¶
func (c *Commitment[E, S]) HashCode() base.HashCode
HashCode returns a hash of the commitment for use in maps or sets.
func (*Commitment[E, S]) MarshalCBOR ¶
func (c *Commitment[E, S]) MarshalCBOR() ([]byte, error)
MarshalCBOR encodes the commitment into CBOR format.
func (*Commitment[E, S]) Op ¶
func (c *Commitment[E, S]) Op(other *Commitment[E, S]) *Commitment[E, S]
Op combines two commitments using the group operation.
func (*Commitment[E, S]) ReRandomise ¶
func (c *Commitment[E, S]) ReRandomise(key *Key[E, S], prng io.Reader) (*Commitment[E, S], *Witness[S], error)
ReRandomise samples fresh randomness and blinds the commitment, returning the new commitment and witness.
func (*Commitment[E, S]) ReRandomiseWithWitness ¶
func (c *Commitment[E, S]) ReRandomiseWithWitness(key *Key[E, S], r *Witness[S]) (*Commitment[E, S], error)
ReRandomiseWithWitness blinds the commitment using the provided witness randomness.
func (*Commitment[E, S]) ScalarOp ¶
func (c *Commitment[E, S]) ScalarOp(message *Message[S]) *Commitment[E, S]
ScalarOp raises the commitment to the given message scalar.
func (*Commitment[E, S]) UnmarshalCBOR ¶
func (c *Commitment[E, S]) UnmarshalCBOR(data []byte) error
UnmarshalCBOR decodes a CBOR commitment into the receiver.
func (*Commitment[E, S]) Value ¶
func (c *Commitment[E, S]) Value() E
Value returns the underlying group element of the commitment.
type Committer ¶
type Committer[E algebra.PrimeGroupElement[E, S], S algebra.PrimeFieldElement[S]] struct { // contains filtered or unexported fields }
Committer produces Pedersen commitments using the provided key.
func (*Committer[E, S]) Commit ¶
func (c *Committer[E, S]) Commit(message *Message[S], prng io.Reader) (*Commitment[E, S], *Witness[S], error)
Commit samples fresh randomness and commits to a message, returning the commitment and witness.
func (*Committer[E, S]) CommitWithWitness ¶
func (c *Committer[E, S]) CommitWithWitness(message *Message[S], witness *Witness[S]) (*Commitment[E, S], error)
CommitWithWitness commits to a message using caller-supplied witness randomness.
type CommitterOption ¶
type CommitterOption[E algebra.PrimeGroupElement[E, S], S algebra.PrimeFieldElement[S]] = func(*Committer[E, S]) error
CommitterOption is a functional option for configuring committers.
type Key ¶
type Key[E algebra.PrimeGroupElement[E, S], S algebra.PrimeFieldElement[S]] struct { // contains filtered or unexported fields }
Key holds the generators defining a Pedersen commitment CRS.
func NewCommitmentKey ¶
func NewCommitmentKey[E algebra.PrimeGroupElement[E, S], S algebra.PrimeFieldElement[S]](g, h E) (*Key[E, S], error)
NewCommitmentKey validates and constructs a Pedersen key from two independent generators.
func (*Key[E, S]) Group ¶
func (k *Key[E, S]) Group() algebra.PrimeGroup[E, S]
Group exposes the prime group structure shared by the generators.
func (*Key[E, S]) H ¶
func (k *Key[E, S]) H() E
H returns the second generator used for hiding randomness.
func (*Key[E, S]) MarshalCBOR ¶
MarshalCBOR encodes the key into CBOR format.
func (*Key[E, S]) UnmarshalCBOR ¶
UnmarshalCBOR decodes a CBOR-encoded key into the receiver.
type Message ¶
type Message[S algebra.PrimeFieldElement[S]] struct { // contains filtered or unexported fields }
Message wraps a scalar plaintext committed with Pedersen commitments.
func NewMessage ¶
func NewMessage[S algebra.PrimeFieldElement[S]](v S) *Message[S]
NewMessage constructs a message from the provided scalar value.
func (*Message[S]) Equal ¶
Equal reports whether the two messages represent the same scalar (and handles nils).
func (*Message[S]) MarshalCBOR ¶
MarshalCBOR encodes the message into CBOR format.
func (*Message[S]) UnmarshalCBOR ¶
UnmarshalCBOR decodes a CBOR message into the receiver.
type Scheme ¶
type Scheme[E algebra.PrimeGroupElement[E, S], S algebra.PrimeFieldElement[S]] struct { // contains filtered or unexported fields }
Scheme wires together the Pedersen CRS with its committer and verifier.
func NewScheme ¶
func NewScheme[E algebra.PrimeGroupElement[E, S], S algebra.PrimeFieldElement[S]](key *Key[E, S]) (*Scheme[E, S], error)
NewScheme validates and constructs a Pedersen commitment scheme from the provided key.
func (*Scheme[E, S]) Committer ¶
func (s *Scheme[E, S]) Committer(opts ...CommitterOption[E, S]) (*Committer[E, S], error)
Committer returns a committer configured with the scheme key.
func (*Scheme[E, S]) Group ¶
func (s *Scheme[E, S]) Group() algebra.PrimeGroup[E, S]
Group returns the prime group used by the scheme.
func (*Scheme[_, _]) Name ¶
func (*Scheme[_, _]) Name() commitments.Name
Name returns the identifier of the Pedersen commitment scheme.
type Verifier ¶
type Verifier[E algebra.PrimeGroupElement[E, S], S algebra.PrimeFieldElement[S]] struct { commitments.GenericVerifier[*Committer[E, S], *Witness[S], *Message[S], *Commitment[E, S]] }
Verifier checks Pedersen commitments against provided messages and witnesses.
type VerifierOption ¶
type VerifierOption[E algebra.PrimeGroupElement[E, S], S algebra.PrimeFieldElement[S]] = func(*Verifier[E, S]) error
VerifierOption is a functional option for configuring verifiers.
type Witness ¶
type Witness[S algebra.PrimeFieldElement[S]] struct { // contains filtered or unexported fields }
Witness holds the randomness used to hide the committed message.
func NewWitness ¶
func NewWitness[S algebra.PrimeFieldElement[S]](v S) (*Witness[S], error)
NewWitness constructs a witness, rejecting zero values to prevent degenerate commitments.
func (*Witness[S]) Equal ¶
Equal reports whether the two witnesses hold the same scalar (and handles nils).
func (*Witness[S]) MarshalCBOR ¶
MarshalCBOR encodes the witness into CBOR format.
func (*Witness[S]) UnmarshalCBOR ¶
UnmarshalCBOR decodes a CBOR witness into the receiver.