crypto: reasonably complete the keypair absraction layer, and use it
This commit is contained in:
@@ -2,6 +2,8 @@ package did
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/INFURA/go-did/crypto"
|
||||
)
|
||||
|
||||
// TryAllVerify tries to verify the signature with all the methods in the slice.
|
||||
@@ -19,10 +21,10 @@ func TryAllVerify(methods []VerificationMethodSignature, data []byte, sig []byte
|
||||
// FindMatchingKeyAgreement tries to find a matching key agreement method for the given private key type.
|
||||
// It returns the shared key as well as the selected method.
|
||||
// If no matching method is found, it returns an error.
|
||||
func FindMatchingKeyAgreement(methods []VerificationMethodKeyAgreement, priv PrivateKey) ([]byte, VerificationMethodKeyAgreement, error) {
|
||||
func FindMatchingKeyAgreement(methods []VerificationMethodKeyAgreement, priv crypto.KeyExchangePrivateKey) ([]byte, VerificationMethodKeyAgreement, error) {
|
||||
for _, method := range methods {
|
||||
if method.PrivateKeyIsCompatible(priv) {
|
||||
key, err := method.ECDH(priv)
|
||||
key, err := method.KeyExchange(priv)
|
||||
return key, method, err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user