Preheat the oven to 180°C.
Grease a 22 cm square baking tray and line it with baking paper.
Dry-fry the walnuts until golden and fragrant. When cool, chop them into small pieces.
Meanwhile melt the chocolate in a glass bowl over boiling water, cool it and stir in the rum (if used).
Break the eggs into a large bowl, slightly beat them, then add the vanilla and sugar. Mix well. Gently fold in the melted chocolate, stir.
Sieve the flour, cocoa powder and baking powder onto the mixture. Gently fold in. Finally add the walnuts, then transfer into the baking tray. Spread it out evenly.
Bake in the oven for about 25 -30 minutes.
When the top is nicely browned, remove from the oven and leave to cool in the tray.
When completely cooled, cut into squares.