Documentation
¶
Index ¶
- Variables
- func CompressPubkey(pubkey *ecdsa.PublicKey) []byte
- func DecompressPubkey(pubkey []byte) (*ecdsa.PublicKey, error)
- func Ecrecover(hash, sig []byte) ([]byte, error)
- func Evaluate(sk *ecdsa.PrivateKey, seed []byte) (index [32]byte, proof []byte)
- func FromECDSA(priv *ecdsa.PrivateKey) []byte
- func FromECDSAPub(pub *ecdsa.PublicKey) []byte
- func GenerateKey() (*ecdsa.PrivateKey, error)
- func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
- func HexToECDSAErrPanic(hexkey string) *ecdsa.PrivateKey
- func Keccak256(data ...[]byte) []byte
- func Keccak512(data ...[]byte) []byte
- func LoadECDSA(file string) (*ecdsa.PrivateKey, error)
- func ProofToHash(pk *ecdsa.PublicKey, seed []byte, proof []byte) (index [32]byte, err error)
- func S256() elliptic.Curve
- func SaveECDSA(file string, key *ecdsa.PrivateKey) error
- func SigToPub(hash, sig []byte) (*ecdsa.PublicKey, error)
- func Sign(hash []byte, prv *ecdsa.PrivateKey) (sig []byte, err error)
- func ToECDSA(d []byte) (*ecdsa.PrivateKey, error)
- func ToECDSAUnsafe(d []byte) *ecdsa.PrivateKey
- func Unmarshal(curve *secp256k1.BitCurve, data []byte) (x, y *big.Int)
- func UnmarshalPubkey(pub []byte) (*ecdsa.PublicKey, error)
- func VRFProve(sk *ecdsa.PrivateKey, seed []byte) (vrf, nizk []byte, err error)
- func VRFVerify(pk *ecdsa.PublicKey, seed, proof []byte) (bool, error)
- func VerifySignature(pubkey, hash, signature []byte) bool
Constants ¶
This section is empty.
Variables ¶
var (
Secp256k1N, _ = new(big.Int).SetString("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141", 16)
Secp256k1halfN = new(big.Int).Div(Secp256k1N, big.NewInt(2))
)
var ( // ErrInvalidVRF occurs when the VRF does not validate. // ErrEvalVRF occurs when unable to generate proof. ErrInvalidVRF = errors.New("invalid VRF proof") ErrEvalVRF = errors.New("failed to evaluate vrf") )
Functions ¶
func CompressPubkey ¶
CompressPubkey encodes a public key to the 33-byte compressed format.
func DecompressPubkey ¶
DecompressPubkey parses a public key in the 33-byte compressed format.
func Evaluate ¶
func Evaluate(sk *ecdsa.PrivateKey, seed []byte) (index [32]byte, proof []byte)
Evaluate returns the verifiable unpredictable(random) function evaluated at seed
func FromECDSA ¶
func FromECDSA(priv *ecdsa.PrivateKey) []byte
FromECDSA exports a private key into a binary dump.
func FromECDSAPub ¶
func GenerateKey ¶
func GenerateKey() (*ecdsa.PrivateKey, error)
func HexToECDSA ¶
func HexToECDSA(hexkey string) (*ecdsa.PrivateKey, error)
HexToECDSA parses a secp256k1 private key.
func HexToECDSAErrPanic ¶
func HexToECDSAErrPanic(hexkey string) *ecdsa.PrivateKey
func LoadECDSA ¶
func LoadECDSA(file string) (*ecdsa.PrivateKey, error)
LoadECDSA loads a secp256k1 private key from the given file.
func ProofToHash ¶
ProofToHash asserts that proof is correct for seedz and outputs index.
func SaveECDSA ¶
func SaveECDSA(file string, key *ecdsa.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(hash []byte, prv *ecdsa.PrivateKey) (sig []byte, err 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 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 ToECDSA ¶
func ToECDSA(d []byte) (*ecdsa.PrivateKey, error)
ToECDSA creates a private key with the given D value.
func ToECDSAUnsafe ¶
func ToECDSAUnsafe(d []byte) *ecdsa.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 secp256k1 public key.
func VRFProve ¶
func VRFProve(sk *ecdsa.PrivateKey, seed []byte) (vrf, nizk []byte, err error)
VRF returns the verifiable random function evaluated seed and an NIZK proof Check if you should use sha256.Sum256(vrf) of the output
func VerifySignature ¶
VerifySignature checks that the given public key created signature over hash. The public key should be in compressed (33 bytes) or uncompressed (65 bytes) format. The signature should have the 64 byte [R || S] format.
Types ¶
This section is empty.
Directories
¶
Path | Synopsis |
---|---|
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. |
Package secp256k1 wraps the bitcoin secp256k1 C library.
|
Package secp256k1 wraps the bitcoin secp256k1 C library. |