2

The tool I use https://www.npmjs.com/package/@smartpy/timelock, https://github.com/RomarQ/tezos-timelock/

the tool works good on other functions such as openChest and createChestKey.

I used node 14.14.0, 16.9.0, 16.10.10 all same output

The error I got when I try to use the chest and key:

[
  0,
  [ 248, ix { t: 0, c: 'Failure', l: 7 }, -3 ],
  ix { t: 0, c: 'rsa modulus is too small', l: 24 }
]

example chest and key outputs,

{
  chest: 'e8af95c5c7ddabd2f3b9fbcc9ba6b69c82aba8b0e7a390af9bdeb9e3f0c4e4a0bebadabaab87e29fffa198eae1d1bd9495c78b89d0d3affb94dff7e4dbff94e1f3a6b2d30bab92d6f8ca97b6a48bcae9f386d3e2abd2a1d6abc089d6dbddabe199e3a682c6b183c4e3ceb8abe389c0c6dadcfdadf3c9819281fac3b9c6b9bddf96c6b4a4c4c8bb868088b9a8fdfbfbe89ce4f0aa81c2a5cba78ad8bac4a1c88ed3f6a8d595b88598d1e1949d8ce1f1fee7a1e4859edde595cc989fe1a0e9fca4e192bed7ecf688bd9181f5f7aa17266c4c88be833df31774d568b6e2e6eebee2ea6e8d962098000000115359d841e241aca028068e58f4da14fc49',
  key: '9ec7d7e9c580b9dfb781939ea889f6ebd3cda9a691cb8ea5b7ac87a2a88d82c2e3bccd97e5ffccd3daf5fef194d0cbbbc3f0aa988ad5e7c9e698d2d8dafcd1f7cdf7fb9d99cbafcb8082fea499b8f6c784c9ddbdb2a080f0d480db83bdf783b9d1daa2978b81ab9cbaf7a0b2f098cff5e3949ec683afd7ccd3f490ce92d0c18db49ba3d1f6d2fbf8028293d9c5c8ba9ab2cbfd9c8cb792c3e9c9b2e2d7e185aef4cab4f0c0b0a1a09ea8a6dece8b9eeeb7f9c0b8f1d09baad8b9b6bfbee09dba86fbcad5eac4f3afc89bab91f4b4ebc696d7dde7fffd97ca93e6def9bae393a7b4c7dcd7bec89787b8d5b89888e9f5a29cc694f2ef8ccacbd5a9e0bf8be1f8aa8eb6e39ff4f1edd3f7b38283f8baf8fd1b'
}

working chest and key example (obtained from example in github),

const chest = "bcf89e8a80d99cd49690dda59accc4d381c1a3facbacc1a3f9aab5e7ecdc8db6b0928eed84a7e5d9958e96b5b1f3c8ddd9b98dd394f9bafaafad85a2d7cbffeec1e280d5c6ccbab3caddb5ced3c1d39c82cea0cc99b7f788bbca85eeb1badd91fdc8e1e1e9a6cddca7bdef8faaf6acf2aeef8ccbd3d987f6d0ecf9c8c9818c92eb8a81e385fff9e8c4ad96d6e7bad6a480ec83f3cb84bedeac82baafa1b88bfd90968b9ee7b2d8aabef9d8e0d9a9c8a5a8859a8db5e6d496de95cfd2cfc4dcfae3edf9f1d5faee998694ed8aada2a7d4b88aecc8acda98d6f69cfb8df3a5ca80b48d91aa9bbbf68f918998ddc5d3cc82d3f0ce81869fd9edb8b0989dcfa5e9b59db18dd099c7b8bb848586afc7c8888f86d2c6988eeee5e5fbfc9de8a7f19e84ebc2b687049390ebd5cecb86eecfe2bef994f9a7c3eabeabdda0b4b7b59381a8a4c3d7c1b382bcf6e1adb2e3c6ce9ca5e0c0a0beb999f4eacc89cf858fb282b294d99ec2daccd9cdcc98a98b8cb5b0bbf9ed80b0f6ccd2a994f3a1faafbbacf7eebbec9399bfdfd1f0da9ee4aa9dcb8b9c85fcab87bd86b98fd7cc9a8cb2e3cc93ef86df83e5ce9bbda8c7d4cad0e4b893fde8e18b9cf283f9829f9ab8f48da8b0f1b5c8f3a1d2a1a6e5c1fec0abb09eb9b0c2c3ae9f9df6c6a7bad396f7b3b1fc90e490a4f2a5f599fedbc8b3b297a99db3b285a3f0acefe0c8d4cec08195af8098d0f4b8d488bdacd7e8effea5cdaf8dd1ccdbe4fee59eb7e1cebff2eb839b8f81d598abc798d5bdcea59bfcbaf89fbdbbcb8182a3eea1f4f5dccafcb4ddd4ff83d3879edef5d3ca06d2f1146cf4c25faf0e432bf540b4de74fae3cc68e0bc57c700000021cf744e778f4d5e220d4be7310077e6735795b6c90bbe2bdcdd9b686e3c71f833f2";

