Security Analysis of Majority and Selfish Mining Attacks in A Blockchain with Sharding