This is really unlike most Thai curry pastes (and actually, curry pastes from anywhere) as it’s essentially cooked before you blend it. Most pastes are made raw and then cooked at the beginning of building the dish.
Method
This is less tricky than it sounds but you have to work out which whole spices you’re using and which ground ones. Any combination of whole and ground is ok but you just need to know that if you use the whole spices they need roasting on a dry frying pan before you grind them. If you use ground then the only one that needs roasting is the coriander powder.
Roast each of the whole spices in turn and grind each one while they’re still hot in a pestle and mortar or a spice blender if you have one.
Heat some oil and fry the onions until they are soft and starting to brown then add the garlic and shrimp paste and fry for another minute or so.
Let them cool and then put them in a blender with the chopped lemon grass and grind to a paste. Add water if you need to but do it slowly. Water’s fine because everything is already cooked.
Add the paste to the ground spices in a bowl and mix it all together. You now have Krung Kaeng Masaman.