Documentation ¶
Index ¶
- Constants
- func CreateAddress(b common.Address, nonce uint64) common.Address
- func CreateAddress2(b common.Address, salt [64]byte, inithash []byte) common.Address
- func Ecrecover(hash, sig []byte) ([]byte, error)
- func FromECDSA(priv *gost3410.PrivateKey) []byte
- func FromECDSAPub(pub *gost3410.PublicKey) []byte
- func GenerateKey() (*gost3410.PrivateKey, error)
- func HashData(kh StreebogState, data []byte) (h common.Hash)
- func HexToECDSA(hexkey string) (*gost3410.PrivateKey, error)
- func Keccak256(data ...[]byte) []byte
- func LoadECDSA(file string) (*gost3410.PrivateKey, error)
- func PubkeyToAddress(p gost3410.PublicKey) common.Address
- func SaveECDSA(file string, key *gost3410.PrivateKey) error
- func SigToPub(hash, sig []byte) (*gost3410.PublicKey, error)
- func Sign(digestHash []byte, prv *gost3410.PrivateKey) ([]byte, error)
- func Streebog256(data ...[]byte) []byte
- func Streebog256Hash(data ...[]byte) (h common.Hash)
- func Streebog512(data ...[]byte) []byte
- func Streebog512Hash(data ...[]byte) (h common.Hash)
- func ToECDSA(d []byte) (*gost3410.PrivateKey, error)
- func ToECDSAUnsafe(d []byte) *gost3410.PrivateKey
- func UnmarshalPubkey(pub []byte) (*gost3410.PublicKey, error)
- func ValidateSignatureValues(v byte, r, s *big.Int, homestead bool) bool
- func VerifySignature(pubkey, digestHash, signature []byte) (bool, error)
- type KeccakState
- type StreebogState
Constants ¶
const DigestLength = 64
DigestLength sets the signature digest exact length
const RecoveryIDOffset = 128
RecoveryIDOffset points to the byte offset within the signature that contains the recovery id.
const SignatureLength = 128 + 1 // 64 bytes ECDSA signature + 1 byte recovery id
SignatureLength indicates the byte length required to carry a signature with recovery id.
Variables ¶
This section is empty.
Functions ¶
func CreateAddress ¶
CreateAddress creates an ethereum address given the bytes and the nonce
func CreateAddress2 ¶
CreateAddress2 creates an ethereum address given the address bytes, initial contract code hash and a salt.
func FromECDSA ¶
func FromECDSA(priv *gost3410.PrivateKey) []byte
FromECDSA exports a private key into a binary dump.
func FromECDSAPub ¶
func GenerateKey ¶
func GenerateKey() (*gost3410.PrivateKey, error)
GenerateKey generates a new private key.
func HashData ¶
func HashData(kh StreebogState, data []byte) (h common.Hash)
HashData hashes the provided data using the KeccakState and returns a 32 byte hash
func HexToECDSA ¶
func HexToECDSA(hexkey string) (*gost3410.PrivateKey, error)
HexToECDSA parses a gost3410 private key.
func LoadECDSA ¶
func LoadECDSA(file string) (*gost3410.PrivateKey, error)
LoadECDSA loads a secp256k1 private key from the given file.
func SaveECDSA ¶
func SaveECDSA(file string, key *gost3410.PrivateKey) error
SaveECDSA saves a secp256k1 private key to the given file with restrictive permissions. The key data is saved hex-encoded.
func Sign ¶
func Sign(digestHash []byte, prv *gost3410.PrivateKey) ([]byte, error)
Sign calculates an ECDSA signature.
This function is susceptible to chosen plaintext attacks that can leak information about the private key that is used for signing. Callers must be aware that the given digest cannot be chosen by an adversery. Common solution is to hash any input before calculating the signature.
The produced signature is in the [R || S || V] format where V is 0 or 1.
func Streebog256 ¶
Sreebog256 calculates and returns the Streebog256 hash of the input data.
func Streebog256Hash ¶
Sreebog256Hash calculates and returns the Sreebog256 hash of the input data, converting it to an internal Hash data structure.
func Streebog512 ¶
Keccak512 calculates and returns the Keccak512 hash of the input data.
func Streebog512Hash ¶
Sreebog512Hash calculates and returns the Sreebog512 hash of the input data, converting it to an internal Hash data structure.
func ToECDSA ¶
func ToECDSA(d []byte) (*gost3410.PrivateKey, error)
ToECDSA creates a private key with the given D value.
func ToECDSAUnsafe ¶
func ToECDSAUnsafe(d []byte) *gost3410.PrivateKey
ToECDSAUnsafe blindly converts a binary blob to a private key. It should almost never be used unless you are sure the input is valid and want to avoid hitting errors due to bad origin encoding (0 prefixes cut off).
func UnmarshalPubkey ¶
UnmarshalPubkey converts bytes to a gost3410 public key.
func ValidateSignatureValues ¶
ValidateSignatureValues verifies whether the signature values are valid with the given chain rules. The v value is assumed to be either 0 or 1.
func VerifySignature ¶
VerifySignature checks that the given public key created signature over digest. The public key should be in compressed (65 bytes) or uncompressed (128 bytes) format. The signature should have the 128 byte [R || S] format.
Types ¶
type KeccakState ¶
KeccakState wraps sha3.state. In addition to the usual hash methods, it also supports Read to get a variable amount of data from the hash state. Read is faster than Sum because it doesn't copy the internal state, but also modifies the internal state.
type StreebogState ¶
func NewStreebogState ¶
func NewStreebogState(n int) StreebogState
NewStreebogState creates a new StreebogState
Directories ¶
Path | Synopsis |
---|---|
Package blake2b implements the BLAKE2b hash algorithm defined by RFC 7693 and the extendable output function (XOF) BLAKE2Xb.
|
Package blake2b implements the BLAKE2b hash algorithm defined by RFC 7693 and the extendable output function (XOF) BLAKE2Xb. |
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
|
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve. |
cloudflare
Package bn256 implements a particular bilinear group at the 128-bit security level.
|
Package bn256 implements a particular bilinear group at the 128-bit security level. |
google
Package bn256 implements a particular bilinear group.
|
Package bn256 implements a particular bilinear group. |
GOST R 34.10-2001 (RFC 5832), GOST R 34.10-2012 (RFC 7091) signature algorithms and VKO GOST R 34.10-2001 (RFC 4357), VKO GOST R 34.10-2012 (RFC 7836) key agreement algorithms.
|
GOST R 34.10-2001 (RFC 5832), GOST R 34.10-2012 (RFC 7091) signature algorithms and VKO GOST R 34.10-2001 (RFC 4357), VKO GOST R 34.10-2012 (RFC 7836) key agreement algorithms. |
GOST R 34.11-2012 hash function.
|
GOST R 34.11-2012 hash function. |