Secure distributed data aggregation in the automatic metering infrastructure of smart grids