Section 39. When an electronic voting system, voting machines or ballot boxes are purchased by the commonwealth or by a city or town, the persons of whom the purchase is made shall give to the state secretary, city or town clerk or election commissioners, as the case may be, a bond with sufficient sureties to keep such system, machines or ballot boxes in working order for two years. Such persons shall also give a bond with sufficient sureties, conditioned to defend and indemnify the commonwealth or cities and towns purchasing, leasing or using the system, machines or ballot boxes against any legal action and for any expense, damage or inconvenience which they may incur or suffer by reason of any suit brought against them for infringement of patents or other rights, arising from the purchase, lease, or use of such system, machines or ballot boxes.