A method for decoding a secret, the method comprising performing on a decoding computer: storing a codeword C comprising a proof value π and a secret S in a persistent memory of the decoding computer, the persistent memory comprising P bytes of memory, wherein the codeword C uses c bytes, wherein the proof value π is determined using the secret S and a result Y, the result Y obtained by applying a memory-hard function MHF to the secret S or to a function of the secret S, wherein the applying of the memory-hard function MHF to the secret S requires at least N bytes of memory, and wherein P-c memory forms extra-persistent space; receiving input data; retrieving the codeword C from the persistent memory; parsing the codeword C to identify the proof value π and the secret S; performing, using a transient memory of the decoding computer, a decoding of the codeword C by: using the proof value π to verify a correctness of the result Y as being obtained from memory-hard function MHF using the secret S, wherein the decoding function is operable to use K bytes of memory, K being less than N; when the correctness is true, applying a cryptographic function to the input data using the secret S to obtain output data; and when the correctness is false, providing an error message and causing the decoding computer to be inoperable to perform subsequent decoding operations; refreshing the transient memory of the decoding computer; and persisting E bytes of memory of the decoding on the extra-persistent space, wherein E is less than N and less than the size of the result Y. storing a codeword C comprising a proof value π and a secret S in a persistent memory of the decoding computer, the persistent memory comprising P bytes of memory, wherein the codeword C uses c bytes, wherein the proof value π is determined using the secret S and a result Y, the result Y obtained by applying a memory-hard function MHF to the secret S or to a function of the secret S, wherein the applying of the memory-hard function MHF to the secret S requires at least N bytes of memory, and wherein P-c memory forms extra-persistent space; receiving input data; retrieving the codeword C from the persistent memory; parsing the codeword C to identify the proof value π and the secret S; performing, using a transient memory of the decoding computer, a decoding of the codeword C by: using the proof value π to verify a correctness of the result Y as being obtained from memory-hard function MHF using the secret S, wherein the decoding function is operable to use K bytes of memory, K being less than N; when the correctness is true, applying a cryptographic function to the input data using the secret S to obtain output data; and when the correctness is false, providing an error message and causing the decoding computer to be inoperable to perform subsequent decoding operations; using the proof value π to verify a correctness of the result Y as being obtained from memory-hard function MHF using the secret S, wherein the decoding function is operable to use K bytes of memory, K being less than N; when the correctness is true, applying a cryptographic function to the input data using the secret S to obtain output data; and when the correctness is false, providing an error message and causing the decoding computer to be inoperable to perform subsequent decoding operations; refreshing the transient memory of the decoding computer; and persisting E bytes of memory of the decoding on the extra-persistent space, wherein E is less than N and less than the size of the result Y. <EOS>