Documentation ¶
Index ¶
- Constants
- func GeneratePrivateRandomBytes(b []byte)
- func GeneratePublicRandomBytes(b []byte)
- func Keccak256(data ...[]byte) []byte
- func PRNGEntropyKick()
- func Secp256k1EcRecover(msg, signature []byte) ([]byte, error)
- func Secp256k1Equals(sk, other []byte) bool
- func Secp256k1GenerateKey() ([]byte, error)
- func Secp256k1GenerateKeyFromSeed(seed io.Reader) ([]byte, error)
- func Secp256k1PublicKey(sk []byte) []byte
- func Secp256k1Sign(sk, toBeSigned []byte) ([]byte, error)
- func Secp256k1SignDigest(sk, msg []byte) ([]byte, error)
- func Secp256k1Verify(pk, toBeVerified, signature []byte) bool
- func Secp256k1VerifyDigest(pk, digest, signature []byte) bool
- type Random
Constants ¶
const Secp256k1PrivateKeyBytes = 32
Secp256k1PrivateKeyBytes is the size of a serialized private key.
const Secp256k1PublicKeyBytes = 65
Secp256k1PublicKeyBytes is the size of a serialized public key.
Variables ¶
This section is empty.
Functions ¶
func GeneratePrivateRandomBytes ¶
func GeneratePrivateRandomBytes(b []byte)
GeneratePrivateRandomBytes generates zero or more random numbers using the Private PRNG instance. These bytes should never be made public. Users of this function should consider creating a separate PRNG using GetNewPrivatePRNG if security domain separation is required.
func GeneratePublicRandomBytes ¶
func GeneratePublicRandomBytes(b []byte)
GeneratePublicRandomBytes generates zero or more random numbers
func PRNGEntropyKick ¶
func PRNGEntropyKick()
PRNGEntropyKick is called when an application event occurs that an attacker on a computer on the network can not observe. For example, when a message arrives, this function can be called. Attackers may know down to the milli or even micro second when a message is serviced. However, they are unlikely to know the timing down to the nearest nano second.
func Secp256k1EcRecover ¶
Secp256k1EcRecover recovers the public key from a message, signature pair.
func Secp256k1Equals ¶
Secp256k1Equals compares two private key for equality and returns true if they are the same.
func Secp256k1GenerateKey ¶
Secp256k1GenerateKey creates a new key using the private PRNG
func Secp256k1GenerateKeyFromSeed ¶
Secp256k1GenerateKeyFromSeed generates a new key from the given reader.
func Secp256k1PublicKey ¶
Secp256k1PublicKey returns the public key for this private key.
func Secp256k1Sign ¶
Secp256k1Sign signs some data and returns the signature.
func Secp256k1SignDigest ¶
Secp256k1SignDigest signs the given message, which must be 32 bytes long.
func Secp256k1Verify ¶
Secp256k1Verify checks the given signature and returns true if it is valid.
func Secp256k1VerifyDigest ¶
Secp256k1VerifyDigest checks the given signature and returns true if it is valid.
Types ¶
type Random ¶
type Random interface { ReadBytes(b []byte) Reseed(seed []byte) QuickReseedKick() GetReader() io.Reader }
Random is the interface for pseudo random number generators in this project.
func GetPrivatePRNG ¶
func GetPrivatePRNG() Random
GetPrivatePRNG returns the PRNG that should be used for generating random values that will stay private.
func GetPublicPRNG ¶
func GetPublicPRNG() Random
GetPublicPRNG returns the PRNG that should be used for generating random values that will become public.
func NewPRNG ¶
NewPRNG returns a new instance of the PRNG. The PRNG has a custom personalisation string, so identical instances on identical hardware should have differently seeded PRNGs.
func NewPrivatePRNG ¶
NewPrivatePRNG returns the PRNG that should be used for generating random values that will stay private. Creating a separate PRNG for each set of usages helps to guarentee security domain separation.