Rewrite asetkey to support extended key types