Documentation
¶
Overview ¶
Package bn256 is a wrapper around github.com/cloudflare/bn256.
In addition to generating and using keypairs for signing, it also contains functions needed to implement more involved cryptography, like threshold signatures and multisignatures.
Index ¶
Constants ¶
const SignatureLength = 64
SignatureLength is the length of the returned signatures after marshaling. It is not explicitly defined in the underlaying package, but it is always 64.
Variables ¶
var Order = bn256.Order
Order reexports cloudflare/bn256.Order.
Functions ¶
func GenerateKeys ¶
func GenerateKeys() (*VerificationKey, *SecretKey, error)
GenerateKeys randomly.
func VerifyKeys ¶
func VerifyKeys(vk *VerificationKey, sk *SecretKey) bool
VerifyKeys checks whether given secretKey and verificationKey forms a vaild pair.
Types ¶
type PolyVerifier ¶
type PolyVerifier struct {
// contains filtered or unexported fields
}
PolyVerifier is a struct which can verify if the given sequence is a polynomial sequence of bounded degree.
func NewPolyVerifier ¶
func NewPolyVerifier(n, f int) PolyVerifier
NewPolyVerifier returns a verifier of polynomial sequences of degree at most f and length n. We assume 0 <= f <= n-1.
func (*PolyVerifier) Verify ¶
func (pv *PolyVerifier) Verify(elems []*VerificationKey) bool
Verify if the given sequence of elems is a polynomial sequence with bounded degree.
type SecretKey ¶
type SecretKey struct {
// contains filtered or unexported fields
}
SecretKey can be used to sign data.
func AddSecretKeys ¶
AddSecretKeys returns a sum of the provided secret keys. If the first argument is nil, it treats it as a zero.
func DecodeSecretKey ¶
DecodeSecretKey decodes a secret key encoded as a base64 string.
func NewSecretKey ¶
NewSecretKey returns a secret key with the specified secret.
func (*SecretKey) VerificationKey ¶
func (sk *SecretKey) VerificationKey() *VerificationKey
VerificationKey returns the verification key associated with this secret key.
type Signature ¶
Signature confirms some information.
func AddSignatures ¶
AddSignatures returns a sum of the provided signatures. If the first argument is nil, it treats it as a zero.
func MulSignature ¶
MulSignature returns the provided signature multiplied by the integer. If the first argument is nil, it treats it as a one.
type VerificationKey ¶
type VerificationKey struct {
// contains filtered or unexported fields
}
VerificationKey can verify the validity of signatures.
func AddVerificationKeys ¶
func AddVerificationKeys(vk1, vk2 *VerificationKey) *VerificationKey
AddVerificationKeys returns a sum of the provided verification keys. If the first argument is nil, it treats it as a zero.
func DecodeVerificationKey ¶
func DecodeVerificationKey(enc string) (*VerificationKey, error)
DecodeVerificationKey decodes a verification key encoded as a base64 string.
func NewVerificationKey ¶
func NewVerificationKey(secret *big.Int) *VerificationKey
NewVerificationKey returns a verification key for the specified secret.
func (*VerificationKey) Encode ¶
func (vk *VerificationKey) Encode() string
Encode encodes given VerificationKey into a base64 string
func (*VerificationKey) Marshal ¶
func (vk *VerificationKey) Marshal() []byte
Marshal the verification key.
func (*VerificationKey) Unmarshal ¶
func (vk *VerificationKey) Unmarshal(data []byte) (*VerificationKey, error)
Unmarshal the verification key.