Hierarchical and shared key assignment