Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeVRF(sk SecretKey, msg []byte) []byte
- func Decrypt(key, encrypted []byte) ([]byte, error)
- func ECDSANewPrivateKey() (*btcec.PrivateKey, error)
- func ECDSAParsePublicKey(data []byte) (*btcec.PublicKey, error)
- func ECDSAParsePublicKeyFromHex(hexString string) (*btcec.PublicKey, error)
- func ECDSAPrivateKeyFromBytes(d []byte) (*btcec.PrivateKey, error)
- func ECDSAPrivateKeyFromHexString(hexString string) (*btcec.PrivateKey, error)
- func ECDSARecoverPublicKey(digest, signature []byte) (*btcec.PublicKey, error)
- func ECDSASign(digest []byte, sk *btcec.PrivateKey) ([]byte, error)
- func Encrypt(key, message []byte) ([]byte, error)
- func GenerateKeyPair(seed []byte) (SecretKey, PublicKey, error)
- func MustBytesFromBase58(s string) []byte
- func NewFastHash() (hash.Hash, error)
- func ReadInputs(inputs []byte) ([]*big.Int, error)
- func SerializeInputs(inputs []*big.Int) []byte
- func SharedKey(sk SecretKey, pk PublicKey, prefix []byte) ([]byte, error)
- func SignVRF(sk SecretKey, msg []byte) ([]byte, error)
- func Verify(publicKey PublicKey, sig Signature, data []byte) bool
- func VerifyVRF(pk PublicKey, msg, signature []byte) (bool, []byte, error)
- type Bls12381
- type Bn256
- type Digest
- func FastHash(data []byte) (Digest, error)
- func Keccak256(data []byte) (Digest, error)
- func MustDigestFromBase58(s string) Digest
- func MustFastHash(data []byte) Digest
- func MustKeccak256(data []byte) Digest
- func NewDigestFromBase58(s string) (Digest, error)
- func NewDigestFromBytes(b []byte) (Digest, error)
- func SecureHash(data []byte) (Digest, error)
- type Dummy
- type MerkleTree
- type PublicKey
- func (k *PublicKey) Bytes() []byte
- func (k PublicKey) MarshalBinary() ([]byte, error)
- func (k PublicKey) MarshalJSON() ([]byte, error)
- func (k PublicKey) String() string
- func (k *PublicKey) UnmarshalBinary(data []byte) error
- func (k *PublicKey) UnmarshalJSON(value []byte) error
- func (k PublicKey) WriteTo(buf []byte) error
- type SecretKey
- type Signature
- func (s Signature) Bytes() []byte
- func (s Signature) MarshalBinary() ([]byte, error)
- func (s Signature) MarshalJSON() ([]byte, error)
- func (s Signature) ShortString() string
- func (s Signature) String() string
- func (s *Signature) UnmarshalBinary(data []byte) error
- func (s *Signature) UnmarshalJSON(value []byte) error
Constants ¶
View Source
const ( DigestSize = 32 KeySize = 32 PublicKeySize = KeySize SecretKeySize = KeySize SignatureSize = 64 )
View Source
const (
ProofSize = 32 + 32 + 32
)
Variables ¶
View Source
var (
ZeroDigest = Digest{
0x03, 0x17, 0x0a, 0x2e, 0x75, 0x97, 0xb7, 0xb7, 0xe3, 0xd8, 0x4c, 0x05, 0x39, 0x1d, 0x13, 0x9a,
0x62, 0xb1, 0x57, 0xe7, 0x87, 0x86, 0xd8, 0xc0, 0x82, 0xf2, 0x9d, 0xcf, 0x4c, 0x11, 0x13, 0x14,
}
)
Functions ¶
func ComputeVRF ¶ added in v0.5.0
ComputeVRF generates the VRF value for the byte slice msg using given private key sk.
func ECDSANewPrivateKey ¶ added in v0.10.0
func ECDSANewPrivateKey() (*btcec.PrivateKey, error)
func ECDSAParsePublicKey ¶ added in v0.10.0
func ECDSAParsePublicKeyFromHex ¶ added in v0.10.0
func ECDSAPrivateKeyFromBytes ¶ added in v0.10.0
func ECDSAPrivateKeyFromBytes(d []byte) (*btcec.PrivateKey, error)
ECDSAPrivateKeyFromBytes creates btcec.PrivateKey from 'd' PrivateKey parameter with appropriate checks.
func ECDSAPrivateKeyFromHexString ¶ added in v0.10.0
func ECDSAPrivateKeyFromHexString(hexString string) (*btcec.PrivateKey, error)
ECDSAPrivateKeyFromHexString creates btcec.PrivateKey from hex string with appropriate checks.
func ECDSARecoverPublicKey ¶ added in v0.7.0
func ECDSASign ¶ added in v0.10.0
func ECDSASign(digest []byte, sk *btcec.PrivateKey) ([]byte, error)
ECDSASign 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 hash 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 MustBytesFromBase58 ¶ added in v0.5.0
func NewFastHash ¶ added in v0.6.0
func SerializeInputs ¶ added in v0.10.0
Types ¶
type Digest ¶
type Digest [DigestSize]byte
func MustDigestFromBase58 ¶ added in v0.3.0
func MustFastHash ¶ added in v0.3.0
func MustKeccak256 ¶ added in v0.10.0
func NewDigestFromBase58 ¶
func NewDigestFromBytes ¶ added in v0.2.0
func SecureHash ¶
func (Digest) MarshalBinary ¶
func (Digest) MarshalJSON ¶
func (Digest) ShortString ¶ added in v0.3.0
func (*Digest) UnmarshalBinary ¶
func (*Digest) UnmarshalJSON ¶
type MerkleTree ¶ added in v0.5.0
type MerkleTree struct {
// contains filtered or unexported fields
}
func NewMerkleTree ¶ added in v0.5.0
func NewMerkleTree() (*MerkleTree, error)
func (*MerkleTree) Push ¶ added in v0.5.0
func (t *MerkleTree) Push(data []byte)
func (*MerkleTree) RebuildRoot ¶ added in v0.5.0
func (t *MerkleTree) RebuildRoot(leaf Digest, proofs []Digest, index uint64) Digest
func (*MerkleTree) Root ¶ added in v0.5.0
func (t *MerkleTree) Root() Digest
type PublicKey ¶
type PublicKey [PublicKeySize]byte
func GeneratePublicKey ¶
func MustPublicKeyFromBase58 ¶ added in v0.3.0
func NewPublicKeyFromBase58 ¶
func NewPublicKeyFromBytes ¶ added in v0.2.0
func (PublicKey) MarshalBinary ¶
func (PublicKey) MarshalJSON ¶
func (*PublicKey) UnmarshalBinary ¶
func (*PublicKey) UnmarshalJSON ¶
type SecretKey ¶
type SecretKey [SecretKeySize]byte
func GenerateSecretKey ¶
func MustSecretKeyFromBase58 ¶ added in v0.5.0
func NewSecretKeyFromBase58 ¶
func NewSecretKeyFromBytes ¶ added in v0.3.0
func (SecretKey) MarshalBinary ¶
func (SecretKey) MarshalJSON ¶
func (*SecretKey) UnmarshalBinary ¶
func (*SecretKey) UnmarshalJSON ¶
type Signature ¶
type Signature [SignatureSize]byte
func MustSignatureFromBase58 ¶ added in v0.3.0
func NewSignatureFromBase58 ¶
func NewSignatureFromBytes ¶ added in v0.2.0
func (Signature) MarshalBinary ¶
func (Signature) MarshalJSON ¶
func (Signature) ShortString ¶ added in v0.3.0
func (*Signature) UnmarshalBinary ¶
func (*Signature) UnmarshalJSON ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.