[#3] signature: Refactor sign and verify
Split methods to separate files, drop redundant intefaces Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
63eb4dc3ea
commit
d005bf0393
7 changed files with 312 additions and 325 deletions
26
signature/marshaller.go
Normal file
26
signature/marshaller.go
Normal file
|
@ -0,0 +1,26 @@
|
|||
package signature
|
||||
|
||||
type stableMarshaler interface {
|
||||
StableMarshal([]byte) []byte
|
||||
StableSize() int
|
||||
}
|
||||
|
||||
type StableMarshalerWrapper struct {
|
||||
SM stableMarshaler
|
||||
}
|
||||
|
||||
func (s StableMarshalerWrapper) ReadSignedData(buf []byte) ([]byte, error) {
|
||||
if s.SM != nil {
|
||||
return s.SM.StableMarshal(buf), nil
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s StableMarshalerWrapper) SignedDataSize() int {
|
||||
if s.SM != nil {
|
||||
return s.SM.StableSize()
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue