cyclic

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2014 License: GPL-3.0-or-later Imports: 3 Imported by: 0

Documentation

Overview

Package cyclic generates cryptographic cyclic groups and generators with a specified bit-length.

The package is not used in a live system, just to generate an initial config.

Reference: http://goo.gl/zU4ZY

Example (Usage)
package main

import (
	"crypto/rand"
	"fmt"

	"github.com/project-iris/iris/crypto/cyclic"
)

func main() {
	// Generate the cyclic group
	group, err := cyclic.New(rand.Reader, 120)
	if err != nil {
		fmt.Println("Failed to generate cyclic group:", err)
	}
	// Output in a nice, source friendly byte format
	fmt.Println("Cyclic group base:")
	bytes := group.Base.Bytes()
	for byte := 0; byte < len(bytes); byte++ {
		fmt.Printf("0x%02x, ", bytes[byte])
		if byte%8 == 7 {
			fmt.Println()
		}
	}
	fmt.Println()
	// Output in a nice, source friendly byte format
	fmt.Println("Cyclic group generator:")
	bytes = group.Generator.Bytes()
	for byte := 0; byte < len(bytes); byte++ {
		fmt.Printf("0x%02x, ", bytes[byte])
		if byte%8 == 7 {
			fmt.Println()
		}
	}
	fmt.Println()
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	Base      *big.Int
	Generator *big.Int
}

Cyclic group with a safe-prime base.

func New

func New(random io.Reader, bits int) (*Group, error)

Generate a new cyclic group and generator of given bits size.

Jump to

Keyboard shortcuts

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