# Function ge_fromfe_frombytes_vartime() step by step explanation?

Could somebody please explain how this function works step by step?

Why: I am programming the Monero wallet functions on a quite limited platform with only some inbuilt cryptographic primitives. I need to implement `ge_fromfe_frombytes_vartime` because this function is needed for computing key images.

What I have available:

``````// Keccak hash function
keccak256( ... )

// This routine performs an elliptic curve
// scalar point multiple using the Elliptic Curve 25519
ec25519_point_multiply( ... );

// Multiply point by a scalar for Elliptic Curve 25519
ed25519_scalar_multiply( ... );

// This routine recovers X-coordinate given Y-coordinate
ec25519_xrecover( ... );

// Check signature (point) against message string (hash)
ed25519_valid_sig( ... );

// Functions for modular arithmetics, operands could be 32B integers
C = (A+B) mod P
C = (A-B) mod P
C = (A*B) mod P (P odd)
C = B mod P (P odd), A is ignored
C = (A/B) mod P (P odd)
C = (1/B) mod P (P odd)
C = (A * B) F(p) only, P is ignored
C = (1/B) mod P (P even), A is ignored
C = B mod P (P even), A is ignored
``````

Thanks a lot for any help!

• If you're trying to understand the mathematics behind it, see github.com/monero-project/research-lab/blob/master/whitepaper/… If you're confused about all of the complex shifts in the C code, I'm not clear on what is preventing you from simply porting the hashToPointCN method from Mininero instead. That hashToPointCN method looks like it does mostly use modular arithmetic. – knaccc Dec 17 '19 at 20:19

• My understanding of `ge_fromfe_frombytes_vartime` is that it simply takes a single field element coordinate and recovers the entire EC point in P2 coordinate space, but has modifications to take into account that only 50% of 32 byte sequences will result in a valid coordinate of an EC point. This is entirely different than treating the field element as a scalar and then doing a scalar multiplication. – knaccc Dec 18 '19 at 2:38