const chest_key = "f5d3cec5da988edfbee8be85b4919bc7c5a3f7ecebe7a19ac8e0c3f9c3aac5948de9b9dddab88b93c4fee4d094a3a5e48494c0ae80b4ffbcd9a8b7a2c9f3dfc0e2e18082f3d3ceabf9f1a7c8fcd4dec7b7e091a89e83f8a6ab90dea1bdbd95bff9ed8ac89c88ebeecfe5faaeb8f184e5df9298e5aff3bad5bbc1fcefdbb5b2929df9c6ced9aebefbc49decb4d9e085b1a8c39099818d97e0b3dbf287efb99c87c8eeb38f86d9e9c2bdeccec4abb5ce89bce988aba5a0adf59180898697a7e5d1dfa8d5a6aac8f0f5bd87ecb7aeaedec6a4f7f5bfead9e1cbd3a8a88fddcb939198f0ae94cecdc3e9d3d9c2b28ece8ff487a0e983868ef995b3ee90f082adf8aeddbab2efc2b5fcd5aff1a19bb3acff83b08986d0ffa3eec4afabbec280f4d498b1f2e6de01c192a381d3b8c19dd8edb4d6e689cbccb1b5c396c7abda9bc4ed9edf9ecff7c78bab8fadbbd4f4e7d1d289eace839becdfa5e7d1ddc2b0e9e1e88d87a3e3aae8c6dd889cd980e69af8b992d4b5e28cb691de94c0afe0f3fbde8b85e4eced9ec8dcd986d189e4a8bcd3fda2efbce5cde9d68499eef7bda5a782c3adf0cc84abd0c0ec91988b9a81ad819af19e97eefacea9a9b1ffe2d1bcc1e5d8dc87e89d8a92afd3fcf4d4d2e1d9e4f583c5a583ebb6f19dd7abd3f8f5d6a8ee9bf78faa8aedf0d8b0e6a1a6bf95849192b5f8bfef9581deaebef3e6f390ac99ade490e7feb5d0d589cce2e3d4b9ced493e3fac1da83f697e6c0e68f8295ec97f2c0aae7dcaffaedb5fef283d4a5b4f3fdd8e7a0b0f9c4accce9c2f9e9ba8b8391fad3d0db84cbe9f3d003";

noticable difference is hex generated by tezos-timelock is smaller than functional ones.

how can I generate functional chest and key using js ?

3
  • Any chance to explain how its work - with simple word - for a newby like me ? :) I see the time value is 3456, why ? When i read some stuff on the commit/reveal schem, we need a "secret" seed, how its work in the blockchain, anyone can see this seed no ?
    – justone
    Jul 19 at 4:44
  • timelock is not needed for implementing commit & reveal scheme (can be alternative for it but its not practical and secure atm). the secret seed you are talking about is blinding factor to create different hashes for same commits, without blinding factor commit1 : rock --- hash ----> 0xaa commit2 : rock --- hash ----> 0xaa with blinding factor commit1 : rock + 42(random number) --- hash ----> 0xabcd commit2 : rock + 35(random number) --- hash ----> 0x4263
    – Hexa
    Jul 26 at 7:42
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review
    – Tom
    Aug 4 at 0:12

1 Answer 1

1

The javascript primitives seem to be weak for creating the chest.

You can use the CLI: ./timelock.exe create-chest-and-chest-key --payload "05010000000b48454c4c4f20574f524c44" --time 3456

And then open it with the JS package:

