# bignum

##### 将大数提高到大幂并对其进行大量修改？(Raising large number to large power and mod it by a large number?)

2021-06-12 23:06:24    分类:技术分享    c   bignum

##### Openssl, Invalid arguments ' Candidates are: int BN_set_word(bignum_st *, ?) '

I am using OpenSSL for a cuda project. I just imported all the project from win to linux (Eclipse) I solved all the dependencies except this annoying error: Invalid arguments ' Candidates are: int BN_set_word(bignum_st *, ?) ' for this line: BN_set_word(two, 2); and the function itself says in the bn.h int BN_set_word(BIGNUM *a, BN_ULONG w); Where BN_ULONG is defined as: #define BN_ULONG unsigned long Neither it works if I do something like unsigned long q = 2; BN_set_word(two, q); Because it returns Invalid arguments ' Candidates are: int BN_set_word(bignum_st *, ?) ' or BN_ULONG q = 2; BN

2021-06-12 11:53:49    分类:问答    c++   c   openssl   bignum

##### Restore a number from several its remainders (chinese remainder theorem)

I have a long integer number, but it is stored not in decimal form, but as set of remainders. So, I have not the N number, but set of such remainders: r_1 = N % 2147483743 r_2 = N % 2147483713 r_3 = N % 2147483693 r_4 = N % 2147483659 r_5 = N % 2147483647 r_6 = N % 2147483629 I know, that N is less than multiplication of these primes, so chinese remainder theorem does work here ( http://en.wikipedia.org/wiki/Chinese_remainder_theorem ). How can I restore N in decimal, if I have this 6 remainders? The wonderful will be any program to do this (C/C+GMP/C++/perl/java/bc). For example, what minimal

2021-06-10 04:23:08    分类:问答    math   gmp   bignum   arbitrary-precision   chinese-remainder-theorem

##### Convert really big number from binary to decimal and print it

I know how to convert binary to decimal. I know at least 2 methods: table and power ;-) I want to convert binary to decimal and print this decimal. Moreover, I'm not interested in this `decimal'; I want just to print it. But, as I wrote above, I know only 2 methods to convert binary to decimal and both of them required addition. So, I'm computing some value for 1 or 0 in binary and add it to the remembered value. This is a thin place. I have a really-really big number (1 and 64 zeros). While converting I need to place some intermediate result in some 'variable'. In C, I have an `int' type

2021-06-09 21:09:06    分类:问答    c   binary   decimal   bignum   bcd

##### Convert a big number given as a string to an OpenSSL BIGNUM

I am trying to convert a string p_str representing a big integer to a BIGNUM p using the OpenSSL library. #include <stdio.h> #include <openssl/bn.h> int main () { /* I shortened the integer */ unsigned char *p_str = "82019154470699086128524248488673846867876336512717"; BIGNUM *p = BN_bin2bn(p_str, sizeof(p_str), NULL); BN_print_fp(stdout, p); puts(""); BN_free(p); return 0; } Compiled it with: gcc -Wall -Wextra -g -o convert convert.c -lcrypto But, when I execute it, I get the following result: 3832303139313534

2021-06-02 11:22:45    分类:问答    c   openssl   bignum

##### How to serialize the GMP mpf type?

It seems that GMP provides only string serialization of the mpf (floating point) type: mpf_get_str(), mpf_class::get_str() The mpz (integer) type has an additional interface for raw bytes: mpz_out_raw() http://gmplib.org/manual/Function-Index.html Am I missing something? Does anyone know of another library that can serialize GMP floats? Does anyone know of another bignum lib that offers robust serialization? Edit: I'd be happy with serializing MPFR's mpfr_t, as well, which similarly only seems to offer string output: http://www.mpfr.org/mpfr-current/mpfr.html#Function-Index

2021-06-02 10:45:34    分类:问答    c++   c   serialization   bignum   gmp

##### custom data type in C

I am working with cryptography and need to use some really large numbers. I am also using the new Intel instruction for carryless multiplication that requires m128i data type which is done by loading it with a function that takes in floating point data as its arguments. I need to store 2^1223 integer and then square it and store that value as well. I know I can use the GMP library but I think it would be faster to create two data types that both store values like 2^1224 and 2^2448. It will have less overhead.I am going to using karatsuba to multiply the numbers so the only operation I need to

2021-06-01 21:06:51    分类:问答    c   types   bignum

##### SHA256 Hash results different across Android & iOS for Big numbers

I'm trying to Hash a BigInteger/BigNum and I'm getting different results in Android/iOS. I need to get the same Hash result so that both the apps work as per the SRP protocol. On closer inspection it is working fine for positive numbers but not working for negative numbers (first nibble greater than 7). Not sure which one is correct and which one is to be adjusted to match with the other. Android: void hashBigInteger(String s) { try { BigInteger a = new BigInteger(s, 16); MessageDigest sha = MessageDigest.getInstance("SHA-256"); byte[] b = a.toByteArray(); sha.update(b, 0, b.length); byte[]

2021-05-25 04:36:59    分类:问答    android   ios   hash   biginteger   bignum

##### Emacs / elisp中的bignum(bignum in emacs/elisp)

2021-05-17 22:12:27    分类:技术分享    elisp   biginteger   bignum

##### JavaScript中的大整数（更多2 ^ 53-1）(Large integers in javascript (more the 2^53-1))

2021-05-09 02:41:55    分类:技术分享    javascript   biginteger   bignum