Takes a 64-byte integer and outputs the lowest 32 bytes modulo the prime q . This is not a CryptoNote-specific function, but comes from the standard ed25519 library.
Takes a 32-byte integer and outputs the integer modulo q. Same code as above, except skipping the 64→32 byte step
Also according to this question(sorry I don't have enough rep to ask as a comment):
import ed25519 import binascii spendkey_hex = b'77fadbe52830d30438ff68036374c0e3fb755d0d983743bcbfb6a45962f50a09' sk = binascii.unhexlify(spendkey_hex) def sc_reduce32(n): n = int.from_bytes(n, byteorder='little') l = (2**252 + 27742317777372353535851937790883648493) reduced = n % l newbytes = reduced.to_bytes(32, 'little') return newbytes reduced_sk = sc_reduce32(sk)
which in turn doesn't match MiniNero code:
q = 2**255 - 19 l = 2**252 + 27742317777372353535851937790883648493 def sc_reduce_key(a): return intToHex(hexToInt(a) % l)
I realise MiniNero is hugely outdated and ShenNoether's replacement never materialized. His version/profiles have disappeared from GitHub/Reddit(Noblesir), but I noticed that Ryan started work on replicating sc_reduce32 in Python(note he's also the guy who asked Q2290), but it seems incomplete.
I wonder if someone could clarify for me what exactly sc_reduce32 is currently supposed to be doing, so I can continue/complete replicating it in python(unless someone already has? link please?).