implement key marshaling