Skip to content

Commit

Permalink
remove references to go-ethereum (#69)
Browse files Browse the repository at this point in the history
Updated secretvault.go to just return the hex string and
removed the offending (but still available in avid) did code that
also uses it.

re AB#9191

Co-authored-by: Henry Jewell <[email protected]>
  • Loading branch information
henry739 and Henry Jewell authored May 7, 2024
1 parent 298c4f1 commit 2c5ead5
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 473 deletions.
13 changes: 3 additions & 10 deletions azkeys/secretvault.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package azkeys

import (
"context"
"crypto/ecdsa"
"fmt"
"net/url"
"os"
Expand All @@ -14,7 +13,6 @@ import (
"github.com/Azure/go-autorest/autorest"
"github.com/datatrails/go-datatrails-common/logger"
"github.com/datatrails/go-datatrails-common/tracing"
"github.com/ethereum/go-ethereum/crypto"
)

const (
Expand Down Expand Up @@ -121,9 +119,9 @@ func (k *SecretVault) ReadSecret(
return entry, nil
}

func (k *SecretVault) GetOrgKey(
func (k *SecretVault) GetOrgKeyHex(
ctx context.Context, id string,
) (*ecdsa.PrivateKey, error) {
) (*string, error) {
log := logger.Sugar.FromContext(ctx)
defer log.Close()

Expand All @@ -134,12 +132,7 @@ func (k *SecretVault) GetOrgKey(
return nil, err
}

r, err := crypto.HexToECDSA(strings.TrimPrefix(*secret.Value, "0x"))
if err != nil {
log.Infof("could not do ecdsa from key: %v", err)
}

return r, err
return secret.Value, err
}

// ListSecrets whose id's match prefix and whose tags include all of the
Expand Down
34 changes: 0 additions & 34 deletions did/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,11 @@ import (
"crypto/ecdsa"
"crypto/ed25519"
"crypto/rsa"
"os"

"github.com/datatrails/go-datatrails-common/logger"
ethcrypto "github.com/ethereum/go-ethereum/crypto"
"github.com/lestrrat-go/jwx/jwk"
)

/**
* Keys handles the keys found as part of DID verificationMethod's
*/

// readRawECDSAPrivateKey reads a file containing a raw ecdsa private key in hex format and returns it
func readRawECDSAPrivateKey(keyFile string) (*ecdsa.PrivateKey, error) {

pemKey, err := os.ReadFile(keyFile)
if err != nil {
return nil, err
}

key, err := getRawECDSAPrivateKey(pemKey)
if err != nil {
return nil, err
}

return key, err

}

// getRawECDSAPrivateKey gets an ECDSA private key from a given hex byte slice.
func getRawECDSAPrivateKey(pemKey []byte) (*ecdsa.PrivateKey, error) {

privateKey, err := ethcrypto.HexToECDSA(string(pemKey))
if err != nil {
return nil, err
}

return privateKey, err
}

// jwkToPublicKey converts a jwk key into a public key
// The following public keys are supported:
//
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ require (
github.com/Azure/go-autorest/autorest/azure/auth v0.5.12
github.com/KimMachineGun/automemlimit v0.2.6
github.com/alicebob/miniredis/v2 v2.32.1
github.com/ethereum/go-ethereum v0.0.0-20221208112643-d318a5aa973a
github.com/fxamacker/cbor/v2 v2.5.0
github.com/go-redis/redis/v8 v8.11.5
github.com/google/uuid v1.3.1
Expand Down Expand Up @@ -51,7 +50,6 @@ require (
github.com/Azure/go-amqp v1.0.0 // indirect
github.com/alicebob/gopher-json v0.0.0-20200520072559-a9ecdc9d1d3a // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd v0.20.1-beta // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
Expand Down
Loading

0 comments on commit 2c5ead5

Please sign in to comment.