pedersen

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateParameters

func ValidateParameters(n *saferith.Modulus, s, t *saferith.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 *saferith.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 *saferith.Int) *saferith.Nat

Commit computes sˣ tʸ (mod N)

x and y are taken as saferith.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() *saferith.Modulus

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

func (Parameters) NArith

func (p Parameters) NArith() *arith.Modulus

N, but as an arith modulus, which is sometimes useful

func (Parameters) S

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

S = r² mod N.

func (Parameters) T

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

T = Sˡ mod N.

func (Parameters) Verify

func (p Parameters) Verify(a, b, e *saferith.Int, S, T *saferith.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