Documentation ¶
Overview ¶
Package vpid contains helpers to generate cryptographic IDs.
Index ¶
- Constants
- func GenerateID128(key *vpcrypto.Key, fc FilterChecker, bt BytesTransformer, ...) (*big.Int, []byte, int, error)
- func GenerateID256(key *vpcrypto.Key, fc FilterChecker, bt BytesTransformer, ...) (*big.Int, []byte, int, error)
- func GenerateID32(key *vpcrypto.Key, fc FilterChecker, bt BytesTransformer, ...) (uint32, []byte, int, error)
- func GenerateID512(key *vpcrypto.Key, fc FilterChecker, bt BytesTransformer, ...) (*big.Int, []byte, int, error)
- func GenerateID64(key *vpcrypto.Key, fc FilterChecker, bt BytesTransformer, ...) (uint64, []byte, int, error)
- func ZeroesIn32(i uint32) int
- func ZeroesIn64(i uint64) int
- func ZeroesInBigInt(i *big.Int) int
- func ZeroesInBuf(data []byte) int
- type BytesTransformer
- type FilterChecker
Constants ¶
const NanoScale = 1000000000
NanoScale is the number we should use to transform seconds to nanoseconds.
const PackageCopyright = "Copyright (C) 2015, 2016 Christian Mauduit <ufoot@ufoot.org>" // PackageCopyright set by version.sh
PackageCopyright contains a short copyright notice.
const PackageEmail = "ufoot@ufoot.org" // PackageEmail set by version.sh
PackageEmail contains a contact email for the package.
const PackageLicense = "GNU GPL v3" // PackageLicense set by version.sh
PackageLicense contains a short license information.
const PackageName = "Vapor Toolkit" // PackageName set by version.sh
PackageName contains a readable name of the package, suitable for display.
const PackageTarname = "vapor" // PackageTarname set by version.sh
PackageTarname contains a short name of the package, suitable for a filename.
const PackageURL = "https://github.com/ufoot/vapor" // PackageURL set by version.sh
PackageURL contains the address of the project homepage.
const VersionMajor = 0 // VersionMajor set by version.sh
VersionMajor is the project major version.
const VersionMinor = 3 // VersionMinor set by version.sh
VersionMinor is the project minor version.
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 ¶
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 ¶
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 ¶
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 ¶
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.