forked from TrueCloudLab/frostfs-sdk-go
[#150] signature: Add scheme
Allow `SignOption` to set 2 parameters: 1. Default signature scheme, which is used in case scheme is unspecified. 2. Restrict scheme option which also checks that scheme is either unspecified or equal to the restricted scheme. This is only used for verification and is necessary because some of the signatures are used in smart-contracts. Also provide signature struct to sign/verify functions in helpers. The constant names differ a bit from those in API because of linter complaints. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
4fba1af6aa
commit
1c7dd03cf5
8 changed files with 129 additions and 131 deletions
|
@ -94,9 +94,8 @@ func CalculateIDSignature(key *ecdsa.PrivateKey, id *oid.ID) (*signature.Signatu
|
|||
signatureV2.StableMarshalerWrapper{
|
||||
SM: id.ToV2(),
|
||||
},
|
||||
func(key, sign []byte) {
|
||||
sig.SetKey(key)
|
||||
sig.SetSign(sign)
|
||||
func(s *signature.Signature) {
|
||||
*sig = *s
|
||||
},
|
||||
); err != nil {
|
||||
return nil, err
|
||||
|
@ -121,11 +120,7 @@ func VerifyIDSignature(obj *Object) error {
|
|||
signatureV2.StableMarshalerWrapper{
|
||||
SM: obj.ID().ToV2(),
|
||||
},
|
||||
func() ([]byte, []byte) {
|
||||
sig := obj.Signature()
|
||||
|
||||
return sig.Key(), sig.Sign()
|
||||
},
|
||||
obj.Signature,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue