forked from TrueCloudLab/frostfs-sdk-go
[#190] Refactor cryptographic functionality
Remove `signature` and `util/signature` packages. Re-implement their functionality in new `crypto` package. Generalize the approach of digital signature computation and verification by adding `Signer` and `PublicKey` primitives similar to standard `crypto` package. Support already exising in protocol signature schemes. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
2deaaeef05
commit
ea043f4ca3
33 changed files with 728 additions and 627 deletions
48
crypto/doc.go
Normal file
48
crypto/doc.go
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
Package neofscrypto collects NeoFS cryptographic primitives.
|
||||
|
||||
Signer type unifies entities for signing NeoFS data.
|
||||
// instantiate Signer
|
||||
// select data to be signed
|
||||
|
||||
var sig Signature
|
||||
|
||||
err := sig.Calculate(signer, data)
|
||||
// ...
|
||||
|
||||
// attach signature to the request
|
||||
|
||||
SDK natively supports several signature schemes that are implemented
|
||||
in nested packages.
|
||||
|
||||
PublicKey allows to verify signatures.
|
||||
// get signature to be verified
|
||||
// compose signed data
|
||||
|
||||
isValid := sig.Verify(data)
|
||||
// ...
|
||||
|
||||
Signature can be also used to process NeoFS API V2 protocol messages
|
||||
(see neo.fs.v2.refs package in https://github.com/nspcc-dev/neofs-api).
|
||||
|
||||
On client side:
|
||||
import "github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||
|
||||
var msg refs.Signature
|
||||
sig.WriteToV2(&msg)
|
||||
|
||||
// send msg
|
||||
|
||||
On server side:
|
||||
// recv msg
|
||||
|
||||
var sig neofscrypto.Signature
|
||||
sig.ReadFromV2(msg)
|
||||
|
||||
// process sig
|
||||
|
||||
Using package types in an application is recommended to potentially work with
|
||||
different protocol versions with which these types are compatible.
|
||||
|
||||
*/
|
||||
package neofscrypto
|
Loading…
Add table
Add a link
Reference in a new issue