GuillaumeCisco edited a comment on issue #38: Python wrappers
URL: 
https://github.com/apache/incubator-milagro-crypto-c/issues/38#issuecomment-521321028
 
 
   Thanks.
   I need a little help on this one.
   If I create rom.c like:
   ```c
   #include <stdio.h>
   #include <stdlib.h>
   #include <string.h>
   #include <time.h>
   #include <amcl/pair_FP256BN.h>
   
   int main()
   {
   BIG_256_56 q2;
   BIG_256_28 r2;
   
   printf("BLS381\n");
   BIG_256_56_rcopy(q2, Modulus_FP256BN);
   printf("q (381) = 0x");
   BIG_256_56_output(q2);
   printf("\n");
   BIG_256_28_rcopy(r2 ,CURVE_Order_FP256BN);
   printf("r (257) = 0x");
   }
   ```
   
   Then how do I wrap it with cffi?
   If I write something like:
   ```python
   import cffi
   import platform
   
   ffi = cffi.FFI()
   ffi.cdef("""
      int main();
   """)
   
   
   if (platform.system() == 'Windows'):
       libamcl_wcc_FP256BN = ffi.dlopen("libamcl_wcc_FP256BN.dll")
       libamcl_core = ffi.dlopen("libamcl_core.dll")
   elif (platform.system() == 'Darwin'):
       libamcl_wcc_FP256BN = ffi.dlopen("libamcl_wcc_FP256BN.dylib")
       libamcl_core = ffi.dlopen("libamcl_core.dylib")
   else:
       libamcl_wcc_FP256BN = ffi.dlopen("libamcl_wcc_FP256BN.so")
       libamcl_core = ffi.dlopen("libamcl_core.so")
   
   libamcl_core.main()
   
   ```
   It won't work, as there is no link between rom.c and `libamcl_core`.
   I should create a .so file from the rom.c, right?
   I have no knowledge in cffi and will learn how to use it.
   But a little help would be great ;)
   Also is it possible to simply export constant from a C code for importing it 
after from python?
   
   Thanks

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@milagro.apache.org
For additional commands, e-mail: issues-h...@milagro.apache.org

Reply via email to