diff --git a/crypto/signature.go b/crypto/signature.go index fa050f0..8718505 100644 --- a/crypto/signature.go +++ b/crypto/signature.go @@ -48,12 +48,7 @@ func (x *Signature) Calculate(signer Signer, data []byte) error { m := (*refs.Signature)(x) - scheme := refs.SignatureScheme(signer.Scheme()) - if scheme > 0 { - scheme-- // to sync numeric values - } - - m.SetScheme(scheme) + m.SetScheme(refs.SignatureScheme(signer.Scheme())) m.SetSign(signature) m.SetKey(key) @@ -69,7 +64,7 @@ func (x *Signature) Calculate(signer Signer, data []byte) error { func (x Signature) Verify(data []byte) bool { m := (*refs.Signature)(&x) - f, ok := publicKeys[Scheme(m.GetScheme()+1)] // increment to sync numeric values + f, ok := publicKeys[Scheme(m.GetScheme())] if !ok { return false } diff --git a/crypto/signer.go b/crypto/signer.go index ec55fbc..1972274 100644 --- a/crypto/signer.go +++ b/crypto/signer.go @@ -6,12 +6,12 @@ import ( // Scheme represents digital signature algorithm with fixed cryptographic hash function. // -// Non-positive values are reserved and depend on context (e.g. unsupported scheme). -type Scheme uint32 +// Negative values are reserved and depend on context (e.g. unsupported scheme). +type Scheme int32 //nolint:revive const ( - _ Scheme = iota + _ Scheme = iota - 1 ECDSA_SHA512 // ECDSA with SHA-512 hashing (FIPS 186-3) ECDSA_DETERMINISTIC_SHA256 // Deterministic ECDSA with SHA-256 hashing (RFC 6979)