vpid

package
v0.0.0-...-bf055c7 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package vpid contains helpers to generate cryptographic IDs.

Index

Constants

View Source
const NanoScale = 1000000000

NanoScale is the number we should use to transform seconds to nanoseconds.

View Source
const PackageCopyright = "Copyright (C)  2015, 2016  Christian Mauduit <ufoot@ufoot.org>" // PackageCopyright set by version.sh

PackageCopyright contains a short copyright notice.

View Source
const PackageEmail = "ufoot@ufoot.org" // PackageEmail set by version.sh

PackageEmail contains a contact email for the package.

View Source
const PackageLicense = "GNU GPL v3" // PackageLicense set by version.sh

PackageLicense contains a short license information.

View Source
const PackageName = "Vapor Toolkit" // PackageName set by version.sh

PackageName contains a readable name of the package, suitable for display.

View Source
const PackageTarname = "vapor" // PackageTarname set by version.sh

PackageTarname contains a short name of the package, suitable for a filename.

View Source
const PackageURL = "https://github.com/ufoot/vapor" // PackageURL set by version.sh

PackageURL contains the address of the project homepage.

View Source
const VersionMajor = 0 // VersionMajor set by version.sh

VersionMajor is the project major version.

View Source
const VersionMinor = 3 // VersionMinor set by version.sh

VersionMinor is the project minor version.

View Source
const VersionStamp = "c6a4298" // VersionStamp set by version.sh

VersionStamp is the project stamp, possibly changes for each build.

Variables

This section is empty.

Functions

func GenerateID128

func GenerateID128(key *vpcrypto.Key, fc FilterChecker, bt BytesTransformer, maxSeconds, minZeroes int) (*big.Int, []byte, int, error)

GenerateID128 generates a 128 bits id, and signs it. If key is nil, no signature is generated. If fc is not nil, it is garanteed that the property is verified by the id. If maxSeconds is greater than 0, will wait for this amount of time and try and find an id that has a signature with a checksum containing a maximum of zeroes. This allows deep per-key personnalisation. If minZeroes is greater than 0, will wait until at least that amount of zeroes is achieved, regardless of the maxSeconds setting. This can take a lot of time...

func GenerateID256

func GenerateID256(key *vpcrypto.Key, fc FilterChecker, bt BytesTransformer, maxSeconds, minZeroes int) (*big.Int, []byte, int, error)

GenerateID256 generates a 256 bits id, and signs it. If key is nil, no signature is generated. If fc is not nil, it is garanteed that the property is verified by the id. If maxSeconds is greater than 0, will wait for this amount of time and try and find an id that has a signature with a checksum containing a maximum of zeroes. This allows deep per-key personnalisation. If minZeroes is greater than 0, will wait until at least that amount of zeroes is achieved, regardless of the maxSeconds setting. This can take a lot of time...

func GenerateID32

func GenerateID32(key *vpcrypto.Key, fc FilterChecker, bt BytesTransformer, maxSeconds, minZeroes int) (uint32, []byte, int, error)

GenerateID32 generates a 32 bits id, and signs it. If key is nil, no signature is generated. If fc is not nil, it is garanteed that the property is verified by the id. If maxSeconds is greater than 0, will wait for this amount of time and try and find an id that has a signature with a checksum containing a maximum of zeroes. This allows deep per-key personnalisation. If minZeroes is greater than 0, will wait until at least that amount of zeroes is achieved, regardless of the maxSeconds setting. This can take a lot of time...

func GenerateID512

func GenerateID512(key *vpcrypto.Key, fc FilterChecker, bt BytesTransformer, maxSeconds, minZeroes int) (*big.Int, []byte, int, error)

GenerateID512 generates a 512 bits id, and signs it. If key is nil, no signature is generated. If fc is not nil, it is garanteed that the property is verified by the id. If maxSeconds is greater than 0, will wait for this amount of time and try and find an id that has a signature with a checksum containing a maximum of zeroes. This allows deep per-key personnalisation. If minZeroes is greater than 0, will wait until at least that amount of zeroes is achieved, regardless of the maxSeconds setting. This can take a lot of time...

func GenerateID64

func GenerateID64(key *vpcrypto.Key, fc FilterChecker, bt BytesTransformer, maxSeconds, minZeroes int) (uint64, []byte, int, error)

GenerateID64 generates a 64 bits id, and signs it. If key is nil, no signature is generated. If fc is not nil, it is garanteed that the property is verified by the id. If maxSeconds is greater than 0, will wait for this amount of time and try and find an id that has a signature with a checksum containing a maximum of zeroes. This allows deep per-key personnalisation. If minZeroes is greater than 0, will wait until at least that amount of zeroes is achieved, regardless of the maxSeconds setting. This can take a lot of time...

func ZeroesIn32

func ZeroesIn32(i uint32) int

ZeroesIn32 counts the zeroes at the end of a 32 bits number. For instance, on an odd number, returns 0, but on an even number, returns 1. 0 returns 0.

func ZeroesIn64

func ZeroesIn64(i uint64) int

ZeroesIn64 counts the zeroes at the end of a 64 bits number. For instance, on an odd number, returns 0, but on an even number, returns 1. 0 returns 0.

func ZeroesInBigInt

func ZeroesInBigInt(i *big.Int) int

ZeroesInBigInt counts the zeroes at the end of a big number. For instance, on an odd number, returns 0, but on an even number, returns 1. 0 returns 0.

func ZeroesInBuf

func ZeroesInBuf(data []byte) int

ZeroesInBuf counts the zeroes at the end of a buffer. For instance, if last byte of the buffer is 8, returns 3. 0 returns 0.

Types

type BytesTransformer

type BytesTransformer interface {
	// Transform takes a bytes buffer and returns a transformed bytes buffer
	Transform([]byte) []byte
}

BytesTransformer is used to process a bytes buffer before signing, it

type FilterChecker

type FilterChecker interface {
	// Filter processes the value and returns the
	// filtered value.
	Filter(*big.Int) *big.Int
	// Check should return true if number matches property,
	// false if not.
	Check(*big.Int) bool
}

FilterChecker is used to filter and check wether a number, typically an id, verifies a property or not.

Jump to

Keyboard shortcuts

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