Documentation
¶
Index ¶
- Constants
- Variables
- func CertificatePublicKeyToBytes(cert *x509.Certificate) ([]byte, error)
- 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 Groth16Verify(vkBytes []byte, proofBytes []byte, inputsBytes []byte, curve ecc.ID) (bool, error)
- func IsRevoked(cert *x509.Certificate, revocationLists []*x509.RevocationList) bool
- func LoadCertificate(certificates []*x509.Certificate, revocations []*x509.RevocationList, ...) (*x509.Certificate, error)
- func MustBytesFromBase58(s string) []byte
- func NewFastHash() (hash.Hash, error)
- func ParseCertificates(data [][]byte) ([]*x509.Certificate, error)
- func ParseRevocationLists(data [][]byte) ([]*x509.RevocationList, error)
- func SecP256Verify(digest, publicKey, signature []byte) (bool, error)
- 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 VerifyRevocationList(revocationList *x509.RevocationList, certificates []*x509.Certificate, ...) error
- func VerifyVRF(pk PublicKey, msg, signature []byte) (bool, []byte, error)
- 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)
- func (d Digest) Bytes() []byte
- func (d Digest) Hex() string
- func (d *Digest) IsZero() bool
- func (d Digest) MarshalBinary() ([]byte, error)
- func (d Digest) MarshalJSON() ([]byte, error)
- func (d Digest) ShortString() string
- func (d Digest) String() string
- func (d *Digest) UnmarshalBinary(data []byte) error
- func (d *Digest) UnmarshalJSON(value []byte) error
- type IncorrectLengthError
- 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) WriteToBuf(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 ¶
const ( DigestSize = 32 KeySize = 32 PublicKeySize = KeySize SecretKeySize = KeySize SignatureSize = 64 )
const ( P256RawPubKeySize = 64 // X(32) || Y(32) P1363SignatureSize = 64 )
const (
ProofSize = 32 + 32 + 32
)
Variables ¶
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 CertificatePublicKeyToBytes ¶ added in v0.11.0
func CertificatePublicKeyToBytes(cert *x509.Certificate) ([]byte, error)
CertificatePublicKeyToBytes extracts the public key from the provided X.509 certificate. Certificate must contain an ECDSA public key on the NIST P-256 curve.
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
ECDSARecoverPublicKey recovers the public key from the given signature and digest. The signature must be in the [R || S || V] format where V is 27 or 28 (legacy format, not EIP-155). If V is lower than 27, it is converted to the legacy format by adding 27, so acceptable values for V are 0, 1, 27, 28. Signatures after EIP-155 must be converted to the legacy format.
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 adversary. 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 Groth16Verify ¶ added in v0.5.0
func IsRevoked ¶ added in v0.11.0
func IsRevoked(cert *x509.Certificate, revocationLists []*x509.RevocationList) bool
func LoadCertificate ¶ added in v0.11.0
func LoadCertificate( certificates []*x509.Certificate, revocations []*x509.RevocationList, ts time.Time, ) (*x509.Certificate, error)
func MustBytesFromBase58 ¶ added in v0.5.0
func NewFastHash ¶ added in v0.6.0
func ParseCertificates ¶ added in v0.11.0
func ParseCertificates(data [][]byte) ([]*x509.Certificate, error)
func ParseRevocationLists ¶ added in v0.11.0
func ParseRevocationLists(data [][]byte) ([]*x509.RevocationList, error)
func SecP256Verify ¶ added in v0.11.0
SecP256Verify verifies ECDSA signature on NIST P-256. Public key must be in raw (64-byte) format. Signature must be in 64-byte P1363 format (R(32) || S(32)).
func VerifyRevocationList ¶ added in v0.11.0
func VerifyRevocationList(revocationList *x509.RevocationList, certificates []*x509.Certificate, ts time.Time) error
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 IncorrectLengthError ¶ added in v0.10.4
func NewIncorrectLengthError ¶ added in v0.10.4
func NewIncorrectLengthError(name string, len int, expectedLen int) IncorrectLengthError
func (IncorrectLengthError) Error ¶ added in v0.10.4
func (e IncorrectLengthError) Error() string
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, proofsRootToLeafsOrder []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 ¶
func (PublicKey) WriteToBuf ¶ added in v0.10.5
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