rewrite of crypto.lib: use bigint instead of number