diff options
author | Rasmus Dahlberg <rasmus@rgdd.se> | 2022-10-13 17:47:14 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus@rgdd.se> | 2022-10-13 18:04:49 +0200 |
commit | 2933ba510c7ac41e39b54667e3cb5f11fdea929d (patch) | |
tree | 84008607ffdf624ed0a39d7b25f8ea45b3d2c93f /pkg/oaddr | |
parent | da885286d66203715367f3e3d834268f10e09c97 (diff) |
Add hs_ed25519_secret_key_parsing
Diffstat (limited to 'pkg/oaddr')
-rw-r--r-- | pkg/oaddr/oaddr.go | 3 | ||||
-rw-r--r-- | pkg/oaddr/oaddr_test.go | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/pkg/oaddr/oaddr.go b/pkg/oaddr/oaddr.go index f065ec9..fd8b6a4 100644 --- a/pkg/oaddr/oaddr.go +++ b/pkg/oaddr/oaddr.go @@ -8,6 +8,7 @@ import ( "fmt" "strings" + bed25519 "github.com/cretz/bine/torutil/ed25519" "golang.org/x/crypto/sha3" ) @@ -29,6 +30,8 @@ func NewFromSigner(s crypto.Signer) (addr OnionAddress, err error) { switch t := s.Public().(type) { case ed25519.PublicKey: addr, err = New(s.Public().(ed25519.PublicKey)) + case bed25519.PublicKey: + addr, err = New(s.Public().(bed25519.PublicKey)) default: err = fmt.Errorf("unknown key type: %v", t) } diff --git a/pkg/oaddr/oaddr_test.go b/pkg/oaddr/oaddr_test.go index a37d4de..549bd67 100644 --- a/pkg/oaddr/oaddr_test.go +++ b/pkg/oaddr/oaddr_test.go @@ -5,6 +5,7 @@ import ( "crypto/ed25519" "testing" + bed25519 "github.com/cretz/bine/torutil/ed25519" "sauteed-onions.org/onion-csr/internal/testonly" ) @@ -45,6 +46,7 @@ func TestNewFromSigner(t *testing.T) { }{ {"rsa key", testonly.RSAPriv(t), OnionAddress{}}, {"valid", testonly.Ed25519Priv(t, testPriv), newAddr(t, testPub)}, + {"valid", bed25519.FromCryptoPrivateKey(testonly.Ed25519Priv(t, testPriv)).PrivateKey(), newAddr(t, testPub)}, } { addr, err := NewFromSigner(table.priv) if got, want := err != nil, table.desc != "valid"; got != want { |