pedersen

package
v0.6.0-alpha-2021-09-21 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 5 Imported by: 37

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateParameters

func ValidateParameters(n *safenum.Modulus, s, t *safenum.Nat) error

ValidateParameters check n, s and t, and returns an error if any of the following is true: - n, s, or t is nil. - s, t are not in [1, …,n-1]. - s, t are not coprime to N. - s = t.

Types

type Error

type Error string
const (
	ErrNilFields    Error = "contains nil field"
	ErrSEqualT      Error = "S cannot be equal to T"
	ErrNotValidModN Error = "S and T must be in [1,…,N-1] and coprime to N"
)

func (Error) Error

func (e Error) Error() string

type Parameters

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

func New

func New(n *arith.Modulus, s, t *safenum.Nat) *Parameters

New returns a new set of Pedersen parameters. Assumes ValidateParameters(n, s, t) returns nil.

func (Parameters) Commit

func (p Parameters) Commit(x, y *safenum.Int) *safenum.Nat

Commit computes sˣ tʸ (mod N)

x and y are taken as safenum.Int, because we want to keep these values in secret, in general. The commitment produced, on the other hand, hides their values, and can be safely shared.

func (Parameters) Domain

func (Parameters) Domain() string

Domain implements hash.WriterToWithDomain, and separates this type within hash.Hash.

func (Parameters) N

func (p Parameters) N() *safenum.Modulus

N = p•q, p ≡ q ≡ 3 mod 4.

func (Parameters) S

func (p Parameters) S() *safenum.Nat

S = r² mod N.

func (Parameters) T

func (p Parameters) T() *safenum.Nat

T = Sˡ mod N.

func (Parameters) Verify

func (p Parameters) Verify(a, b, e *safenum.Int, S, T *safenum.Nat) bool

Verify returns true if sᵃ tᵇ ≡ S Tᵉ (mod N).

func (*Parameters) WriteTo

func (p *Parameters) WriteTo(w io.Writer) (int64, error)

WriteTo implements io.WriterTo and should be used within the hash.Hash function.

Jump to

Keyboard shortcuts

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