Documentation ¶
Overview ¶
Package cache implements a set of caching wrappers around Ed25519 signature verification to transparently accelerate repeated verification with the same public key(s).
Index ¶
- type Cache
- type Verifier
- func (v *Verifier) Add(verifier *ed25519.BatchVerifier, publicKey ed25519.PublicKey, ...)
- func (v *Verifier) AddPublicKey(publicKey ed25519.PublicKey)
- func (v *Verifier) AddWithOptions(verifier *ed25519.BatchVerifier, publicKey ed25519.PublicKey, ...)
- func (v *Verifier) Verify(publicKey ed25519.PublicKey, message, sig []byte) bool
- func (v *Verifier) VerifyWithOptions(publicKey ed25519.PublicKey, message, sig []byte, opts *ed25519.Options) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
type Cache interface { // Get returns a public key's corresponding expanded public key iff // present in the cache, or returns nil. Get(publicKey *curve.CompressedEdwardsY) *ed25519.ExpandedPublicKey // Put adds the expanded public key to the cache. Put(publicKey *curve.CompressedEdwardsY, expanded *ed25519.ExpandedPublicKey) }
Cache is an expanded public key cache.
func NewLRUCache ¶
NewLRUCache creates a new cache with a Least-Recently-Used replacement policy. Cache instances returned are thread-safe.
type Verifier ¶
type Verifier struct {
// contains filtered or unexported fields
}
Verifier verifies signatures, storing expanded public keys in a cache for reuse by subsequent verification with the same public key.
Note: Unless there are more cache hits than misses, this will likely be a net performance loss. Integration should be followed by benchmarking.
func NewVerifier ¶
NewVerifier creates a new Verifier instance backed by a Cache.
func (*Verifier) Add ¶
func (v *Verifier) Add(verifier *ed25519.BatchVerifier, publicKey ed25519.PublicKey, message, sig []byte)
Add will add the signature to the batch verifier.
func (*Verifier) AddPublicKey ¶
AddPublicKey will expand and add the public key to the cache.
func (*Verifier) AddWithOptions ¶
func (v *Verifier) AddWithOptions(verifier *ed25519.BatchVerifier, publicKey ed25519.PublicKey, message, sig []byte, opts *ed25519.Options)
AddWithOptions will add the signature to the batch verifier, with extra Options.