forked from TrueCloudLab/frostfs-sdk-go
neofsecdsa: Add StaticSigner for externally calculated hashes
Signed-off-by: Evgenii Baidakov <evgenii@nspcc.io>
This commit is contained in:
parent
6ac961d41c
commit
70df422866
1 changed files with 35 additions and 0 deletions
|
@ -92,3 +92,38 @@ type PublicKey interface {
|
|||
// Verify checks signature of the given data. True means correct signature.
|
||||
Verify(data, signature []byte) bool
|
||||
}
|
||||
|
||||
// StaticSigner emulates real sign and contains already precalculated hash.
|
||||
// Provides neofscrypto.Signer interface.
|
||||
type StaticSigner struct {
|
||||
scheme Scheme
|
||||
sig []byte
|
||||
pubKey PublicKey
|
||||
}
|
||||
|
||||
// NewStaticSigner creates new StaticSigner.
|
||||
func NewStaticSigner(scheme Scheme, sig []byte, pubKey PublicKey) *StaticSigner {
|
||||
return &StaticSigner{
|
||||
scheme: scheme,
|
||||
sig: sig,
|
||||
pubKey: pubKey,
|
||||
}
|
||||
}
|
||||
|
||||
// Scheme returns neofscrypto.ECDSA_DETERMINISTIC_SHA256.
|
||||
// Implements neofscrypto.Signer.
|
||||
func (s *StaticSigner) Scheme() Scheme {
|
||||
return s.scheme
|
||||
}
|
||||
|
||||
// Sign returns precalculated hash.
|
||||
// Implements neofscrypto.Signer.
|
||||
func (s *StaticSigner) Sign(_ []byte) ([]byte, error) {
|
||||
return s.sig, nil
|
||||
}
|
||||
|
||||
// Public returns neofscrypto.PublicKey.
|
||||
// Implements neofscrypto.Signer.
|
||||
func (s *StaticSigner) Public() PublicKey {
|
||||
return s.pubKey
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue