Documentation
¶
Overview ¶
Sia uses a specific set of cryptographic functions across the entire project. All of those functions are defined and implemented within the siacrypto package to maintain consistency.
Currently, siacrypto is in a state of 'hotfix', meaning we intend to swap out the existing functions for NaCl or libsodium.
Index ¶
- Constants
- func CreateKeyPair() (pubKey PublicKey, secKey SecretKey, err error)
- func RandomByte() byte
- func RandomByteSlice(numBytes int) (randomBytes []byte)
- func RandomInt(ceiling int) int
- func RandomUint16() uint16
- func RandomUint64() (randInt uint64)
- type Hash
- type PublicKey
- type SecretKey
- type Signature
Constants ¶
const ( PublicKeySize = 32 SecretKeySize = 64 SignatureSize = 64 )
Public keys, secret keys, and signatures all use a byte slice for their underlying representation. These sizes are the lengths of those types, in bytes.
const ( // HashSize is the size of a Hash in bytes HashSize int = 32 )
Variables ¶
This section is empty.
Functions ¶
func CreateKeyPair ¶
CreateKeyPair needs no input, produces a public key and secret key as output
func RandomByteSlice ¶
RandomByteSlice returns a slice of random bytes
func RandomUint16 ¶
func RandomUint16() uint16
RandomUint16 returns a random uint16. It accomplishes this by feeding 2 bytes of random data to a binary decoder.
func RandomUint64 ¶
func RandomUint64() (randInt uint64)
RandomUint64 returns a random uint64. It uses the same process as RandomUint16.
Types ¶
type Hash ¶
A Hash is the first 32 bytes of a sha512 checksum.
func HashObject ¶
HashObject converts an object to a byte slice and returns the hash of the byte slice.
type PublicKey ¶
type PublicKey [PublicKeySize]byte
A PublicKey is the binary representation of an ECC public key.
type SecretKey ¶
type SecretKey [SecretKeySize]byte
A SecretKey is the binary representation of an ECC secret key.
func (SecretKey) SignObject ¶
SignObject returns the signature of an object's hash.
type Signature ¶
type Signature [SignatureSize]byte
A Signature is the binary representation of an ECC signature.