Documentation
¶
Index ¶
- Variables
- func BitcoinAddressFromPubkey(pubkey PubKey) string
- func BitcoinWalletImportFormatFromSeckey(seckey SecKey) string
- func ChkSig(address Address, hash SHA256, sig Sig) error
- func DeterministicKeyPairIterator(seed []byte) ([]byte, PubKey, SecKey)
- func ECDH(pub PubKey, sec SecKey) []byte
- func GenerateDeterministicKeyPair(seed []byte) (PubKey, SecKey)
- func GenerateKeyPair() (PubKey, SecKey)
- func RandByte(n int) []byte
- func TestSecKey(seckey SecKey) error
- func TestSecKeyHash(seckey SecKey, hash SHA256) error
- func VerifySignature(pubkey PubKey, sig Sig, hash SHA256) error
- func VerifySignedHash(sig Sig, hash SHA256) error
- type Address
- func AddressFromPubKey(pubKey PubKey) Address
- func AddressFromSecKey(secKey SecKey) Address
- func BitcoinAddressFromBytes(b []byte) (Address, error)
- func BitcoinDecodeBase58Address(addr string) (Address, error)
- func BitcoinMustDecodeBase58Address(addr string) Address
- func DecodeBase58Address(addr string) (Address, error)
- func MustDecodeBase58Address(addr string) Address
- func (addr *Address) BitcoinBytes() []byte
- func (addr *Address) BitcoinChecksum() Checksum
- func (addr Address) BitcoinString() string
- func (addr *Address) Bytes() []byte
- func (addr *Address) Checksum() Checksum
- func (addr Address) Null() bool
- func (addr Address) String() string
- func (addr Address) Verify(key PubKey) error
- type Checksum
- type PubKey
- type PubKeySlice
- type Ripemd160
- type SHA256
- type SecKey
- func GenerateDeterministicKeyPairs(seed []byte, n int) []SecKey
- func GenerateDeterministicKeyPairsSeed(seed []byte, n int) ([]byte, []SecKey)
- func MustSecKeyFromHex(s string) SecKey
- func MustSecKeyFromWalletImportFormat(input string) SecKey
- func NewSecKey(b []byte) SecKey
- func SecKeyFromHex(s string) (SecKey, error)
- func SecKeyFromWalletImportFormat(input string) (SecKey, error)
- type Sig
Constants ¶
This section is empty.
Variables ¶
var ( // DebugLevel1 debug level one DebugLevel1 = true //checks for extremely unlikely conditions (10e-40) // DebugLevel2 debug level two DebugLevel2 = true //enable checks for impossible conditions )
Functions ¶
func BitcoinAddressFromPubkey ¶
BitcoinAddressFromPubkey prints the bitcoin address for a seckey
func BitcoinWalletImportFormatFromSeckey ¶
BitcoinWalletImportFormatFromSeckey exports seckey in wallet import format key must be compressed
func ChkSig ¶
ChkSig checks whether PubKey corresponding to address hash signed hash - recovers the PubKey from sig and hash - fail if PubKey cannot be be recovered - computes the address from the PubKey - fail if recovered address does not match PubKey hash - verify that signature is valid for hash for PubKey
func DeterministicKeyPairIterator ¶
DeterministicKeyPairIterator takes SHA256 value, returns a new SHA256 value and publickey and private key. Apply multiple times feeding the SHA256 value back into generate sequence of keys
func ECDH ¶
ECDH generates a shared secret A: pub1,sec1 B: pub2,sec2 person A sends their public key pub1 person B sends an emphameral pubkey pub2 person A computes cipher.ECDH(pub2, sec1) person B computes cipher.ECDH(pub1, sec2) cipher.ECDH(pub2, sec1) equals cipher.ECDH(pub1, sec2) This is their shared secret
func GenerateDeterministicKeyPair ¶
GenerateDeterministicKeyPair generates deterministic key pair
func TestSecKeyHash ¶
TestSecKeyHash performs a series of tests to determine if a seckey is valid. All generated keys and keys loaded from disc must pass the TestSecKey suite. TestPrivKey returns error if a key fails any test in the test suite.
func VerifySignature ¶
VerifySignature verifies that hash was signed by PubKey
func VerifySignedHash ¶
VerifySignedHash this only checks that the signature can be converted to a public key Since there is no pubkey or address argument, it cannot check that the signature is valid in that context.
Types ¶
type Address ¶
Address version is after Key to enable better vanity address generation Address stuct is a 25 byte with a 20 byte publickey hash, 1 byte address type and 4 byte checksum.
func AddressFromPubKey ¶
AddressFromPubKey creates Address from PubKey as ripemd160(sha256(sha256(pubkey)))
func AddressFromSecKey ¶
AddressFromSecKey generates address from secret key
func BitcoinAddressFromBytes ¶
BitcoinAddressFromBytes Returns an address given an Address.Bytes()
func BitcoinDecodeBase58Address ¶
BitcoinDecodeBase58Address decode bitcoin address from string
func BitcoinMustDecodeBase58Address ¶
BitcoinMustDecodeBase58Address must decodes bitcoin address from string
func DecodeBase58Address ¶
DecodeBase58Address creates an Address from its base58 encoding
func MustDecodeBase58Address ¶
MustDecodeBase58Address creates an Address from its base58 encoding. Will panic if the addr is invalid
func (*Address) BitcoinBytes ¶
BitcoinBytes returns bitcoin address as byte slice
func (*Address) BitcoinChecksum ¶
BitcoinChecksum bitcoin checksum
func (Address) BitcoinString ¶
BitcoinString convert bitcoin address to hex string
func (*Address) Checksum ¶
Checksum returns Address Checksum which is the first 4 bytes of sha256(key+version)
type PubKey ¶
type PubKey [33]byte
PubKey public key
func MustPubKeyFromHex ¶
MustPubKeyFromHex decodes a hex encoded PubKey, or panics
func PubKeyFromHex ¶
PubKeyFromHex generates PubKey from hex string
func PubKeyFromSecKey ¶
PubKeyFromSecKey recovers the public key for a secret key
func PubKeyFromSig ¶
PubKeyFromSig recovers the public key from a signed hash
func (*PubKey) ToAddressHash ¶
ToAddressHash returns the public key as ripemd160(sha256(sha256(key)))
type SHA256 ¶
type SHA256 [32]byte
SHA256 32 bytes
func Merkle ¶
Merkle computes the merkle root of a hash array Array of hashes is padded with 0 hashes until next power of 2
func MustSHA256FromHex ¶
MustSHA256FromHex same as SHA256FromHex, except will panic when detect error
func MustSumSHA256 ¶
MustSumSHA256 like SumSHA256, but len(b) must equal n, or panic
func SHA256FromHex ¶
SHA256FromHex decodes a hex encoded SHA256 hash to bytes. If invalid, will return error. Does not panic.
type SecKey ¶
type SecKey [32]byte
SecKey secret key
func GenerateDeterministicKeyPairs ¶
GenerateDeterministicKeyPairs returns sequence of n private keys from initial seed
func GenerateDeterministicKeyPairsSeed ¶
GenerateDeterministicKeyPairsSeed returns sequence of n private keys from initial seed, and return the new seed
func MustSecKeyFromHex ¶
MustSecKeyFromHex decodes a hex encoded SecKey, or panics
func MustSecKeyFromWalletImportFormat ¶
MustSecKeyFromWalletImportFormat SecKeyFromWalletImportFormat or panic
func SecKeyFromHex ¶
SecKeyFromHex decodes a hex encoded SecKey, or panics
func SecKeyFromWalletImportFormat ¶
SecKeyFromWalletImportFormat extracts a seckey from wallet import format
type Sig ¶
type Sig [64 + 1]byte //64 byte signature with 1 byte for key recovery
Sig signature
func MustSigFromHex ¶
MustSigFromHex decodes a hex-encoded Sig, panicing if invalid
func SigFromHex ¶
SigFromHex generates signature from hex string
Directories
¶
| Path | Synopsis |
|---|---|
|
Package chacha20poly1305 implements the ChaCha20-Poly1305 AEAD as specified in RFC 7539.
|
Package chacha20poly1305 implements the ChaCha20-Poly1305 AEAD as specified in RFC 7539. |
|
internal/chacha20
Package chacha20 implements the core ChaCha20 function as specified in https://tools.ietf.org/html/rfc7539#section-2.3.
|
Package chacha20 implements the core ChaCha20 function as specified in https://tools.ietf.org/html/rfc7539#section-2.3. |
|
Package encoder binary implements translation between numbers and byte sequences and encoding and decoding of varints.
|
Package encoder binary implements translation between numbers and byte sequences and encoding and decoding of varints. |
|
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0.
|
Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 2898 / PKCS #5 v2.0. |
|
Package poly1305 implements Poly1305 one-time message authentication code as specified in http://cr.yp.to/mac/poly1305-20050329.pdf.
|
Package poly1305 implements Poly1305 one-time message authentication code as specified in http://cr.yp.to/mac/poly1305-20050329.pdf. |
|
Package ripemd160 implements the RIPEMD-160 hash algorithm.
|
Package ripemd160 implements the RIPEMD-160 hash algorithm. |
|
Package scrypt implements the scrypt key derivation function as defined in Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard Functions" (http://www.tarsnap.com/scrypt/scrypt.pdf).
|
Package scrypt implements the scrypt key derivation function as defined in Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard Functions" (http://www.tarsnap.com/scrypt/scrypt.pdf). |
|
nolint: golint
|
nolint: golint |