Skip to content

Commit

Permalink
extmod: monero module - muladd256_modm added
Browse files Browse the repository at this point in the history
- required for Bulletproof
  • Loading branch information
ph4r05 committed Aug 17, 2018
1 parent 2db45c3 commit 695a382
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions embed/extmod/modtrezorcrypto/modtrezorcrypto-monero.h
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,20 @@ STATIC mp_obj_t mod_trezorcrypto_monero_mulsub256_modm(size_t n_args, const mp_o
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorcrypto_monero_mulsub256_modm_obj, 3, 4, mod_trezorcrypto_monero_mulsub256_modm);

//void muladd256_modm
STATIC mp_obj_t mod_trezorcrypto_monero_muladd256_modm(size_t n_args, const mp_obj_t *args){
mp_obj_t res = n_args == 4 ? args[0] : mp_obj_new_scalar();
const int off = n_args == 4 ? 0 : -1;

assert_scalar(res);
assert_scalar(args[1+off]);
assert_scalar(args[2+off]);
assert_scalar(args[3+off]);
muladd256_modm(MP_OBJ_SCALAR(res), MP_OBJ_C_SCALAR(args[1+off]), MP_OBJ_C_SCALAR(args[2+off]), MP_OBJ_C_SCALAR(args[3+off]));
return res;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_trezorcrypto_monero_muladd256_modm_obj, 3, 4, mod_trezorcrypto_monero_muladd256_modm);

//void contract256_modm_r
STATIC mp_obj_t mod_trezorcrypto_monero_pack256_modm(const mp_obj_t arg){
assert_scalar(arg);
Expand Down Expand Up @@ -1023,6 +1037,7 @@ STATIC const mp_rom_map_elem_t mod_trezorcrypto_monero_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_sub256_modm), MP_ROM_PTR(&mod_trezorcrypto_monero_sub256_modm_obj) },
{ MP_ROM_QSTR(MP_QSTR_mul256_modm), MP_ROM_PTR(&mod_trezorcrypto_monero_mul256_modm_obj) },
{ MP_ROM_QSTR(MP_QSTR_mulsub256_modm), MP_ROM_PTR(&mod_trezorcrypto_monero_mulsub256_modm_obj) },
{ MP_ROM_QSTR(MP_QSTR_muladd256_modm), MP_ROM_PTR(&mod_trezorcrypto_monero_muladd256_modm_obj) },
{ MP_ROM_QSTR(MP_QSTR_pack256_modm), MP_ROM_PTR(&mod_trezorcrypto_monero_pack256_modm_obj) },
{ MP_ROM_QSTR(MP_QSTR_pack256_modm_into), MP_ROM_PTR(&mod_trezorcrypto_monero_pack256_modm_into_obj) },
{ MP_ROM_QSTR(MP_QSTR_unpack256_modm), MP_ROM_PTR(&mod_trezorcrypto_monero_unpack256_modm_obj) },
Expand Down

0 comments on commit 695a382

Please sign in to comment.