zn

package
v0.0.0-...-eab8366 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	N *big.Int
}

Group represents Z_n* - group of all integers smaller than n and coprime with n. Note that this group is not cyclic in the general case (as opposed to, for example, Schnorr group).

When n is a prime, use a special case of this group, the GroupZp struct instead.

func NewGroup

func NewGroup(n *big.Int) *Group

func (*Group) Add

func (g *Group) Add(x, y *big.Int) *big.Int

Add computes x + y mod group.N.

func (*Group) Exp

func (g *Group) Exp(x, exponent *big.Int) *big.Int

Exp computes x^exponent mod group.N.

func (*Group) GetRandomElement

func (g *Group) GetRandomElement() *big.Int

GetRandomElement returns a random element from this group. Elements of this group are integers that are coprime with N.

func (*Group) Inv

func (g *Group) Inv(x *big.Int) *big.Int

Inv computes inverse of x, that means xInv such that x * xInv = 1 mod group.N.

func (*Group) IsElementInGroup

func (g *Group) IsElementInGroup(x *big.Int) bool

IsElementInGroup returns true if x is in the group and false otherwise. An element x is in Group when it is coprime with group.N, that means gcd(x, group.N) = 1.

func (*Group) Mul

func (g *Group) Mul(x, y *big.Int) *big.Int

Mul computes x * y mod group.N.

type GroupZp

type GroupZp struct {
	*Group
	Order *big.Int
}

GroupZp represents is a special case of the Z_n* group, where n is a prime. The group is cyclic, however the generator of the group is difficult to find (as opposed to Schnorr group and qr.RSASpecial group).

func NewGroupZp

func NewGroupZp(p *big.Int) (*GroupZp, error)

func (*GroupZp) GetGeneratorOfSubgroup

func (zp *GroupZp) GetGeneratorOfSubgroup(subgroupOrder *big.Int) (*big.Int, error)

GetGeneratorOfSubgroup returns a generator of a subgroup of a specified order in Z_n. Parameter groupOrder is order of Z_n (if n is prime, order is n-1).

Jump to

Keyboard shortcuts

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