ring

package
v0.0.0-...-cbd876d Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

README

ring

Brief description

The package ring offers a basic implementation of modular arithmetic ring as well as a few operations on it.

Overview

  1. Create a new ring modulo 10 with r = NewRing(big.NewInt(10))
  2. Add two aribraty-precision numbers in the ring r with a = r.Add(big.NewInt(7), big.NewInt(8)) where a should be equal to 5

Available operations

  • Reduction
  • Addition
  • Subtraction
  • Multiplication
  • Negation

Documentation

Overview

Package ring implement an integer ring with basic operations on big.Int in this ring

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ring

type Ring struct {
	Q *big.Int
}

Ring represents a ring of integers with modulo Q

func NewRing

func NewRing(q *big.Int) *Ring

NewRing returns a ring with given modulo Q

func (*Ring) Add

func (r *Ring) Add(a, b *big.Int) (c *big.Int)

Add adds a and b in ring r

func (*Ring) Mult

func (r *Ring) Mult(a, b *big.Int) (c *big.Int)

Mult mulitplies a to b in ring r

func (*Ring) Neg

func (r *Ring) Neg(a *big.Int) (c *big.Int)

Neg returns -a in ring r

func (*Ring) Red

func (r *Ring) Red(a *big.Int) (c *big.Int)

Red reduces a big.Int a modulo r.Q

func (*Ring) Sub

func (r *Ring) Sub(a, b *big.Int) (c *big.Int)

Sub subs b to a in ring r

Jump to

Keyboard shortcuts

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