Mechanotransduction in vertebrate hair cells involves a biophysically defined elastic element (the "gating spring") that pulls on the transduction channels. The tip link, a fine filament made of cadherin 23 linking adjacent stereocilia in hair-cell bundles, has been suggested to be the gating spring. However, TRP channels that mediate mechanotransduction in Drosophila, zebrafish, and mice often have cytoplasmic domains containing a large number of ankyrin repeats that are also candidates for the gating spring. We have explored the elastic properties of cadherin and ankyrin repeats through molecular dynamics simulations using crystallographic structures of proteins with one cadherin repeat or 4 and 12 ankyrin repeats, and using models of 17 and 24 ankyrin repeats. The extension and stiffness of large ankyrin-repeat structures were found to match those predicted by the gating-spring model. Our results suggest that ankyrin repeats of TRPA1 and TRPN1 channels serve as the gating spring for mechanotransduction.