crypto: reasonably complete the keypair absraction layer, and use it

This commit is contained in:
Michael Muré
2025-06-24 14:05:42 +02:00
parent 162aff3046
commit 371d9f55b2
22 changed files with 195 additions and 480 deletions

View File

@@ -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
}
}