alg.go
func (alg Algorithm) New(keyset interface{}) (Signer, error) {
	a := algSet[alg]

	// check hash
	if !a.hash.Available() {
		return nil, ErrInvalidHash
	}

	var s Store

	// load the data
	switch p := keyset.(type) {
	// regular store
	case Store:
		s = p

	// raw key
	case []byte:
		s = &Keystore{Key: p}

	// rsa keys
	case *rsa.PrivateKey:
		s = &Keystore{Key: p}
	case *rsa.PublicKey:
		s = &Keystore{PubKey: p}

	// ecc keys
	case *ecdsa.PrivateKey:
		s = &Keystore{Key: p}
	case *ecdsa.PublicKey:
		s = &Keystore{PubKey: p}

	default:
		return nil, ErrInvalidKeyset
	}

	return a.init(s, a.hash)
}
func (alg Algorithm) New(keyset interface{}) (Signer, error) {
	a := algSet[alg]

	// check hash
	if !a.hash.Available() {
		return nil, ErrInvalidHash
	}

	var s Store

	// load the data
	switch p := keyset.(type) {
	// regular store
	case Store:
		s = p

	// raw key
	case []byte:
		s = &Keystore{Key: p}

	// rsa keys
	case *rsa.PrivateKey:
		s = &Keystore{Key: p}
	case *rsa.PublicKey:
		s = &Keystore{PubKey: p}

	// ecc keys
	case *ecdsa.PrivateKey:
		s = &Keystore{Key: p}
	case *ecdsa.PublicKey:
		s = &Keystore{PubKey: p}

	default:
		return nil, ErrInvalidKeyset
	}

	return a.init(s, a.hash)
}
// New creates a Signer using the supplied keyset.
//
// The keyset can be of type []byte, *rsa.{PrivateKey,PublicKey},
// *ecdsa.{PrivateKey,PublicKey}, or compatible with the Store interface.
//
// If a private key is not provided, tokens cannot be Encode'd.  Public keys
// will be automatically generated for RSA and ECC private keys if none were
// provided in the keyset.