The Brazilian finance minister and architect of the government's market-friendly economic policies has resigned amid a corruption scandal.