(async () => {
    // Make sure the hacl wasm bindings get loaded before running any other method
    await Timelock.ensureHaclWasmLoaded();

    const time = 3456;

    const chest = "bcf89e8a80d99cd49690dda59accc4d381c1a3facbacc1a3f9aab5e7ecdc8db6b0928eed84a7e5d9958e96b5b1f3c8ddd9b98dd394f9bafaafad85a2d7cbffeec1e280d5c6ccbab3caddb5ced3c1d39c82cea0cc99b7f788bbca85eeb1badd91fdc8e1e1e9a6cddca7bdef8faaf6acf2aeef8ccbd3d987f6d0ecf9c8c9818c92eb8a81e385fff9e8c4ad96d6e7bad6a480ec83f3cb84bedeac82baafa1b88bfd90968b9ee7b2d8aabef9d8e0d9a9c8a5a8859a8db5e6d496de95cfd2cfc4dcfae3edf9f1d5faee998694ed8aada2a7d4b88aecc8acda98d6f69cfb8df3a5ca80b48d91aa9bbbf68f918998ddc5d3cc82d3f0ce81869fd9edb8b0989dcfa5e9b59db18dd099c7b8bb848586afc7c8888f86d2c6988eeee5e5fbfc9de8a7f19e84ebc2b687049390ebd5cecb86eecfe2bef994f9a7c3eabeabdda0b4b7b59381a8a4c3d7c1b382bcf6e1adb2e3c6ce9ca5e0c0a0beb999f4eacc89cf858fb282b294d99ec2daccd9cdcc98a98b8cb5b0bbf9ed80b0f6ccd2a994f3a1faafbbacf7eebbec9399bfdfd1f0da9ee4aa9dcb8b9c85fcab87bd86b98fd7cc9a8cb2e3cc93ef86df83e5ce9bbda8c7d4cad0e4b893fde8e18b9cf283f9829f9ab8f48da8b0f1b5c8f3a1d2a1a6e5c1fec0abb09eb9b0c2c3ae9f9df6c6a7bad396f7b3b1fc90e490a4f2a5f599fedbc8b3b297a99db3b285a3f0acefe0c8d4cec08195af8098d0f4b8d488bdacd7e8effea5cdaf8dd1ccdbe4fee59eb7e1cebff2eb839b8f81d598abc798d5bdcea59bfcbaf89fbdbbcb8182a3eea1f4f5dccafcb4ddd4ff83d3879edef5d3ca06d2f1146cf4c25faf0e432bf540b4de74fae3cc68e0bc57c700000021cf744e778f4d5e220d4be7310077e6735795b6c90bbe2bdcdd9b686e3c71f833f2";

    const chest_key = "f5d3cec5da988edfbee8be85b4919bc7c5a3f7ecebe7a19ac8e0c3f9c3aac5948de9b9dddab88b93c4fee4d094a3a5e48494c0ae80b4ffbcd9a8b7a2c9f3dfc0e2e18082f3d3ceabf9f1a7c8fcd4dec7b7e091a89e83f8a6ab90dea1bdbd95bff9ed8ac89c88ebeecfe5faaeb8f184e5df9298e5aff3bad5bbc1fcefdbb5b2929df9c6ced9aebefbc49decb4d9e085b1a8c39099818d97e0b3dbf287efb99c87c8eeb38f86d9e9c2bdeccec4abb5ce89bce988aba5a0adf59180898697a7e5d1dfa8d5a6aac8f0f5bd87ecb7aeaedec6a4f7f5bfead9e1cbd3a8a88fddcb939198f0ae94cecdc3e9d3d9c2b28ece8ff487a0e983868ef995b3ee90f082adf8aeddbab2efc2b5fcd5aff1a19bb3acff83b08986d0ffa3eec4afabbec280f4d498b1f2e6de01c192a381d3b8c19dd8edb4d6e689cbccb1b5c396c7abda9bc4ed9edf9ecff7c78bab8fadbbd4f4e7d1d289eace839becdfa5e7d1ddc2b0e9e1e88d87a3e3aae8c6dd889cd980e69af8b992d4b5e28cb691de94c0afe0f3fbde8b85e4eced9ec8dcd986d189e4a8bcd3fda2efbce5cde9d68499eef7bda5a782c3adf0cc84abd0c0ec91988b9a81ad819af19e97eefacea9a9b1ffe2d1bcc1e5d8dc87e89d8a92afd3fcf4d4d2e1d9e4f583c5a583ebb6f19dd7abd3f8f5d6a8ee9bf78faa8aedf0d8b0e6a1a6bf95849192b5f8bfef9581deaebef3e6f390ac99ade490e7feb5d0d589cce2e3d4b9ced493e3fac1da83f697e6c0e68f8295ec97f2c0aae7dcaffaedb5fef283d4a5b4f3fdd8e7a0b0f9c4accce9c2f9e9ba8b8391fad3d0db84cbe9f3d003";

    const result = await Timelock.openChest(chest, chest_key, time);

    // result = `{"kind":"Correct","bytes":"05010000000b48454c4c4f20574f524c44"}`
})();

I do not expect to have much time in the upcoming weeks, but I will try to have a look at the javascript primitives.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.